Package: spamass-milter
Version: 0.3.1-7

In reference to:
http://lists.debian.org/debian-project/2008/12/msg00151.html
8<----------------------------------------------------------------------------------
If you sign up for mail from mailing lists, just discard mail that you
don't want to read that comes in from us with Priority: bulk or List-*
headers instead of bouncing it. A mailing list is little more than a
glorified mail forwarder: bouncing forwarded mail is wrong.
---------------------------------------------------------------------------------->8
(Co-incidence that the author of that text is the package maintainer for
this package)

Find attached a patch which turns a REJECT into a DISCARD when a
"Precedence: List" header is present.

I took http://mit.edu/network/spam/examples/britney.txt and pre-pended a
  "Precendence: List" header to it, telneted into the box on 25
EHLO,MAIL FROM,RCPT TO,DATA,<paste> and as result:

Dec 27 15:25:39 abaddon spamd[31168]: spamd: identified spam (11.7/5.0)
for jeroen:108 in 5.1 seconds, 1199 bytes.
Dec 27 15:25:39 abaddon spamd[31168]: spamd: result: Y 11 -
BAYES_60,DATE_IN_PAST_24_48,FH_FROMEML_NOTLD,HTML_MESSAGE,HTML_MISSING_CTYPE,HTML_TAG_BALANCE_BODY,INVALID_DATE,MISSING_MIME_HB_SEP,NORMAL_HTTP_TO_IP,RDNS_NONE
scantime=5.1,size=1199,user=jeroen,uid=108,required_score=5.0,rhost=localhost,raddr=127.0.0.1,rport=9814,mid=<200106110439.aaa06...@pacific-carrier-annex.mit.edu>,bayes=0.790679,autolearn=no
Dec 27 15:25:39 abaddon postfix/cleanup[32588]: 99F0135A523:
milter-discard: END-OF-MESSAGE from
noc.sixxs.net[2001:838:1:1:210:dcff:fe20:7c7c]: milter triggers DISCARD
action; from=<test...@unfix.org> to=<jer...@unfix.org> proto=ESMTP
helo=<noc.sixxs.net>

Please apply this patch to spamass-milter so that I don't get unsubbed
anymore from Debian mailinglists because they are forwarding spam and spam.

Greets,
 Jeroen
diff -u spamass-milter-0.3.1/spamass-milter.cpp 
spamass-milter-0.3.1-precedence/spamass-milter.cpp
--- spamass-milter-0.3.1/spamass-milter.cpp     2007-10-02 00:06:23.000000000 
+0200
+++ spamass-milter-0.3.1-precedence/spamass-milter.cpp  2008-12-27 
16:20:04.000000000 +0100
@@ -455,10 +455,25 @@
                                do_reject = true;
                }
        }
+
        if (do_reject)
        {
-               debug(D_MISC, "Rejecting");
-               smfi_setreply(ctx, "550", "5.7.1", "Blocked by SpamAssassin");
+               // Change Reject into a DISCARD when the Precedence is List
+               // This stops us from bouncing towards mailing lists
+               // See bottom of 
http://lists.debian.org/debian-project/2008/12/msg00151.html
+               // Added by Jeroen Massar
+               if (cmp_nocase_partial("List", assassin->precedence()) == 0) 
do_reject = false;
+
+               if (do_reject)
+               {
+                       debug(D_MISC, "Rejecting");
+                       smfi_setreply(ctx, "550", "5.7.1", "Blocked by 
SpamAssassin");
+               }
+               else
+               {
+                       debug(D_MISC, "Discarding");
+                       /* No reply here, we just throw it out of the door */
+               }
 
 
                if (flag_bucket)
@@ -521,7 +536,9 @@
                        free(buf);
 #endif 
                }
-               return SMFIS_REJECT;
+
+               /* To Reject or To Discard, that is the question */
+               return do_reject ? SMFIS_REJECT : SMFIS_DISCARD;
        }
   }
 
@@ -1085,6 +1102,12 @@
        };
      }
 
+  // Is it a Precedence header?
+  if ( cmp_nocase_partial("Precedence", headerf) == 0 )
+  {
+       assassin->set_precedence(headerv);
+  }
+
   // Is it a "X-Spam-" header field?
   if ( cmp_nocase_partial("X-Spam-", headerf) == 0 )
     {
@@ -1644,6 +1667,12 @@
 }
 
 string& 
+SpamAssassin::precedence()
+{
+  return x_precedence;
+}
+
+string& 
 SpamAssassin::spam_report()
 {
   return x_spam_report;
@@ -1776,6 +1805,14 @@
 }
 
 string::size_type
+SpamAssassin::set_precedence(const string& val)
+{
+  string::size_type old = x_precedence.size();
+  x_precedence = val;
+  return (old);
+}
+
+string::size_type
 SpamAssassin::set_spam_prev_content_type(const string& val)
 {
   string::size_type old = x_spam_prev_content_type.size();
diff -u spamass-milter-0.3.1/spamass-milter.h 
spamass-milter-0.3.1-precedence/spamass-milter.h
--- spamass-milter-0.3.1/spamass-milter.h       2007-08-22 06:14:58.000000000 
+0200
+++ spamass-milter-0.3.1-precedence/spamass-milter.h    2008-12-27 
15:13:08.000000000 +0100
@@ -99,6 +99,7 @@
   string& spam_checker_version();
   string& spam_level();
   string& content_type();
+  string& precedence();
   string& subject();
   string& rcpt();              /* first RCPT TO: recipient (raw) */
   string& from();              /* MAIL FROM: sender (raw) */
@@ -115,6 +116,7 @@
   string::size_type set_spam_checker_version(const string&);
   string::size_type set_spam_level(const string&);
   string::size_type set_content_type(const string&);
+  string::size_type set_precedence(const string&);
   string::size_type set_subject(const string&);
   string::size_type set_rcpt(const string&);
   string::size_type set_from(const string&);
@@ -138,7 +140,7 @@
   string outputbuffer;
 
   // Variables for SpamAssassin influenced fields
-  string x_spam_status, x_spam_flag, x_spam_report, x_spam_prev_content_type;
+  string x_spam_status, x_spam_flag, x_spam_report, x_spam_prev_content_type, 
x_precedence;
   string x_spam_checker_version, x_spam_level, _content_type, _subject;
   
   // Envelope info: MAIL FROM:, RCPT TO:, and IP address of remote host

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to