You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by km...@apache.org on 2013/01/03 18:51:43 UTC

svn commit: r1428508 - in /spamassassin/trunk/spamc: libspamc.h spamc.c spamc.pod

Author: kmcgrail
Date: Thu Jan  3 17:51:43 2013
New Revision: 1428508

URL: http://svn.apache.org/viewvc?rev=1428508&view=rev
Log:
adding -X option to allow spamc to return EX_TEMPFAIL instead of EX_UNAVAILABLE when using -x option

Modified:
    spamassassin/trunk/spamc/libspamc.h
    spamassassin/trunk/spamc/spamc.c
    spamassassin/trunk/spamc/spamc.pod

Modified: spamassassin/trunk/spamc/libspamc.h
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamc/libspamc.h?rev=1428508&r1=1428507&r2=1428508&view=diff
==============================================================================
--- spamassassin/trunk/spamc/libspamc.h (original)
+++ spamassassin/trunk/spamc/libspamc.h Thu Jan  3 17:51:43 2013
@@ -134,6 +134,11 @@
 /* December 5, 2007 duncf: send log messages to callback */
 #define SPAMC_LOG_TO_CALLBACK (1<<14)
 
+/* December 6, 2011 Sebastian Wiesinger <se...@karotte.org>:
+ * Turn EX_UNAVAILABLE into EX_TEMPFAIL - bug 6717
+ * */
+#define SPAMC_UNAVAIL_TEMPFAIL (1<<13)
+
 #define SPAMC_MESSAGE_CLASS_SPAM 1
 #define SPAMC_MESSAGE_CLASS_HAM  2
 

Modified: spamassassin/trunk/spamc/spamc.c
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamc/spamc.c?rev=1428508&r1=1428507&r2=1428508&view=diff
==============================================================================
--- spamassassin/trunk/spamc/spamc.c (original)
+++ spamassassin/trunk/spamc/spamc.c Thu Jan  3 17:51:43 2013
@@ -197,6 +197,12 @@ print_usage(void)
 
     usg("  -x, --no-safe-fallback\n"
         "                      Don't fallback safely.\n");
+    usg("  -X, --unavailable-tempfail\n"
+        "                      When using -x, turn 'unavailable' error into\n"
+        "                      'tempfail'. This may be useful for an MTAs\n"
+        "                      to defer emails with a temporary SMTP error\n"
+	"                      instead of bouncing with a permanent SMTP\n"
+        "                      error.\n");
     usg("  -l, --log-to-stderr Log errors and warnings to stderr.\n");
 #ifndef _WIN32
     usg("  -e, --pipe-to command [args]\n"
@@ -229,9 +235,9 @@ read_args(int argc, char **argv,
           struct transport *ptrn)
 {
 #ifndef _WIN32
-    const char *opts = "-BcrR46d:e:fyp:n:t:s:u:L:C:xzSHU:ElhVKF:0:1:2";
+    const char *opts = "-BcrR46d:e:fyp:n:t:s:u:L:C:xXzSHU:ElhVKF:0:1:2";
 #else
-    const char *opts = "-BcrR46d:fyp:n:t:s:u:L:C:xzSHElhVKF:0:1:2";
+    const char *opts = "-BcrR46d:fyp:n:t:s:u:L:C:xXzSHElhVKF:0:1:2";
 #endif
     int opt;
     int ret = EX_OK;
@@ -262,6 +268,7 @@ read_args(int argc, char **argv,
        { "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' },
@@ -438,6 +445,16 @@ read_args(int argc, char **argv,
                 flags &= (~SPAMC_SAFE_FALLBACK);
                 break;
             }
+            case 'X':
+            {
+		/* Only activates if -x is also used */
+	        if (!(flags & SPAMC_SAFE_FALLBACK)) {
+                	flags |= SPAMC_UNAVAIL_TEMPFAIL;
+		} else {
+			libspamc_log(flags, LOG_ERR, "This option is only valid if -x is set first");
+		}
+		break;
+            }
             case 'y':
             {
                 flags |= SPAMC_SYMBOLS;
@@ -1039,6 +1056,11 @@ main(int argc, char *argv[])
         else if (use_exit_code) {
             ret = result;
 	}
+	
+        /* If -x and -X are used, change from EX_UNAVAILABLE TO EX_TEMPFAIL - bug 6717 */
+	if ((!(flags & SPAMC_SAFE_FALLBACK)) && (flags & SPAMC_UNAVAIL_TEMPFAIL) && (ret == EX_UNAVAILABLE)) {
+	    ret = EX_TEMPFAIL;
+	}
     }
     
 finish:

Modified: spamassassin/trunk/spamc/spamc.pod
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamc/spamc.pod?rev=1428508&r1=1428507&r2=1428508&view=diff
==============================================================================
--- spamassassin/trunk/spamc/spamc.pod (original)
+++ spamassassin/trunk/spamc/spamc.pod Thu Jan  3 17:51:43 2013
@@ -228,6 +228,13 @@ let the MTA queue up the mails for a ret
 
 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. This may allow your MTA to defer mails with a 
+temporary SMTP error instead of bouncing them with a permanent SMTP error. 
+See also L<"EXIT CODES">.
+
 =item B<-y>, B<--tests>
 
 Just output the names of the tests hit to stdout, on one line, separated