In the /etc/conf.d/spamd file there is an obsolete comment, this is:
# Note: if you plan on using the -u flag to spamd you will need to
# make sure the location of the PID file is writable by that user.
# This can be done by making the directory /var/run/spamd and
# changing the owner to the UID that runs spamd. You will then
# need to edit $pidfile in /etc/init.d/spamd. This should fix the
# problem with stop/restart in the init scripts.
# See http://bugs.gentoo.org/show_bug.cgi?id=70124 for a full
I added a new user (spamd) and added the "-u spamd" option to SPAMD_OPTS,
without chaging the PIDFILE variable. Now spamd runs, stops/restarts,
without any issue. The pidfile, /run/spamd.id, is owned by root, and there
are three processes runing:
# pstree -u
While I have only tested with 3.4.0, I suspect this works since 3.1.0, when
spamassassin changed to preforking. See first item in the 3.1.0 announcement
This is the syslog output when restarting spamd:
# tail -f messages | grep spamd
Sep 28 19:02:30 postaria spamd: spamd: server killed by SIGTERM, shutting down
Sep 28 19:02:30 postaria spamd: logger: removing stderr method
Sep 28 19:02:31 postaria spamd: spamd: server started on IO::Socket::INET6 [127.0.0.1]:783, IO::Socket::INET6 [::1]:783 (running version 3.4.0)
Sep 28 19:02:31 postaria spamd: spamd: server pid: 24551
Sep 28 19:02:31 postaria spamd: spamd: server successfully spawned child process, pid 24552
Sep 28 19:02:31 postaria spamd: spamd: server successfully spawned child process, pid 24553
Sep 28 19:02:31 postaria spamd: prefork: child states: IS
Sep 28 19:02:31 postaria spamd: prefork: child states: II
The coment above confused me quite a little bit, I think it is worth
Created attachment 435928 [details, diff]
Master process works with root privilleges but childs use user set by "-u". Indeed, this comment is confusing.
This bug should wait for bug #455604
Done in a new revision:
I removed all mention of the PID file handling and permissions. It should just work out-of-the-box, no matter what you do. The PID is hard-coded to /run/spamd/spamd.pid, but you shouldn't need to mess with it.