Package: spamassassin
Severity: wishlist
Tags: patch

 Hello,

   here is a patch with my proposed improvements
 to the spamassassin package.

   1) /etc/spamassassin/default has some more commented options
   to allow:

        - the selection of the log mode (syslog/file) and
        facility.

        - helper home directory

   2) postinst creates the spamd user and sets the proper
   permissions on /var/log/spamassassing, /var/run/spamassassin
   and /var/lib/spamassassin, in order to handle a non-root spamd.
diff -urN spamassassin-3.0.1/debian/rules spamassassin-3.0.1-my/debian/rules
--- spamassassin-3.0.1/debian/rules     2004-12-12 03:59:09.000000000 +0100
+++ spamassassin-3.0.1-my/debian/rules  2004-12-12 03:20:42.000000000 +0100
@@ -112,6 +112,7 @@
        dh_testroot
        dh_clean -k
        dh_installdirs -i
+       dh_installlogrotate
 
        $(MAKE) install
 
diff -urN spamassassin-3.0.1/debian/spamassassin.default 
spamassassin-3.0.1-my/debian/spamassassin.default
--- spamassassin-3.0.1/debian/spamassassin.default      2004-12-12 
03:59:09.000000000 +0100
+++ spamassassin-3.0.1-my/debian/spamassassin.default   2004-12-12 
03:56:46.000000000 +0100
@@ -14,13 +14,35 @@
 # need to make sure --max-children is not set to anything higher than
 # 5, unless you know what you're doing.
 
-OPTIONS="--create-prefs --max-children 5 --helper-home-dir"
+OPTIONS="--create-prefs --max-children 5"
 
 # Pid file
 # Where should spamd write its PID to file? If you use the -u or
 # --username option above, this needs to be writable by that user.
 # Otherwise, the init script will not be able to shut spamd down.
-PIDFILE="/var/run/spamd.pid"
+PIDFILE="/var/run/spamassassin/spamd.pid"
+
+# Log facility
+# Where should spamd write about its operations? You can
+# use a standard syslog facility or a file. If you do not
+# specify an option here, spamd will log to the syslog
+# with the "mail" facility. Use "null" to disable logging.
+# Any log file needs to be writable by the user running spamd.
+#LOGFACILITY="mail"
+#LOGFACILITY="null"
+#LOGFACILITY="/var/log/spamassassin/spamd.log"
+
+# Helper home directory
+# Specify where helper programs (razor, pyzor, ...) will
+# place their configuration and/or support files.
+# You can either set this variable to a directory
+# or set it to an empty value in order to tell spamd
+# to use the home directory of the spamc user.
+# If you do not set this variable, the HOME environment
+# variable setting from the shell running spamd will
+# be used.
+HELPER_HOME_DIR=""
+#HELPER_HOME_DIR="/var/lib/spamassassin"
 
 # Set nice level of spamd
 #NICE="--nicelevel 15"
diff -urN spamassassin-3.0.1/debian/spamassassin.dirs 
spamassassin-3.0.1-my/debian/spamassassin.dirs
--- spamassassin-3.0.1/debian/spamassassin.dirs 2004-12-12 03:59:09.000000000 
+0100
+++ spamassassin-3.0.1-my/debian/spamassassin.dirs      2004-12-12 
04:00:46.000000000 +0100
@@ -8,3 +8,7 @@
 etc/logcheck/violations.ignore.d
 usr/share/man/man8
 usr/sbin
+var/log/spamassassin
+var/lib/spamassassin
+var/run/spamassassin
+etc/logrotate.d
diff -urN spamassassin-3.0.1/debian/spamassassin.init 
spamassassin-3.0.1-my/debian/spamassassin.init
--- spamassassin-3.0.1/debian/spamassassin.init 2004-12-12 03:59:09.000000000 
+0100
+++ spamassassin-3.0.1-my/debian/spamassassin.init      2004-12-12 
04:03:13.000000000 +0100
@@ -11,7 +11,7 @@
 NAME=spamd
 SNAME=spamassassin
 DESC="SpamAssassin Mail Filter Daemon"
