[Mailman-Users] KNOWN_SPAMMERS not consulted for -bounces

Todd Freedom_Lover at pobox.com
Thu Apr 22 19:45:19 CEST 2004

Hash: SHA1

I have SpamAssassin setup site-wide on a system running mailman (and
some webmail users).  I wanted to take advantage of this to filter out
the most obvious spam sent to my lists so I added

    KNOWN_SPAMMERS = [('X-Spam-Flag','YES')]

to mm_cfg.py.  That works for most stuff but it does not help when
spam is sent to the list-bounces address, as more and more spam seems
to be doing on this system.  I don't really want to disable sending
uncaught bounces to the list admin, but as more and more spam gets
sent there, it's harder and harder to justify not doing something.

Is there a reason anyone knows of why the BounceRunner doesn't run
messages through the either the GLOBAL_PIPLINE or OWNER_PIPELINE?  I
experimented with adding a simple _dospamdetect method to the
BounceRunner and it seems to work, but I'd like to know if there's
some well thought out reason why this isn't already done and what I
might break doing this.

The patch I made to Mailman/Queue/BounceRunner.py is below.  Try not
to laugh too hard if I've done anything grossly out of style for
Python coding.  Most of it is taken right out of the _dopipeline code
in Mailman/Queue/IncomingRunner.py.  Comments, criticisms, or
improvements would be most welcome.

- --- mailman-2.1.4/Mailman/Queue/BounceRunner.py~	Mon Jan  5 13:51:14 2004
+++ mailman-2.1.4/Mailman/Queue/BounceRunner.py	Mon Apr 19 00:12:48 2004
@@ -16,6 +16,8 @@
 """Bounce queue runner."""
+import sys
+import os
 import re
 import time
@@ -24,6 +26,7 @@
 from email.Utils import parseaddr
 from Mailman import mm_cfg
+from Mailman import Errors
 from Mailman import Utils
 from Mailman import LockFile
 from Mailman.Message import UserNotification
@@ -56,6 +59,9 @@
         # Make sure we have the most up-to-date state
         outq = get_switchboard(mm_cfg.OUTQUEUE_DIR)
+        # First detect spam
+        if self._dospamdetect(mlist, msg, msgdata):
+            return
         # There are a few possibilities here:
         # - the message could have been VERP'd in which case, we know exactly
@@ -110,6 +116,23 @@
         self._next_registration = now + REGISTER_BOUNCES_EVERY
+    def _dospamdetect(self, mlist, msg, msgdata):
+        modname = 'Mailman.Handlers.SpamDetect'
+        __import__(modname)
+        try:
+            pid = os.getpid()
+            sys.modules[modname].process(mlist, msg, msgdata)
+            # Failsafe -- a child may have leaked through.
+            if pid <> os.getpid():
+                syslog('error', 'child process leaked thru: %s', modname)
+                os._exit(1)
+        except Errors.DiscardMessage:
+            # Throw the message away; we need do nothing else with it.
+            syslog('vette', 'Message discarded, msgid: %s',
+                   msg.get('message-id', 'n/a'))
+            return 1
+        return
     def _register_bounces(self):
         syslog('bounce', 'Processing %s queued bounces', self._bouncecnt)
         # First, get the list of bounces register against the site list.  For

- -- 
Todd        OpenPGP -> KeyID: 0xD654075A | URL: www.pobox.com/~tmz/pgp
Never attribute to malice that which can be adequately explained by
    -- Hanlon's Razor

Version: GnuPG v1.2.4 (GNU/Linux)
Comment: When crypto is outlawed bayl bhgynjf jvyy unir cevinpl.


More information about the Mailman-Users mailing list