X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=debian%2Fspamass-milter.init;h=4855d4eec76efebbdaa4cee5541a802f05323523;hb=f1e8e76b711db827f304c1b2ad0defee10ed9417;hp=1d7337afa2273ae4953c9e15989e9ee27d6a2498;hpb=1f97efb358a73d5dd47aeb8f86a96a40d6c32538;p=deb_pkgs%2Fspamass-milter.git diff --git a/debian/spamass-milter.init b/debian/spamass-milter.init index 1d7337a..4855d4e 100644 --- a/debian/spamass-milter.init +++ b/debian/spamass-milter.init @@ -32,6 +32,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin +NAME=spamass-milter DAEMON=/usr/sbin/spamass-milter SOCKET=/var/run/spamass/spamass.sock PIDFILE=/var/run/spamass/spamass.pid @@ -41,17 +42,26 @@ DEFAULT=/etc/default/spamass-milter OPTIONS="" RUNAS="nobody" CHUID="" -SOCKETMODE="0660" -SOCKETOWNER="root:adm" +SOCKETMODE="0640" +SOCKETOWNER="root:root" test -x $DAEMON || exit 0 +if [ -e /etc/mail/sendmail.cf ] && egrep -q 'X.+S=local:/var/run/sendmail/spamass\.sock' /etc/mail/sendmail.cf; then + SOCKET=/var/run/sendmail/spamass.sock + SOCKETMODE="" + SOCKETOWNER="" + RUNAS="" + echo "WARNING: You are using the old location of spamass.sock. Change your input filter to use"; + echo "/var/run/spamass/spamass.sock so spamass-milter can run as nobody"; +fi; + # If /usr/sbin/postfix exists, set up the defaults for a postfix install # These can be overridden in /etc/default/spamass-milter if [ -x /usr/sbin/postfix ]; then SOCKET="/var/spool/postfix/spamass/spamass.sock" - PIDFILE="/var/spool/postfix/spamass/spamass.pid" SOCKETOWNER="postfix:postfix" + SOCKETMODE="0660" fi; if [ -r $DEFAULT ]; then @@ -65,23 +75,23 @@ fi; set -e start() { + # Because the default socket is in the same location as the + # pidfile, we create them in this order. + if [ ! -d $(dirname $PIDFILE) ]; then + mkdir -p $(dirname $PIDFILE); + if [ -d $(dirname $PIDFILE) ] && [ -n "$RUNAS" ]; then + chown "$RUNAS" $(dirname $PIDFILE); + fi; + fi; if [ ! -d $(dirname $SOCKET) ]; then mkdir -p $(dirname $SOCKET); if [ -n "$SOCKETOWNER" ]; then chown "$SOCKETOWNER" $(dirname $SOCKET); fi; fi; - if [ ! -d $(dirname $PIDFILE) ]; then - mkdir -p $(dirname $PIDFILE); - if [ -n "$RUNAS" ]; then - chown "$RUNAS" $(dirname $PIDFILE); - fi; - fi; - # Drop in a compatibility symlink for the old sendmail socket location - if [ -d /var/run/sendmail ] && [ -n "$RUNAS" ] && - [ "$SOCKET" == "/var/run/spamass/spamass.sock" ] && - ! [ -e /var/run/sendmail/spamass.sock ]; then - ln -s $SOCKET /var/run/sendmail/spamass.sock; + if [ -n "$RUNAS" ] && [ -d $(dirname $PIDFILE) ] && [ "$(stat -c '%U' $(dirname $PIDFILE))" != "$RUNAS" ]; then + echo "WARNING: $NAME will run as user $RUNAS but $(dirname $PIDFILE) is not owned by $RUNAS"; + echo "Either delete this directory or chown it appropriately. Startup attempts may fail."; fi; /bin/rm -f $SOCKET start-stop-daemon --start -p $PIDFILE $CHUID --exec $DAEMON -- -P $PIDFILE -f -p $SOCKET $OPTIONS @@ -90,7 +100,7 @@ start() { chmod $SOCKETMODE $SOCKET; fi; if [ -n "$SOCKETOWNER" ]; then - chown $SOCKETOWNER $SOCKET: + chown $SOCKETOWNER $SOCKET; fi; } @@ -104,19 +114,19 @@ case "$1" in start) echo -n "Starting $DESC: " start - echo "${DAEMON}" + echo "${NAME}" ;; stop) echo -n "Stopping $DESC: " stop - echo "${DAEMON}" + echo "${NAME}" ;; force-reload | restart) echo -n "Restarting $DESC: " stop start - echo "${DAEMON}" + echo "${NAME}" ;; *)