Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: IOKit framework location corrected. #120

Merged
merged 1 commit into from
Dec 7, 2019
Merged

Conversation

0xDP
Copy link
Contributor

@0xDP 0xDP commented Nov 17, 2019

@Youw Youw added the macOS Related to macOS backend label Nov 17, 2019
@Youw Youw self-requested a review November 17, 2019 20:09
@Youw
Copy link
Member

Youw commented Nov 17, 2019

thanks for your PR

seems reasonable, but we have to take into account the fact that this has been working for years, and I don't recall any issues related to it

best case scenario, if we could test it on all versions of macOS starting with 10.6 and check how exactly does this work (before/after the change), not to accidentally cause some regressions
Any volunteers?
After second though, no need - since we link against IOKit.framework this path is not relevant - dlopen would simply return a reference to already loaded library (by name)

I can check only latest macOS 10.15 (Catalina):
It works as expected before AND after this patch - IOKit.framework gets loaded just fine
I almost sure, this is because libhidapi.dylib is linked against IOKit.statically for some reason:

$ otool -L mac/.libs/libhidapi.0.dylib 
mac/.libs/libhidapi.0.dylib:
	/usr/local/lib/libhidapi.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1673.126.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)

Secondly, I'm not sure we want to support macOS 10.5 and older (for the same reason we dropped support of Linux 2.x(something) earlier, and simpler would be just to link against IOKit.framework statically, and don't do this dynamic load at all

Copy link
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a second thought:
#121 will go for next release
let's have this one

@Youw Youw merged commit 65d22a9 into libusb:master Dec 7, 2019
@Youw
Copy link
Member

Youw commented Dec 7, 2019

Fixes #119

@cyberstudio10
Copy link

This fix actually fixed my problem in Mojave and Catalina. My app worked until put in a sandbox and signed with Hardened Runtime with the com.apple.security.device.usb entitlement. hid_enumerate put empty strings in the path field and I was not able to open anything. This was fixed when the path to dlopen was corrected. Just here to say thank you for this fix and to confirm that this fix has real world significance even though things seem to have been working for many many years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS Related to macOS backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants