Skip to content

[pull] master from libusb:master#10

Merged
pull[bot] merged 6 commits intohttpsgithu:masterfrom
libusb:master
May 17, 2021
Merged

[pull] master from libusb:master#10
pull[bot] merged 6 commits intohttpsgithu:masterfrom
libusb:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull bot commented May 17, 2021

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

osy and others added 6 commits May 16, 2021 15:13
USBDeviceReEnumerate() does not return an error code (bug?) so if it fails
we could be stuck waiting forever. Set a sane timeout to 10s.

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Since it calls USBDeviceReEnumerate() and not USBDeviceReset(), we name
it accordingly.

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
When libusb_detach_kernel_driver() is called on the first interface, we use
the capture re-enumerate APIs to force kernel drivers to detach. On
subsequent calls, a counter is incremented to keep track of the number of
detach calls. When libusb_attach_kernel_driver() is called for the same
number of times, then we re-enumerate (reset) and let kernel drivers
re-attach.

darwin_kernel_driver_active() is changed to attempt to claim an interface
and return 1 only if a kIOReturnExclusiveAccess status is returned. The old
implementation which looks for a CFBundleID in the IORegistryEntry does not
seem to work in all cases.

darwin_reset_device() is aware of the capture status and will re-set twice
if capture mode is enabled: once to do a USB reset and again to re-capture.

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
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>
The InterfaceVersion is what we want and there is no reason to also check
that the InterfaceVersion matches the macOS version it was introduced in.
This check inadvertently disables features for other Apple platforms that
use IOKit.

Closes #911

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
@pull pull bot added the ⤵️ pull label May 17, 2021
@pull pull bot merged commit 35e8ee9 into httpsgithu:master May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants