summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Hjelm <hjelmn@google.com>2021-08-07 23:02:16 -0600
committerNathan Hjelm <hjelmn@google.com>2021-08-07 23:10:52 -0600
commit3ed54c52b1ece08eae21774fbac50a5cc16bae93 (patch)
treecb2b4e3e1df06f44a128d4b1df49f71d44d53632
parente2edecd3a3f3ff79f58c992862f15b00e4eb3c49 (diff)
downloadlibusb-3ed54c52b1ece08eae21774fbac50a5cc16bae93.tar.gz
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>
-rw-r--r--libusb/os/darwin_usb.c29
-rw-r--r--libusb/version_nano.h2
2 files changed, 15 insertions, 16 deletions
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 @@ static int darwin_detach_kernel_driver (struct libusb_device_handle *dev_handle,
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;
- }
-
- /* request authorization */
- kresult = IOServiceAuthorize (dpriv->service, kIOServiceInteractionAllowed);
- if (kresult != kIOReturnSuccess) {
- usbi_warn (ctx, "IOServiceAuthorize: %s", darwin_error_str(kresult));
- return darwin_to_libusb (kresult);
- }
+ 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);
+ }
- /* 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