NUT (UPS) daemon is unable to start after upgrade

Started by RedVortex, January 26, 2023, 11:51:42 PM

Previous topic - Next topic
/usr/local/etc/rc.d/nut: WARNING: failed precmd routine for nut


I'm trying to figure out what is happening. I removed/reinstalled the plugin without luck so far. I'll keep you posted.

Same boat here, worked fine in 22.x series.


root@firewall:/var/db # /usr/local/etc/rc.d/nut restart
nut not running? (check /var/db/nut/upsd.pid).
Network UPS Tools - UPS driver controller 2.8.0
Network UPS Tools - Generic HID driver 0.47 (2.8.0)
USB communication driver (libusb 1.0) 0.43
Can't chdir to /var/db/nut: Permission denied
Driver failed to start (exit status=1)
/usr/local/etc/rc.d/nut: WARNING: failed precmd routine for nut
root@firewall:/var/db #



root@firewall:/var/db # ls -la nut/
total 12
drwxr-x---   2 uucp  uucp    512 Jan 26 17:53 .
drwxr-xr-x  24 root  wheel  1024 Jan 26 17:52 ..
-rw-r--r--   1 root  uucp      6 Jan 26 17:53 upsmon.pid
root@firewall:/var/db #


Also did a remove/install with no luck

Yep, exact same issue as you. I'll try to play with the permissions and see what's up.

I'll also try to remove the plugin again and this time get rid of everything as well (configs, folders, etc...)

I've also done the uninstall/install and try again.  Same error as everyone else is posting.  I also went through before the reinstall and deleted everything related to nut that was left over and still getting the same error.

I removed os-nut and then I remove /var/db/nut and reinstalled os-nut.

The permissions where 740 and nut.nut after reinstall on /var/db/nut

After I tried to start nut, the permissions on the /var/db/nut were now uucp:uucp and 740

Upsmon is able to run but not ups daemon since /usr/local/sbin/upsdrvctl is unable to start with uucp:uucp on /var/db/nut

Changing to nut:nut (like right after the plugin installation is done) makes /usr/local/sbin/upsdrvctl work

Trying to see how to workaround this for now but it sound like a bug...

The right fix is likely that the owner:group of /var/db/nut remains nut:nut so that everything works. Unsure why this becomes uucp:uucp at some point.

Changing the permissions to 777 on /var/db/nut makes things work (DP is the UPS name)

root@*******:/var/log # ls -al /var/db/nut/
total 20
drwxrwxrwx   2 uucp  uucp    512 Jan 26 18:41 .
drwxr-xr-x  21 root  wheel  1536 Jan 26 18:37 ..
-rw-r--r--   1 nut   uucp      6 Jan 26 18:41 upsd.pid
-rw-r--r--   1 root  uucp      6 Jan 26 18:38 upsmon.pid
srw-rw----   1 nut   uucp      0 Jan 26 18:41 usbhid-ups-DP
-rw-r--r--   1 nut   uucp      6 Jan 26 18:41 usbhid-ups-DP.pid


This is definitely not a good fix in any way, it is very bad and insecure but it gets me going for now until the right solution is found or this is fixed.

January 27, 2023, 12:55:41 AM #6 Last Edit: January 27, 2023, 01:42:27 AM by RedVortex
I think this needs to become nut:nut instead of uucp:uucp

/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh

root@********:/usr/local/opnsense # more scripts/OPNsense/Nut/setup.sh
#!/bin/sh
mkdir -p /var/db/nut

chown uucp:uucp /var/db/nut

Quote from: RedVortex on January 27, 2023, 12:44:51 AM
The right fix is likely that the owner:group of /var/db/nut remains nut:nut so that everything works. Unsure why this becomes uucp:uucp at some point.

Changing the permissions to 777 on /var/db/nut makes things work (DP is the UPS name)

root@*******:/var/log # ls -al /var/db/nut/
total 20
drwxrwxrwx   2 uucp  uucp    512 Jan 26 18:41 .
drwxr-xr-x  21 root  wheel  1536 Jan 26 18:37 ..
-rw-r--r--   1 nut   uucp      6 Jan 26 18:41 upsd.pid
-rw-r--r--   1 root  uucp      6 Jan 26 18:38 upsmon.pid
srw-rw----   1 nut   uucp      0 Jan 26 18:41 usbhid-ups-DP
-rw-r--r--   1 nut   uucp      6 Jan 26 18:41 usbhid-ups-DP.pid


This is definitely not a good fix in any way, it is very bad and insecure but it gets me going for now until the right solution is found or this is fixed.

Changing to 777 allowed for it to start. Least that is a work around for now.

January 27, 2023, 01:26:50 AM #8 Last Edit: January 27, 2023, 01:42:41 AM by RedVortex
I brought the permissions back to 750 and modified the /usr/local/opnsense/scripts/OPNsense/Nut/setup.sh file instead to have nut:nut, I prefer it this way, more secure and it works.

Now, I think we need to open a bug to update this file with nut:nut instead of uucp:uucp.

Sorry I corrected my above 2 posts to reflect the right file I'm talking about

/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh


January 27, 2023, 02:35:21 AM #10 Last Edit: January 27, 2023, 04:36:17 AM by RedVortex
To be more precise, I'm talking about adapting this

https://github.com/opnsense/plugins/blob/master/sysutils/nut/src/opnsense/scripts/OPNsense/Nut/setup.sh

so that it fixes our current issue. Likely by changing this script so that the permissions and/or owner/groups fit what nut and upsdrvctl need it to be to work properly. In my situation, it means nut:nut instead of uucp:uucp. I'm just not sure why this changed for 23.x and was working properly in 22.x and if nut:nut is the right fix or permissions.

The port owner changed permissions, not a fault by opnsense,  I will fix it