OPNsense Forum

English Forums => General Discussion => Topic started by: ittchmh on November 25, 2020, 03:36:26 pm

Title: [FIXED] os-nut plugin permissions issue
Post by: ittchmh on November 25, 2020, 03:36:26 pm
I have NUT usb permissions issue
It doesn't work, always UPS APC is unavailable end errors like
Command:
Code: [Select]
/usr/local/etc/rc.d/nut restartOutput:
Code: [Select]
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:
Code: [Select]
usbconfigOutput:
Code: [Select]
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
Code: [Select]
/usr/local/etc/nut/ups.conf
Code: [Select]
[APC]
driver=usbhid-ups
port=ugen0.3

I've set /etc/devfs.conf to
Code: [Select]
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
Code: [Select]
/etc/rc.d/devfs restart
If I run from console
Code: [Select]
/usr/local/libexec/nut/usbhid-ups -u root -D -a APC it works
Code: [Select]
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
Code: [Select]
/usr/local/libexec/nut/usbhid-ups -D -a APC I get

Code: [Select]
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!
(http://Annotation 2020-11-25 161850.png)
Title: [FIXED]Re: os-nut plugin permissions issue
Post by: ittchmh on November 25, 2020, 04:31:21 pm
I fixed

/etc/devfs.conf
Code: [Select]
perm    ugen0.3 0770
own     ugen0.3 uucp:wheel

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

/etc/rc.conf
Code: [Select]
devfs_system_ruleset="nut_usb"
Restart service to read new config
Code: [Select]
/etc/rc.d/devfs restart
Check permissions
Code: [Select]
ls -l /dev/ug*Output:
Code: [Select]
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!
Title: Re: [FIXED] os-nut plugin permissions issue
Post by: Seraph on December 05, 2020, 02:19:58 pm
Hi,

just wanted to thank you had exactly the same problem and was going crazy, you saved me a lot of time thanks again!
Title: Re: [FIXED] os-nut plugin permissions issue
Post by: kevinfason on January 26, 2023, 12:31:33 am
Ditto. I just did this on a 22.7.11 after moving hardware and restoring backup.