-
-
Notifications
You must be signed in to change notification settings - Fork 374
usbhid-ups should complain if it has no access to USB devices #477
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
Comments
As noted in the Ubuntu bug LP1483615, "The APC portion of usbhid-ups expects that if it can open the device, it can read the string descriptors." In Launchpad, you can mark that bug as affecting you to give it more visibility. The Ubuntu revision 2.7.2-4ubuntu1.2 fixes the LP1540008 udev/permissions issue. I would recommend enabling Closing this issue since the segfault and permissions issues are being tracked elsewhere. |
As I understood LP1483615 it is about an issue where although it can open the device (which I guess means the |
Can you please verify: does the SEGFAULT also happen with current (git master HEAD) code? If yes - it is our issue, if no (fixed already) it is a distro issue. |
With the current master the error is now:
That's better than a segfault, but still doesn't really point at a permissions problem.
would be much clearer. |
Yes, probably. Thanks for the test. Can you run the driver with deeper debug (many -D options) to see if it sees and reports the issue at some level? |
Doesn't seem so:
strace:
|
Thanks for the details, I hope to look at adding a few checks there soon. |
Looking at libusb.c, around lines 178-255, I see that the call NUT makes is for NUT code does not work with /dev paths directly, so apparently the third-party library hides its inability to contact the device and the reason. Not sure if libusb-0.1 native, 0.1 compat in 1.x, or 1.x modern would make a difference. Just in case, can you please try compiling against newer libusb? (There's a git branch for that, currently in experimental/vote-gathering phase) |
With the
With at least two D's the ouput is:
(Build on Travis from this) |
Thanks for the tests. So the problem seems two-fold: that libusb 0.1 fails to report the problem, and I'm not sure how much we can do about that, and that NUT logging priority for the error which is reported can be bumped to a more visible number (e.g. 0 or 1)? |
@AndreKR : hello again, can you check if a build of https://github.com/jimklimov/nut/tree/libusb-1.0 does what you want? :) |
The problem seems to be more complicated than I initially realized. Now we have bogus error message for all the non-UPS devices:
In order to solve this I guess the matching would have to be split up into two parts, one that only used vendor/product ID and one that actually requires access to the device. However, maybe that is unnecessarily complicated. While I was trying to diagnose the problem I did run it with one |
…accessing the device (issue networkupstools#477)
Posted an updated PR to log those errors at debug-level 1. As for matching the vendor/product IDs before opening the USB device - the current API does not provide for that easily: AFAIU the generic routine is used to open each USB device and invoke a callback to match this device for the driver in question (where the callback recognizes a device's metadata as supported), I guess. Details about devices we were able to open, and whether they matched or were skipped, are still available at debug level 2. |
Yep, works as expected. |
FWIW, we can count how many errors we had and if there were any not about access rights. However it seems that with libusb-0.1 API we can only evaluate the string value of usb_strerror() return values - in the library source there is magic about tracking errors in their string buffer or as a printable errno, and no reliably usable way to learn of an With libusb-1.0 however the |
When the proper udev rules are not applied and the nut user cannot access the USB devices, it just segfaults. A better error message would be very helpful.
Original details:
This is on Ubuntu 16.04 with an APC Back-UPS CS 500.
ups.conf:
syslog:
It works with
-u root
:Only while I collected data for this issue report, I found out that it's a permission problem. I will now go read about how to grant permissions for a USB device to the
nut
user, but I do think a better error message would have been very helpful.The text was updated successfully, but these errors were encountered: