summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Hjelm <hjelmn@google.com>2021-08-08 09:16:38 -0600
committerNathan Hjelm <hjelmn@google.com>2021-08-08 09:19:21 -0600
commit993b28c400b97e65fc1c457f112e2a9c2fd1d912 (patch)
tree554d2772aeae2682a2db9825e9fbbc0ff0ca5763
parent3ed54c52b1ece08eae21774fbac50a5cc16bae93 (diff)
downloadlibusb-993b28c400b97e65fc1c457f112e2a9c2fd1d912.tar.gz
darwin: improve the error message on kernel driver detach failure
Detaching a kernel driver in macOS requires that either the binary has the com.apple.vm.device-access entitlement or is run with effective UID 0 (root). This commit adds an effective UID check before attempting to capture a device and prints a warning that neither is the user root nor does the binary have the correct entitlement. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
-rw-r--r--libusb/os/darwin_usb.c4
-rw-r--r--libusb/version_nano.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index 5d31088..b6cc359 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -2454,6 +2454,10 @@ static int darwin_detach_kernel_driver (struct libusb_device_handle *dev_handle,
}
} else {
usbi_info (ctx, "no capture entitlements. may not be able to detach the kernel driver for this device");
+ if (0 != geteuid()) {
+ usbi_warn (ctx, "USB device capture requires either an entitlement (com.apple.vm.device-access) or root privelege");
+ return LIBUSB_ERROR_ACCESS;
+ }
}
/* reset device to release existing drivers */
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 981f704..f5aaa73 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11648
+#define LIBUSB_NANO 11649