Here's a patch that will cause spamc to return the failure code when -x is
specified, regardless of the -e flag:

--- spamassassin-3.1.7/spamc/spamc.c    2006-09-29 06:06:44.000000000 -0700
+++ spamassassin-3.1.7-new/spamc/spamc.c        2007-01-11 18:59:32.594271748 
-0800
@@ -819,6 +819,9 @@
     }
     free(username);

+    if (ret != EX_OK && (flags & SPAMC_SAFE_FALLBACK) == 0)
+           goto finish;
+
 /* FAIL: */
     get_output_fd(&out_fd);


Now, one COULD just use a line like this in master.cf:

spamassassin unix -     n       n       -       -       pipe
  flags=q user=nobody argv=/usr/local/bin/spamc -x -u $(recipient) -e 
/usr/sbin/sendmail -oi -f $(sender) $(recipient)

HOWEVER, this will cause mail to bounce if your spamd is unavailable.  This is
because spamc can return any one of several error codes.  Postfix will only 
queue 
mail if the return code is specifically EX_TEMPFAIL.  I prefer all mail to queue
up if spamd is down for some reason.  So, I wrote a script that does that:

/usr/local/bin/spam_filter:

#!/bin/bash

RECIPIENT=$1
SENDER=$2

EX_OK=0
EX_TEMPFAIL=75

if /usr/local/bin/spamc -x -u "$RECIPIENT" -e /usr/sbin/sendmail -oi -f 
"$SENDER" "$RECIPIENT"; then
  exit $EX_OK;
else
  exit $EX_TEMPFAIL;
fi


Then I use a line like this in master.cf:

spamassassin unix -     n       n       -       -       pipe
  flags=q user=nobody argv=/usr/local/bin/spam_filter $(recipient) $(sender)


Hope this helps!
-- Kevin


Reply via email to