Package: spamc Version: 3.3.1-1 Severity: wishlist Tags: patch I use spamc as a simple delivery filter with postfix like this in master.cf:
dovecot-sa unix - n n - - pipe flags=ODRhu user=vmail:mail argv=/usr/bin/spamc -x -X -u ${recipient} -e /usr/lib/dovecot/deliver -f ${sender} -a ${recipient} -d ${user}@${nexthop} I was unhappy with how postfix would bounce mails when spamd wasn't running and spamc was run with -x to prevent unfiltered mail to come trough. When spamc returns EX_TEMPFAIL instead of EX_UNAVAILABLE, postfix will queue the mail and try to deliver it later. Please be aware that I don't have much recent experience with C-code and none with the spamassassin code as such but the attached patch works well for me. I also requested to add something like this to the spamassassin upstream: https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6717 Regards Sebastian
Index: spamassassin-3.3.1/spamc/libspamc.h =================================================================== --- spamassassin-3.3.1.orig/spamc/libspamc.h 2011-12-06 22:25:23.000000000 +0100 +++ spamassassin-3.3.1/spamc/libspamc.h 2011-12-06 22:42:14.000000000 +0100 @@ -131,6 +131,11 @@ /* December 5, 2007 duncf: send log messages to callback */ #define SPAMC_LOG_TO_CALLBACK (1<<14) +/* December 6, 2011 Sebastian Wiesinger <sebast...@karotte.org>: + * Turn EX_UNAVAILABLE into EX_TEMPFAIL + * */ +#define SPAMC_UNAVAIL_TEMPFAIL (1<<13) + #define SPAMC_MESSAGE_CLASS_SPAM 1 #define SPAMC_MESSAGE_CLASS_HAM 2 Index: spamassassin-3.3.1/spamc/spamc.c =================================================================== --- spamassassin-3.3.1.orig/spamc/spamc.c 2011-12-06 22:25:23.000000000 +0100 +++ spamassassin-3.3.1/spamc/spamc.c 2011-12-06 22:46:34.000000000 +0100 @@ -197,6 +197,10 @@ usg(" -x, --no-safe-fallback\n" " Don't fallback safely.\n"); + usg(" -X, --unavailable-tempfail\n" + " When using -x, turn 'unavailabe' error into\n" + " 'tempfail'. Most MTAs will then defer mails\n" + " instead of bouncing them.\n"); usg(" -l, --log-to-stderr Log errors and warnings to stderr.\n"); #ifndef _WIN32 usg(" -e, --pipe-to command [args]\n" @@ -227,9 +231,9 @@ struct transport *ptrn) { #ifndef _WIN32 - const char *opts = "-BcrRd:e:fyp:n:t:s:u:L:C:xzSHU:ElhVKF:0:1:2"; + const char *opts = "-BcrRd:e:fyp:n:t:s:u:L:C:xXzSHU:ElhVKF:0:1:2"; #else - const char *opts = "-BcrRd:fyp:n:t:s:u:L:C:xzSHElhVKF:0:1:2"; + const char *opts = "-BcrRd:fyp:n:t:s:u:L:C:xXzSHElhVKF:0:1:2"; #endif int opt; int ret = EX_OK; @@ -260,6 +264,7 @@ { "headers", no_argument, 0, 2 }, { "exitcode", no_argument, 0, 'E' }, { "no-safe-fallback", no_argument, 0, 'x' }, + { "unavailable-tempfail", no_argument, 0, 'X' }, { "log-to-stderr", no_argument, 0, 'l' }, { "pipe-to", required_argument, 0, 'e' }, { "help", no_argument, 0, 'h' }, @@ -442,6 +447,11 @@ flags &= (~SPAMC_SAFE_FALLBACK); break; } + case 'X': + { + flags |= SPAMC_UNAVAIL_TEMPFAIL; + break; + } case 'y': { flags |= SPAMC_SYMBOLS; @@ -1025,6 +1035,9 @@ else if (use_exit_code) { ret = result; } + if ((flags & SPAMC_UNAVAIL_TEMPFAIL) && ret == EX_UNAVAILABLE) { + ret = EX_TEMPFAIL; + } } finish: Index: spamassassin-3.3.1/spamc/spamc.pod =================================================================== --- spamassassin-3.3.1.orig/spamc/spamc.pod 2011-12-06 22:25:23.000000000 +0100 +++ spamassassin-3.3.1/spamc/spamc.pod 2011-12-06 22:42:14.000000000 +0100 @@ -230,6 +230,12 @@ This also disables the TCP fail-over behaviour from B<-d>. +=item B<-X>, B<--unavailable-tempfail> + +When disabling 'safe fallback' with B<-x>, this option will turn EX_UNAVAILABLE +errors into EX_TEMPFAIL. Most (if not all) MTAs will then defer mails instead +of bouncing them. See also L<"EXIT CODES">. + =item B<-y>, B<--tests> Just output the names of the tests hit to stdout, on one line, separated