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>
}
} else {
usbi_info (ctx, "no capture entitlements. may not be able to detach the kernel driver for this device");
}
} 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 */
}
/* reset device to release existing drivers */
-#define LIBUSB_NANO 11648
+#define LIBUSB_NANO 11649