[Nut-upsdev] pidpath, altpidpath, statepath considered muddled or confusing

Greg Troxel gdt at lexort.com
Sun May 18 12:57:10 BST 2025


I'm following up on a request from a pkgsrc user to improve the package,
and that's leading me to thinking part of the issues are in nut, vs the
package.

Setting aside daemons that run as root vs not, there are two kinds of
directories, using the BSD hier(7) scheme:

   /var/db/nut:
     - state files intended to persist across reboots

   /var/run/nut:
     - pidfiles
     - (probably) sockets

1) configure args slightly confusing autoconf vs nut

nut has configure args in two groups; one setting the usual autoconf
variables not really about nut, and the second group setting state, pid,
altpid:

  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]


  --with-statepath=PATH   path for ups state files (${STATEPATH}, typically
                          /var/state/ups)
  --with-altpidpath=PATH  path for NUT driver/upsd .pid files not running as
                          root (<statepath>)
  --with-pidpath=PATH     Path for root-owned .pid files (${PIDPATH},
                          typically /var/run)


2) There are some issues; the defaults are hardcoded paths instead of
following localstatedir and runstatedir

  STATEPATH="/var/state/ups"
  PIDPATH="/var/run"

but this is minor as packaging will just set them.


3) multiple pid paths confusing and unnecessary

Within BSD/pkgsrc, the rough norm is that each daemon should run
unprivileged as its own uid/gid, perhaps starting as root and dropping
when necessary, and that therefore a subdirectory of /var/run is needed
for pidfiles, so this would be /var/run/nut.  This then needs to be
created at startup, as /var/run might not have it, or would generally be
cleared.

Once there is /var/run/nut, then there's no reason to have pidpath and
altpidpath separated.  I don't see why a single dir that's nutuid:nutgid
can't be used for both.

4) statedir unclear

Grepping for statedir via

  find . -name \*.[ch] | xargs egrep -R STATEPATH

I don't end up understanding what if anything is or should be put there.

On my own system, there's a socket for the bestfortress driver, and
pidfiles for bestfortress, upsd, and upsmon.  All of those belong in
/var/run/nut, not /var/db/nut, as they are per-system-boot and not used
across reboots or even nut start/stop.


So: am I off here, or is this something to be cleaned up, or ?



More information about the Nut-upsdev mailing list