[FIXED] os-nut plugin permissions issue

Started by ittchmh, November 25, 2020, 03:36:26 PM

Previous topic - Next topic
November 25, 2020, 03:36:26 PM Last Edit: November 26, 2020, 07:45:35 AM by ittchmh
I have NUT usb permissions issue
It doesn't work, always UPS APC is unavailable end errors like
Command: /usr/local/etc/rc.d/nut restart
Output:

nut not running? (check /var/db/nut/upsd.pid).
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
No matching HID UPS found
Driver failed to start (exit status=1)
/usr/local/etc/rc.d/nut: WARNING: failed precmd routine for nut


In logs I see errors like
restarting nut
returned exit status 1


Command: usbconfig
Output:
ugen0.1: <Intel EHCI root HUB> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.2: <vendor 0x8087 product 0x07db> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen0.3: <American Power Conversion Back-UPS XS 700U   FW:924.Z3 .I USB FW:Z3> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (24mA)
ugen0.4: <Generic Ultra Fast Media> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (96mA)


Config file /usr/local/etc/nut/ups.conf

[APC]
driver=usbhid-ups
port=ugen0.3


I've set /etc/devfs.conf to

perm usb0 0770
own usb0 root:uucp

perm uhid0 0770
own uhid0 root:uucp

[nut_usb=10]
add path 'ugen0.3' group wheel user uucp mode 0770
add path 'usb/0.3.0' group wheel user uucp mode 0770


Reloaded rules with /etc/rc.d/devfs restart

If I run from console /usr/local/libexec/nut/usbhid-ups -u root -D -a APC it works

Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
   0.000000     debug level is '1'
   0.000802     upsdrv_initups...
   0.066616     Using subdriver: APC HID 0.96
   0.066641     104 HID objects found
   0.068696     Path: UPS.PowerSummary.iProduct, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8, Value: 1
....


If I run without root parameter /usr/local/libexec/nut/usbhid-ups -D -a APC I get

Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
   0.000000     debug level is '1'
   0.000828     upsdrv_initups...
   0.001004     No matching HID UPS found


So it seams to NUT USB permissions issue, I can't reboot right now after I edited /etc/devfs.conf but I reloaded devfs service

Please help!

I fixed

/etc/devfs.conf
perm    ugen0.3 0770
own     ugen0.3 uucp:wheel


/etc/devfs.rules
[nut_usb=10]
add path 'ugen0.3' group wheel user uucp mode 0770


/etc/rc.conf
devfs_system_ruleset="nut_usb"

Restart service to read new config
/etc/rc.d/devfs restart

Check permissions
ls -l /dev/ug*
Output:
lrwxr-xr-x  1 root  wheel  9 Nov 18 11:53 /dev/ugen0.1 -> usb/0.1.0
lrwxr-xr-x  1 root  wheel  9 Nov 18 11:53 /dev/ugen0.2 -> usb/0.2.0
lrwxrwx---  1 uucp  wheel  9 Nov 18 11:53 /dev/ugen0.3 -> usb/0.3.0
lrwxr-xr-x  1 root  wheel  9 Nov 18 11:53 /dev/ugen0.4 -> usb/0.4.0


Now it should work!

Hi,

just wanted to thank you had exactly the same problem and was going crazy, you saved me a lot of time thanks again!

Ditto. I just did this on a 22.7.11 after moving hardware and restoring backup.