libusb/hidapi

Why need sudo for libhidapi-libusb and not for libhidapi-hidraw?

FauthD opened this issue · 4 comments

FauthD commented

Hi,
on Ubuntu 22.04 I need sudo for a test tool (Python bindings) when libhidapi-libusb is installed.
Enforcing libhidapi-hidraw (by uninstalling libusb backend) allows my tool to run without sudo.
Note: I have access rights to the /dev/hidrawX without sudo.

Thanks!

Youw commented

From main README:

Note that you will need to install an udev rule file with your application for unprivileged users to be able to access HID devices with hidapi. Refer to the 69-hid.rules file in the udev directory for an example.

FauthD commented

That's what I did in first place, did develop USB stuff since 1996 (with Linux since 2004).
The devices use "root plugdev" (owner group).
crw-rw---- 1 root plugdev 234, 0 Jan 15 22:13 /dev/hidraw0

Tools using the HidRaw backend work fine without sudo.
Only the UsbLib backend needs sudo (unfortunatelly this is prioritized from Python bindings).
Assumption is some path in /sys/* needs root root. It is that many paths are used in enumeration, probably one of it is the problem.
Double checked the rights for the .so files, these are the same to each other.

And some lib (dfUsbLib) I wrote some years ago also works fine without sudo (always worked), but that only used libudev, not libhidraw.

Next days I will analyze further, just had the hope that someone already knows about this issue.

Edit: Sure I am a member of group plugdev (since years on that PC).

FauthD commented

Just got a message this is marked as completed. Not quite right.
Please repopen.

Youw commented

This is an issue tracker, not a support forum. I'm closing everything that is not related to the implementation of HIDAPI.
I'll convert it into a discussion - this is the most I can do right now.