Bug 6717 - Add option -X to turn EX_UNAVAILABE into EX_TEMPFAIL
Summary: Add option -X to turn EX_UNAVAILABE into EX_TEMPFAIL
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: PC Linux
: P2 enhancement
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-06 22:58 UTC by Sebastian
Modified: 2013-06-04 00:06 UTC (History)
3 users (show)



Attachment Type Modified Status Actions Submitter/CLA Status
Patch to add -X option application/octet-stream None Sebastian [NoCLA]
Revised Patch to add EX_TEMPFAIL for -X option for spamc application/octet-stream None Kevin A. McGrail [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian 2011-12-06 22:58:42 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.
Comment 1 Bernhard Frauendienst 2012-01-06 18:37:50 UTC
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.
Comment 2 Kevin A. McGrail 2012-01-06 20:31:51 UTC
I'll see what I can do to test this. Your idea makes sense.
Comment 3 Sebastian 2012-12-28 16:21:19 UTC
Hello,

I just wanted to ask if there is anything new regarding this enhancement? Will something like this be added?

Regards

Sebastian
Comment 4 Kevin A. McGrail 2013-01-03 17:22:16 UTC
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.
Comment 5 Kevin A. McGrail 2013-01-03 17:52:21 UTC
(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
Comment 6 Sebastian 2013-06-04 00:06:03 UTC
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?