Moving pid files from /var/run/$name.pid to /var/run/$name/$name.pid

Tom Lane tgl at redhat.com
Fri Aug 24 14:02:50 UTC 2012


Hans de Goede <hdegoede at redhat.com> writes:
> Today I received a bug report to mv sensorsd's pid file from /var/run/sensorsd.pid to
> /var/run/sensorsd/sensorsd.pid, see:
> https://bugzilla.redhat.com/show_bug.cgi?id=851428

The traditional argument for not creating pidfiles directly in /var/run
is that a daemon that does that has to be started as root, else it won't
have permission to write /var/run.  A daemon that is intended to run
under some non-root UID works a lot better if you make a subdirectory
owned by that UID.  mysql, for instance, has always used
/var/run/mysqld/mysqld.pid.

I know nothing about the security level of sensorsd --- if it has to be
root-privileged anyway, this argument doesn't have any force for you.
But it's generally safer to avoid running daemons as root if that's
not absolutely necessary.

> Making the requested change means making changes to the daemon C-code,
> and if we then upstream these changes, they will cause issues for
> other distro's.  So I think that upstreaming the necessary changes is
> going to be a problem.

IMO, if a daemon makes any such assumption in a nonconfigurable way,
it's broken and upstream ought to be willing to take back a patch to
make it configurable.  /var/run is not a universal standard.  You
don't have to look any further than /var/run versus /run to realize
that some flexibility there is a good idea for any upstream that has
any portability pretensions whatsoever.

			regards, tom lane


More information about the devel mailing list