Hi,
I'm on NetBSD-8.1 amd64, using an updated pkgsrc stable, but the issue
arises with pkgsrc current as well.
The issue
Stopping the postgrey daemon ( service postgrey stop ) results in the
following error message in /var/log/maillog :
Couldn't unlink "/var/run/postgrey.pid" [Permission denied]
My diagnosis
The user/group postgrey doesn't have write permissions in /var/run .
My proposal
Create a directory postgrey in /var/run with the right permissions for
the user/group postgrey and place postgrey.pid in this directory.
My proposed patch (tested; see below) modifies the rc.d file for
postgrey to create a directory postgrey in /var/run with the right
permissions for the user/group postgrey. This solves the original issue:
stopping the daemon postgrey now no longer results in an error message.
This solution is inspired by the rc.d file for mail/opendkim, which does
the same thing for opendkim. It's also inspired by a solution to the
same bug in Debian in 2012: see
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630353#msg15 .
Thank you,
C.
This is my proposed patch for the file mail/postgrey/files/postgrey.sh :
--- postgrey.sh 2011-02-16 19:37:50.000000000 +0000
+++ postgrey.sh.modified 2019-09-07 14:13:27.724033338 +0000
@@ -11,7 +11,7 @@
name="@PKGBASE@"
rcvar=$name
-pidfile="@VARBASE@/run/${name}.pid"
+pidfile="@VARBASE@/run/postgrey/${name}.pid"
command_interpreter="@PERL@"
command="@PREFIX@/sbin/postgrey"
command_args="-d --pidfile=${pidfile}"
@@ -21,6 +21,17 @@
"
@PKGBASE@_flags=${@PKGBASE@_flags-"-i 2525"}
extra_commands="reload"
+start_precmd="postgrey_precmd"
+
+postgrey_precmd()
+{
+ if [ ! -d @VARBASE@/run/postgrey ]; then
+ @MKDIR@ @VARBASE@/run/postgrey
+ @CHMOD@ 0750 @VARBASE@/run/postgrey
+ @CHOWN@ @POSTGREY_USER@:@POSTGREY_GROUP@ @VARBASE@/run/postgrey
+ fi
+}
+
stop_postcmd='rm -f $pidfile'
load_rc_config $name