-PIDFILE="/var/run/$NAME.pid"
+PIDFILE="/var/run/spamassassin/$NAME.pid"
 PNAME="spamd"
 
 export TMPDIR=/tmp
@@ -21,10 +21,15 @@
 ENABLED=0
 OPTIONS=""
 NICE=
+LOGFACILITY="mail"
+HELPER_HOME_DIR=$HOME
 
 test -f /etc/default/spamassassin && . /etc/default/spamassassin
 
-DOPTIONS="-d --pidfile=$PIDFILE"
+# There's no "=" between --helper-home-dir and $HELPER_HOME_DIR. This allows to
+# have an empty $HELPER_HOME_DIR.
+
+DOPTIONS="-d --pidfile=$PIDFILE --syslog=$LOGFACILITY --helper-home-dir 
$HELPER_HOME_DIR"
 
 if [ "$ENABLED" = "0" ]; then
     echo "$DESC: disabled, see /etc/default/spamassassin"
diff -urN spamassassin-3.0.1/debian/spamassassin.logrotate 
spamassassin-3.0.1-my/debian/spamassassin.logrotate
--- spamassassin-3.0.1/debian/spamassassin.logrotate    1970-01-01 
01:00:00.000000000 +0100
+++ spamassassin-3.0.1-my/debian/spamassassin.logrotate 2004-12-12 
03:18:57.000000000 +0100
@@ -0,0 +1,7 @@
+
+"/var/log/spamassassin/*.log" {
+       weekly
+       rotate 4
+       compress
+       missingok
+}
diff -urN spamassassin-3.0.1/debian/spamassassin.postinst 
spamassassin-3.0.1-my/debian/spamassassin.postinst
--- spamassassin-3.0.1/debian/spamassassin.postinst     2004-12-12 
03:59:09.000000000 +0100
+++ spamassassin-3.0.1-my/debian/spamassassin.postinst  2004-12-12 
03:07:52.000000000 +0100
@@ -20,4 +20,42 @@
 
 db_stop
 
+
+case "$1" in
+       configure)
+
+               # Add spamd user and group.
+       
+               if ! getent group spamd >/dev/null ; then
+                       echo 'Adding system group: spamd.'
+                       addgroup --system spamd
+               fi
+               
+               if ! getent passwd spamd >/dev/null ; then
+                       echo 'Adding system user: spamd.'
+                       adduser --system --ingroup spamd --no-create-home \
+                               --home /var/lib/spamassassin \
+                               --disabled-password spamd
+               fi
+
+               # Update permissions
+
+               chown -R spamd:adm      /var/log/spamassassin
+               chown spamd:spamd       /var/lib/spamassassin
+               chown spamd:adm         /var/run/spamassassin
+               chmod 0775              /var/run/spamassassin
+
+       ;;
+       
+       abort-upgrade|abort-remove|abort-deconfigure)
+       
+       ;;
+       
+       *)
+               echo "postinst called with unknown argument \$1'" >&2
+               exit 1
+       ;;
+
+esac
+
 #DEBHELPER#
diff -urN spamassassin-3.0.1/debian/spamassassin.postrm 
spamassassin-3.0.1-my/debian/spamassassin.postrm
--- spamassassin-3.0.1/debian/spamassassin.postrm       1970-01-01 
01:00:00.000000000 +0100
+++ spamassassin-3.0.1-my/debian/spamassassin.postrm    2004-12-12 
02:48:04.000000000 +0100
@@ -0,0 +1,57 @@
+#! /bin/sh
+# postrm script for spamassassin
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+       purge)
+               if [ -d /var/log/spamassassin ]; then
+                       rm -rf /var/log/spamassassin
+               fi
+
+               if [ -d /var/lib/spamassassin ]; then
+                       rm -rf /var/lib/spamassassin
+               fi
+
+               if getent passwd spamd >/dev/null ; then
+                       deluser spamd
+               fi
+
+               if getent group spamd >/dev/null ; then
+                       delgroup spamd
+               fi      
+
+       ;;
+        
+       remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+
+
+        ;;
+
+       *)
+               echo "postrm called with unknown argument \`$1'" >&2
+               exit 1
+
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0

Reply via email to