<div dir="ltr"><div>FWIW, just checked: `git grep nut-client` does not return anything related to systemd, so that typo gotta be Fedora's invention ;)</div><div><br></div><div>In-source there is only nut-common.tmpfiles handling.</div><div><br></div><div>Jim<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 30, 2022 at 8:20 AM Simon Wilson via Nut-upsuser <<a href="mailto:nut-upsuser@alioth-lists.debian.net">nut-upsuser@alioth-lists.debian.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">----- Message from Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank">bgee@campercaver.net</a>> ---------<br>
    Date: Tue, 29 Nov 2022 19:25:19 -0600<br>
    From: Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank">bgee@campercaver.net</a>><br>
Subject: Re: [Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade<br>
      To: Jim Klimov <<a href="mailto:jimklimov%2Bnut@gmail.com" target="_blank">jimklimov+nut@gmail.com</a>><br>
      Cc: Arnaud Quette via Nut-upsuser <<a href="mailto:nut-upsuser@alioth-lists.debian.net" target="_blank">nut-upsuser@alioth-lists.debian.net</a>><br>
<br>
<br>
> I got it to run, but what a mess ...<br>
><br>
> Yes, I am running systemctl daemon-reload and systemctl restart  <br>
> nut-server after each change I make.<br>
><br>
<br>
Hi Bill,<br>
<br>
Drivers and upsd share defaults (see 'man nutupsdrv').<br>
<br>
Your original error message ("writepid: fopen  <br>
/var/run/usbhid-ups-cyberpower.pid: Permission denied") would seem to  <br>
indicate, same as the Red Hat bug, that your driver's default pid path  <br>
is /var/run.<br>
<br>
The driver by default uses STATEPATH (which can be over-ridden in  <br>
upsd.conf) to store pid files. The driver .service file is supposed to  <br>
make sure that path exists by running the ExecStartPre line, which  <br>
gets its instructions from the referenced ".conf" file from  <br>
/usr/lib/tmpfiles.d. The .service file then calls 'upsdrvctl start' to  <br>
start your usbhid-ups driver, as defined in ups.conf. Those all need  <br>
to align...<br>
<br>
2 x questions:<br>
<br>
1. Without its comments, what are the active lines (as installed,  <br>
without any changes) in /usr/lib/systemd/system/nut-driver@.service  <br>
(or wherever that service file is located on your system)?<br>
2. in your upsd.conf (also as installed, without any changes), what is  <br>
the commented out STATEPATH you later mention uncommenting?<br>
<br>
> I created /usr/lib/tmpfiles.d/nut-client.conf   The owner is  <br>
> root:root and permissions are 0644.  The contents are<br>
><br>
> # State file (e.g. upsd to driver) and pidfile location for NUT:<br>
> D /var/run/nut 0770 root nut - -<br>
> X /var/run/nut<br>
><br>
> I uncommented the STATEPATH line in /etc/ups/upsd.conf.<br>
><br>
> I created a directory /var/state/ups, set to 777 permissions.   <br>
> Changed the STATEPATH line in upsd.conf.  No success.<br>
><br>
> I looked at /usr/lib/systemd/system/nut-driver@.service but could  <br>
> not see any changes to be made.  The bug report at RedHat mentions  <br>
> that a file identified in ExecStartPre does not exist, but I could  <br>
> not duplicate.<br>
><br>
> I tried running this as root:<br>
><br>
> NUT_STATEPATH=/var/state/ups NUT_ALTPIDPATH=/var/state/ups  <br>
> /usr/sbin/usbhid-ups -u nut -g nut -s cyberpower -x port=auto<br>
><br>
> And it works.  I tried it with only one or the other of the two  <br>
> environment variables, but did not work.  It has to have both.<br>
><br>
> ===============<br>
> Bill Gee<br>
><br>
><br>
> On 11/29/22 17:43, Jim Klimov wrote:<br>
>> As recently noted in the lists, this was tracked<br>
>> down to a Fedora 37 packaging bug:  <br>
>> <a href="https://bugzilla.redhat.com/show_bug.cgi" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/show_bug.cgi</a>  <br>
>> <<a href="https://bugzilla.redhat.com/show_bug.cgi" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/show_bug.cgi</a>>?id=2127269<br>
>><br>
>> > The nut user does not have write permissions at /run.<br>
>> Note that /run is linked as /var/run and the nut user DOES have write<br>
>> permissions there.<br>
>><br>
>> These two statements do not fit together :) Permissions on symlink  <br>
>> do not matter, only the ultimate object's rights do (root-owned  <br>
>> /run). The packaging error is that (/var)/run/nut should have been  <br>
>> used for drivers and upsd, or /var/state/ups as it should also  <br>
>> exist and be accessible to these. For a quick fix you can set  <br>
>> Environment=NUT_ALTPIDPATH=/var/state/ups for their systemd units  <br>
>> or respective custom drop-in files.<br>
>><br>
>> Jim<br>
>><br>
>> On Tue, Nov 29, 2022, 14:06 Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank">bgee@campercaver.net</a>  <br>
>> <mailto:<a href="mailto:bgee@campercaver.net" target="_blank">bgee@campercaver.net</a>>> wrote:<br>
>><br>
>>    Yesterday I upgraded one of my systems from Fedora 36 to Fedora  <br>
>> 37.     NUT<br>
>>    was upgraded to version 2.8.0.  It no longer runs.<br>
>><br>
>>    At first I thought it was because of the XFCE Power Manager program.<br>
>>    That program finds the UPS with no problem.  I thought maybe the two<br>
>>    programs were competing for the UPS port.  I shut down the XFCE power<br>
>>    manager, but that did not help NUT.<br>
>><br>
>>    Based on the diagnostics given below, I think this is a permissions<br>
>>    problem at /run.  The nut user does not have write permissions at /run.<br>
>>    Note that /run is linked as /var/run and the nut user DOES have write<br>
>>    permissions there.<br>
>><br>
>>    How can I correct this?<br>
>><br>
>>    =======================================<br>
>>    [root@mythtv ups]# systemctl status nut-server<br>
>>    nut-server.service - Network UPS Tools - power devices information<br>
>>    server<br>
>>           Loaded: loaded (/usr/lib/systemd/system/nut-server.service;<br>
>>    enabled; preset: disabled)<br>
>>           Active: active (running) since Tue 2022-11-29 06:18:13 CST;<br>
>>    19min ago<br>
>>         Main PID: 11908 (upsd)<br>
>>            Tasks: 1 (limit: 9482)<br>
>>           Memory: 736.0K<br>
>>              CPU: 27ms<br>
>>           CGroup: /system.slice/nut-server.service<br>
>>                   └─11908 /usr/sbin/upsd -F<br>
>><br>
>>    Nov 29 06:18:13 mythtv.billgee.local upsd[11908]: Can't connect to UPS<br>
>>    [cyberpower] (usbhid-ups-cyberpower): No such fi><br>
>>    Nov 29 06:18:13 mythtv.billgee.local nut-server[11908]: Can't<br>
>>    connect to<br>
>>    UPS [cyberpower] (usbhid-ups-cyberpower): No s><br>
>>    Nov 29 06:18:13 mythtv.billgee.local nut-server[11908]: Running as<br>
>>    foreground process, not saving a PID file<br>
>>    Nov 29 06:18:13 mythtv.billgee.local upsd[11908]: Running as foreground<br>
>>    process, not saving a PID file<br>
>>    Nov 29 06:23:13 mythtv.billgee.local nut-server[11908]: Can't<br>
>>    connect to<br>
>>    UPS [cyberpower] (usbhid-ups-cyberpower): No such file or directory><br>
>>    Nov 29 06:23:13 mythtv.billgee.local upsd[11908]: Can't connect to UPS<br>
>>    [cyberpower] (usbhid-ups-cyberpower): No such file or directory><br>
>><br>
>>    [root@mythtv ups]# usbhid-ups -a cyberpower<br>
>>    Network UPS Tools - Generic HID driver 0.47 (2.8.0)<br>
>>    USB communication driver (libusb 1.0) 0.43<br>
>>    writepid: fopen /var/run/usbhid-ups-cyberpower.pid: Permission denied<br>
>>    Using subdriver: CyberPower HID 0.6<br>
>>    cps_adjust_battery_scale: battery readings will be scaled by 2/3<br>
>><br>
>>    Fatal error: unable to create listener socket<br>
>><br>
>>    bind /var/run/usbhid-ups-cyberpower failed: Permission denied<br>
>><br>
>>    Exiting.<br>
>><br>
>>    [root@mythtv ups]# ll /var/run/usb*<br>
>>    ls: cannot access '/var/run/usb*': No such file or directory<br>
>><br>
>>    [root@mythtv ups]# ll -d /var/run<br>
>>    lrwxrwxrwx. 1 root root 6 Aug 31  2014 /var/run -> ../run<br>
>><br>
>>    [root@mythtv ups]# ll -d /run<br>
>>    drwxr-xr-x 55 root root 1500 Nov 28 08:22 /run<br>
>><br>
>>    [root@mythtv ups]# tail /etc/ups/ups.conf<br>
>>    [cyberpower]<br>
>>              driver=usbhid-ups<br>
>>              desc="CyberPower CP1500"<br>
>>              port=auto<br>
>>              vendorid=0764<br>
>>    ==================================================<br>
>><br>
>><br>
>>    Thanks!<br>
>>    --     ===============<br>
>>    Bill Gee<br>
>><br>
>>    _______________________________________________<br>
>>    Nut-upsuser mailing list<br>
>>    <a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank">Nut-upsuser@alioth-lists.debian.net</a><br>
>>    <mailto:<a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank">Nut-upsuser@alioth-lists.debian.net</a>><br>
>>    <a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
>>    <<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a>><br>
>><br>
><br>
> _______________________________________________<br>
> Nut-upsuser mailing list<br>
> <a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank">Nut-upsuser@alioth-lists.debian.net</a><br>
> <a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
<br>
<br>
----- End message from Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank">bgee@campercaver.net</a>> -----<br>
<br>
<br>
<br>
-- <br>
Simon Wilson<br>
M: 0400 12 11 16<br>
<br>
<br>
_______________________________________________<br>
Nut-upsuser mailing list<br>
<a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank">Nut-upsuser@alioth-lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
</blockquote></div>