SA Bugzilla – Bug 6717
Add option -X to turn EX_UNAVAILABE into EX_TEMPFAIL
Last modified: 2013-06-04 00:06:03 UTC
Created attachment 5014 [details] Patch to add -X option Hello, 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 would appreciate it if something like this could be added to spamassassin.
I would appreciate an option like this. However, it should also work in all other cases that don't necessarily indicate a configuration error. For example, if the connection is supposed to be created via a unix socket, but spamd is not running hence the socket does not exist, spamc fails with EX_SOFTWARE (in my tests) which would not result in a EX_TEMPFAIL with this patch.
I'll see what I can do to test this. Your idea makes sense.
Hello, I just wanted to ask if there is anything new regarding this enhancement? Will something like this be added? Regards Sebastian
Created attachment 5129 [details] Revised Patch to add EX_TEMPFAIL for -X option for spamc The patch is trivial. I cleaned up the patch mostly for verbiage and to make it work with the current trunk. I also added more safety checks to ensure -x is required. Here's showing it work where with -X it gets EC 75 and without it gets EC 69: [root@devel spamc]# ./spamc -l -x -c -d 127.0.0.1 < /tmp/1.mbox ; echo $? spamc: connect to spamd on 127.0.0.1 failed, retrying (#1 of 3): Connection refused spamc: connect to spamd on 127.0.0.1 failed, retrying (#2 of 3): Connection refused spamc: connect to spamd on 127.0.0.1 failed, retrying (#3 of 3): Connection refused spamc: connection attempt to spamd aborted after 3 retries 0/0 69 [root@devel spamc]# ./spamc -l -x -X -c -d 127.0.0.1 < /tmp/1.mbox ; echo $? spamc: connect to spamd on 127.0.0.1 failed, retrying (#1 of 3): Connection refused spamc: connect to spamd on 127.0.0.1 failed, retrying (#2 of 3): Connection refused spamc: connect to spamd on 127.0.0.1 failed, retrying (#3 of 3): Connection refused spamc: connection attempt to spamd aborted after 3 retries 0/0 75 I'm currently running a make test on this prior to committing.
(In reply to comment #4) > I'm currently running a make test on this prior to committing. make test worked so I am committing this change and closing the ticket. Sebastian, if you can test it in your environment, that would be helpful. svn commit -m 'adding -X option to allow spamc to return EX_TEMPFAIL instead of EX_UNAVAILABLE when using -x option' Sending spamc/libspamc.h Sending spamc/spamc.c Sending spamc/spamc.pod Transmitting file data ... Committed revision 1428508. Regards, KAM
Hi, I just came back to this and I wondered if this is the right syntax (my C is not very good): if ((!(flags & SPAMC_SAFE_FALLBACK)) && (flags & SPAMC_UNAVAIL_TEMPFAIL) && (ret == EX_UNAVAILABLE)) why negate the flags & SPAMC_SAFE_FALLBACK check?