You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/06/28 15:00:01 UTC

svn commit: r551544 - in /spamassassin/trunk: spamc/libspamc.c spamc/spamc.c t/spamc_x_E_R.t

Author: jm
Date: Thu Jun 28 06:00:00 2007
New Revision: 551544

URL: http://svn.apache.org/viewvc?view=rev&rev=551544
Log:
bug 5412: fix all the various combinations of spamc -x -E -R -s; previous rev of the fix broke -s

Modified:
    spamassassin/trunk/spamc/libspamc.c
    spamassassin/trunk/spamc/spamc.c
    spamassassin/trunk/t/spamc_x_E_R.t

Modified: spamassassin/trunk/spamc/libspamc.c
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamc/libspamc.c?view=diff&rev=551544&r1=551543&r2=551544
==============================================================================
--- spamassassin/trunk/spamc/libspamc.c (original)
+++ spamassassin/trunk/spamc/libspamc.c Thu Jun 28 06:00:00 2007
@@ -508,8 +508,8 @@
              * safely use as an "always fail" test case */
             if (!strcmp(host, "255.255.255.255")) {
               libspamc_log(tp->flags, LOG_ERR,
-			 "connect to spamd on %s failed broadcast addr",
-			 host);
+                          "connect to spamd on %s failed, broadcast addr",
+                          host);
               status = -1;
             }
             else {
@@ -540,8 +540,8 @@
              * safely use as an "always fail" test case */
             if (!strcmp(ipaddr, "255.255.255.255")) {
               libspamc_log(tp->flags, LOG_ERR,
-			 "connect to spamd on %s failed, broadcast addr",
-			 ipaddr);
+                          "connect to spamd on %s failed, broadcast addr",
+                          ipaddr);
               status = -1;
             }
             else {

Modified: spamassassin/trunk/spamc/spamc.c
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamc/spamc.c?view=diff&rev=551544&r1=551543&r2=551544
==============================================================================
--- spamassassin/trunk/spamc/spamc.c (original)
+++ spamassassin/trunk/spamc/spamc.c Thu Jun 28 06:00:00 2007
@@ -709,8 +709,8 @@
     struct transport trans;
     struct message m;
     int out_fd = -1;
-    int result;
-    int ret;
+    int result = EX_SOFTWARE;
+    int ret = EX_SOFTWARE;
     int extratype = 0;
     int islearned = 0;
     int isreported = 0;
@@ -928,13 +928,11 @@
 
 /* FAIL: */
     result = m.is_spam;
-    if ((flags & SPAMC_CHECK_ONLY) && result != EX_TOOBIG) {
-        get_output_fd(&out_fd);
-	/* probably, the write to stdout failed; we can still report exit code */
-	message_cleanup(&m);
-	ret = result;
+    if (ret != EX_OK) {
+        result = ret;
     }
-    else if (flags & (SPAMC_LEARN|SPAMC_PING) ) {
+
+    if (flags & (SPAMC_LEARN|SPAMC_PING) ) {
         get_output_fd(&out_fd);
         message_cleanup(&m);
     }
@@ -950,7 +948,7 @@
         }
         else {
             /* bug 5412: spamc -x should not output the message on error */
-            if ((flags & SPAMC_SAFE_FALLBACK) && ret != EX_TOOBIG) {
+            if ((flags & SPAMC_SAFE_FALLBACK) || result == EX_TOOBIG) {
                 get_output_fd(&out_fd);
                 message_dump(STDIN_FILENO, out_fd, &m);
             }
@@ -959,7 +957,7 @@
 
 	message_cleanup(&m);
 	if (ret == EX_TOOBIG) {
-	    ret = 0;
+	    ret = EX_OK;    /* too big always means exit(0) -- bug 5412 */
 	}
 	else if (flags & SPAMC_SAFE_FALLBACK) {
 	    ret = EX_OK;

Modified: spamassassin/trunk/t/spamc_x_E_R.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/spamc_x_E_R.t?view=diff&rev=551544&r1=551543&r2=551544
==============================================================================
--- spamassassin/trunk/t/spamc_x_E_R.t (original)
+++ spamassassin/trunk/t/spamc_x_E_R.t Thu Jun 28 06:00:00 2007
@@ -5,7 +5,7 @@
 
 our $DO_RUN = !$SKIP_SPAMD_TESTS;
 
-use Test; plan tests => ($DO_RUN ? 31 : 0);
+use Test; plan tests => ($DO_RUN ? 49 : 0);
 
 exit unless $DO_RUN;
 
@@ -45,6 +45,47 @@
 
 # ----------------------------------------------------------------------
 # error conditions
+# max-size of 512 bytes; EX_TOOBIG, pass through message despite -x
+
+%patterns = (
+  q{ Subject: There yours for FREE!}, 'subj',
+);
+%anti_patterns = (
+  q{ X-Spam-Flag: }, 'flag',
+);
+
+# this should have exit code == 0, and pass through the full
+# unfiltered text
+clear_pattern_counters();
+ok(scrun("-s 512 -x < data/spam/001", \&patterns_run_cb));
+ok ok_all_patterns();
+
+# this should have exit code == 0, and pass through the full
+# unfiltered text
+clear_pattern_counters();
+ok(scrun("-s 512 -x -E < data/spam/001", \&patterns_run_cb));
+ok ok_all_patterns();
+
+%patterns = (
+  q{ 0/0 }, '0/0',
+);
+%anti_patterns = (
+  q{ Subject: There yours for FREE!}, 'subj',
+  q{ X-Spam-Flag: }, 'flag',
+);
+
+# this should have exit code == 0, and emit "0/0"
+clear_pattern_counters();
+ok(scrun("-s 512 -x -R < data/spam/001", \&patterns_run_cb));
+ok ok_all_patterns();
+
+# this should have exit code == 0, and emit "0/0"
+clear_pattern_counters();
+ok(scrun("-s 512 -x -E -R < data/spam/001", \&patterns_run_cb));
+ok ok_all_patterns();
+
+# ----------------------------------------------------------------------
+
 $spamdhost = '255.255.255.255'; # cause "connection failed" errors
 
 # these should have exit code == 0
@@ -77,6 +118,3 @@
 clear_pattern_counters();
 ok(scrunwantfail("--connect-retries 1 -x -E < data/spam/001", \&patterns_run_cb));
 ok ok_all_patterns();
-
-# ----------------------------------------------------------------------
-