Just letting you know that this virtual patch of mine is now in use
on madduck.net for 13 months, on ifi.uzh.ch for about 5-6 months (we
are tracking backports, so it works with 3.2.5), and i've heard of
several other people who put it to use and are happy with it. So
far, there has not been a single problem.

It's not the ideal solution, but until spamd learns to handle
virtuals better, it's as good as it gets.

Please integrate it. I've attached the same patch for 3.2.5 to make
it easier. The old patch also applies cleanly.

-- 
 .''`.   martin f. krafft <[EMAIL PROTECTED]>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems
From 4ce7c1f787e345cbd8f44555f017900e7842b003 Mon Sep 17 00:00:00 2001
From: martin f. krafft <[EMAIL PROTECTED]>
Date: Sat, 13 Sep 2008 12:07:01 +0100
Subject: [PATCH] Import patch for #387878

Signed-off-by: martin f. krafft <[EMAIL PROTECTED]>
---
 debian/changelog                  |    8 +++++
 debian/spamassassin.README.Debian |    7 +++++
 debian/spamassassin.default       |   53 ++++++++++++++++++++++++++++++++++++-
 debian/spamassassin.init          |   49 ++++++++++++++++++++++++++++++++++
 4 files changed, 116 insertions(+), 1 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index cf7eeb7..79e5057 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+spamassassin (3.2.5-1.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Added infrastructure to spawn a second spamd instance for virtual
+    configurations (closes: #387878).
+
+ -- martin f. krafft <[EMAIL PROTECTED]>  Sat, 13 Sep 2008 12:05:51 +0100
+
 spamassassin (3.2.5-1) unstable; urgency=low
 
   * New upstream version.  (Closes: 482010, 475526)
diff --git a/debian/spamassassin.README.Debian b/debian/spamassassin.README.Debian
index 17c9475..8872291 100644
--- a/debian/spamassassin.README.Debian
+++ b/debian/spamassassin.README.Debian
@@ -139,4 +139,11 @@ programs Razor, DCC and Pyzor, but Razor and DCC are disabled by
 default since they are not free for non-personal use. Feel free to
 enable them in /etc/spamassassin/init.pre
 
+Virtual mail setups
+-------------------
+
+Debian's spamassassin can now support virtual and non-virtual mail setups out
+of the box by spawning two separate spamd instances. You can enable and
+configure the second instance in /etc/default/spamassassin.
+
  -- Duncan Findlay <[EMAIL PROTECTED]>, Mon, 21 May 2007 23:53:57 -0400
diff --git a/debian/spamassassin.default b/debian/spamassassin.default
index 09fd095..a2d791f 100644
--- a/debian/spamassassin.default
+++ b/debian/spamassassin.default
@@ -1,5 +1,5 @@
 # /etc/default/spamassassin
-# Duncan Findlay
+# Duncan Findlay and martin f. krafft
 
 # WARNING: please read README.spamd before using.
 # There may be security risks.
@@ -29,3 +29,54 @@ PIDFILE="/var/run/spamd.pid"
 # Set to anything but 0 to enable the cron job to automatically update
 # spamassassin's rules on a nightly basis
 CRON=0
+
+
+
+### VIRTUAL CONFIGURATION
+# Debian's spamassassin package can spawn a second spamd instance and thus
+# handle virtual and non-virtual mail configurations out of the box.
+#
+# To enable the virtual instance, set VINSTANCE to 1 and configure at least
+# VUSER and VCONFIGDIR below.
+#VINSTANCE=1
+
+# Port
+# The virtual instance must listen on a different port than the main instance.
+# The default is 784.
+#VPORT=784
+
+# User
+# The virtual instance must be run by a non-root user. Ideally, this will be
+# the same user as responsible for delivering mail to your virtual mail
+# directory hierarchy. There is no default.
+#VUSER=vmail
+
+# Directory layout
+# How is your virtual directory hierarchy organised? Where can spamd find
+# per-vuser configuration. Specify the complete path to the directory to hold
+# the user_prefs and bayes_* files for each vuser. You can use the following
+# escapes:
+#   %u -- replaced with the full name of the current user, as sent by spamc.
+#   %l -- replaced with the ’local part’ of the current username.  In other
+#         words, if the username is an email address, this is the part before
+#         the "@" sign.
+#   %d -- replaced with the ’domain’ of the current username.  In other words,
+#         if the user‐ name is an email address, this is the part after the
+#         "@" sign.
+#   %% -- replaced with a single percent sign (%).
+# There is no default.
+#VCONFIGDIR=/srv/vmail/%d/%l/.spamassassin
+
+# spamd options
+# Specify the options to pass to the virtual spamd instance. Note that these
+# are separate from the OPTIONS further up. However, the same notes apply, so
+# make sure not to increase --max-children without knowing what you're doing.
+# I suggest not to use --helper-home-dir
+VOPTIONS="--create-prefs --max-children 5"
+
+# Set nice level of virtual spamd
+#NICE="--nicelevel 15"
+#
+# Pid file
+# the location of the file to hold the virtual instance's PID
+#VPIDFILE=/var/run/spamd-virtual.pid
diff --git a/debian/spamassassin.init b/debian/spamassassin.init
index f90ea16..964eeb2 100644
--- a/debian/spamassassin.init
+++ b/debian/spamassassin.init
@@ -12,6 +12,7 @@
 # Spamd init script
 # June 2002
 # Duncan Findlay
+# Virtual configuration by martin f. krafft
 
 # Based on skeleton by Miquel van Smoorenburg and Ian Murdock
 
@@ -31,10 +32,24 @@ ENABLED=0
 OPTIONS=""
 NICE=
 
+VNAME=$NAME-virtual
+VDESC="$DESC (virtual instance)"
+VINSTANCE=0
+VPORT=784
+VUSER=""
+VCONFIGDIR=""
+VOPTIONS=""
+VPIDFILE=/var/run/$VNAME.pid
+VNICE=
+
 test -f /etc/default/spamassassin && . /etc/default/spamassassin
 
 DOPTIONS="-d --pidfile=$PIDFILE"
 
+VOPTIONS="$VOPTIONS --virtual-config-dir=$VCONFIGDIR --nouser-config"
+VOPTIONS="$VOPTIONS --username $VUSER --port $VPORT"
+VDOPTIONS="-d --pidfile=$VPIDFILE"
+
 if [ "$ENABLED" = "0" ]; then
     echo "$DESC: disabled, see /etc/default/spamassassin"
     exit 0
@@ -42,6 +57,16 @@ fi
 
 test -f $DAEMON || exit 0
 
+if [ "$VINSTANCE" = "1" ]; then
+  if [ -z "$VCONFIGDIR" ]; then
+    echo "$VDESC: no virtual-config-dir specified, disabling..."
+    VINSTANCE=0
+  elif [ -z "$VUSER" ]; then
+    echo "$VDESC: no virtual user specified, disabling..."
+    VINSTANCE=0
+  fi
+fi
+
 set -e
 
 case "$1" in
@@ -50,18 +75,34 @@ case "$1" in
 	start-stop-daemon --start --pidfile $PIDFILE --exec $XNAME \
 	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS
 	echo "$NAME."
+	if [ "$VINSTANCE" = 1 ]; then
+	  echo -n "Starting $VDESC: "
+	  start-stop-daemon --start --pidfile $VPIDFILE --exec $XNAME \
+	      $VNICE --oknodo --startas $DAEMON -- $VOPTIONS $VDOPTIONS
+	  echo "$VNAME."
+	fi
 	;;
 
   stop)
 	echo -n "Stopping $DESC: "
 	start-stop-daemon --stop --pidfile $PIDFILE --exec $XNAME --oknodo
 	echo "$NAME."
+	if [ "$VINSTANCE" = 1 ]; then
+	  echo -n "Stopping $VDESC: "
+	  start-stop-daemon --stop --pidfile $VPIDFILE --exec $XNAME --oknodo
+	  echo "$VNAME."
+	fi
 	;;
 
   reload|force-reload)
 	echo -n "Reloading $DESC: "
 	start-stop-daemon --stop --pidfile $PIDFILE --signal HUP --exec $XNAME
 	echo "$NAME."
+	if [ "$VINSTANCE" = 1 ]; then
+	  echo -n "Reloading $VDESC: "
+	  start-stop-daemon --stop --pidfile $VPIDFILE --signal HUP --exec $XNAME
+	  echo "$VNAME."
+	fi
 	;;
 
   restart)
@@ -72,6 +113,14 @@ case "$1" in
 	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS
 
 	echo "$NAME."
+	if [ "$VINSTANCE" = 1 ]; then
+	  echo -n "Restarting $VDESC: "
+	  start-stop-daemon --stop --pidfile $VPIDFILE --exec $XNAME \
+	    --retry 5 --oknodo
+	  start-stop-daemon --start --pidfile $VPIDFILE --exec $XNAME \
+	      $VNICE --oknodo --startas $DAEMON -- $VOPTIONS $VDOPTIONS
+	  echo "$VNAME."
+	fi
 	;;
 
   *)
-- 
1.6.0.1

Attachment: digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)

Reply via email to