[Bug 269729] sysutils/nut USB permissions issue

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 21 Feb 2023 07:28:31 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269729

            Bug ID: 269729
           Summary: sysutils/nut USB permissions issue
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: cy@FreeBSD.org
          Reporter: dennypage@me.com
          Assignee: cy@FreeBSD.org
             Flags: maintainer-feedback?(cy@FreeBSD.org)

I maintain the NUT package for pfSense and have run into an issue with USB
permissions for some UPS models. 

NB: My testing is against nut-2.8.0_13, but I haven't seen anything suggesting
that the issue is resolved in later port revisions.

The permission problem arrises from the fact that the kernel attaches a driver
to the device during initialization, and this subsequently prevents the device
from being opened by usbhid-ups. The error reported is "Can't claim USB device"

The following demonstrates the specifics:

-----
[23.01-RELEASE][root@fw]/root: usbconfig -d ugen0.2 show_ifdrv
ugen0.2: <American Power Conversion Smart-UPS1000 FW:UPS 16.0 / ID1047> at
usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (10mA)
ugen0.2.0: uhid0: <American Power Conversion Smart-UPS1000 FW:UPS 16.0 /
ID1047, class 0/0, rev 2.00/0.01, addr 4>

[23.01-RELEASE][root@fw]/root: /usr/local/libexec/nut/usbhid-ups -a ups
Network UPS Tools - Generic HID driver 0.47 (2.8.0)
USB communication driver (libusb 1.0) 0.43
interrupt pipe disabled (add 'pollonly' flag to 'ups.conf' to get rid of this
message)
Can't claim USB device [051d:0003]@0/0: Other error

[23.01-RELEASE][root@fw]/root: usbconfig -d ugen0.2 detach_kernel_driver

[23.01-RELEASE][root@fw]/root: usbconfig -d ugen0.2 show_ifdrv
ugen0.2: <American Power Conversion Smart-UPS1000 FW:UPS 16.0 / ID1047> at
usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (10mA)

[23.01-RELEASE][root@fw]/root: /usr/local/libexec/nut/usbhid-ups -a ups
Network UPS Tools - Generic HID driver 0.47 (2.8.0)
USB communication driver (libusb 1.0) 0.43
interrupt pipe disabled (add 'pollonly' flag to 'ups.conf' to get rid of this
message)
Using subdriver: APC HID 0.98

[23.01-RELEASE][root@fw]/root: 
-----

As you would expect, if the "-u root" option is added to usbhid-ups then it
will succeed even if the kernel driver is currently attached.

I note that this permission issue is also present in the truss outputs in bug
#267144

-- 
You are receiving this mail because:
You are the assignee for the bug.