darwin: fix USB capture for root This commit restores the ability to capture-open a USB device when running as root. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index 319289b..5d31088 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c
@@ -2439,22 +2439,21 @@ if (dpriv->capture_count == 0) { usbi_dbg (ctx, "attempting to detach kernel driver from device"); - if (!darwin_has_capture_entitlements ()) { - usbi_info (ctx, "no capture entitlements. can not detach the kernel driver for this device"); - return LIBUSB_ERROR_NOT_SUPPORTED; - } + if (darwin_has_capture_entitlements ()) { + /* request authorization */ + kresult = IOServiceAuthorize (dpriv->service, kIOServiceInteractionAllowed); + if (kresult != kIOReturnSuccess) { + usbi_warn (ctx, "IOServiceAuthorize: %s", darwin_error_str(kresult)); + return darwin_to_libusb (kresult); + } - /* request authorization */ - kresult = IOServiceAuthorize (dpriv->service, kIOServiceInteractionAllowed); - if (kresult != kIOReturnSuccess) { - usbi_warn (ctx, "IOServiceAuthorize: %s", darwin_error_str(kresult)); - return darwin_to_libusb (kresult); - } - - /* we need start() to be called again for authorization status to refresh */ - err = darwin_reload_device (dev_handle); - if (err != LIBUSB_SUCCESS) { - return err; + /* we need start() to be called again for authorization status to refresh */ + err = darwin_reload_device (dev_handle); + if (err != LIBUSB_SUCCESS) { + return err; + } + } else { + usbi_info (ctx, "no capture entitlements. may not be able to detach the kernel driver for this device"); } /* reset device to release existing drivers */
diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 94aba9b..981f704 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h
@@ -1 +1 @@ -#define LIBUSB_NANO 11647 +#define LIBUSB_NANO 11648