darwin: add authorization for device capture
authorosy <50960678+osy@users.noreply.github.com>
Wed, 12 May 2021 03:58:59 +0000 (20:58 -0700)
committerNathan Hjelm <hjelmn@google.com>
Sun, 16 May 2021 21:15:05 +0000 (15:15 -0600)
commit6a902c3b207a017cd699ac8bb6659abf32eb0c99
tree564ec71c6ac443a828ebbc8dd280a07564453029
parentabd788c203624930241f45f32b501c16936bd806
darwin: add authorization for device capture

To use USBDeviceReEnumerate with kUSBReEnumerateCaptureDeviceMask your app
either needs to be running as root OR have the 'com.apple.vm.device-access'
entitlement AND have the user authorization requested via
IOServiceAuthorize().

We can use the capture re-enumerate APIs if either 1) the process is running
as root or 2) the 'com.apple.vm.device-access' entitlement is used AND
IOServiceAuthorize() is called. We assume that if the entitlement is not
there then we are running as root--if this is not true, then
darwin_detach_kernel_driver will fail anyways.

The authorization status is cached in the device's start() so we have to
stop() and start() the device by destroying the plugin and recreating it
again.

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Xcode/libusb.xcodeproj/project.pbxproj
configure.ac
libusb/os/darwin_usb.c
libusb/os/darwin_usb.h
libusb/version_nano.h