From 90d62bec18278a7e83fe5571523c46b20ce2fc95 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Wed, 29 Aug 2001 05:54:28 +0000 Subject: _dispose(): Factor out common code paths to _toadmins(). _toadmins(): Run the message through SpamDetect to filter out known spam patterns in messages to the list owners/moderators. Log such detected spam to logs/spam and discard the message. Also, for every message to a list's -owner or -admin address, we always send it on to the list owners and moderators, even though the moderators can't access the admin pages (only the admindb pages). Note 1: this makes the `tomoderators' key in the message metadata obsolete. Note 2: this may not be the Right Thing To Do. --- Mailman/Queue/CommandRunner.py | 61 +++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 25 deletions(-) (limited to 'Mailman/Queue/CommandRunner.py') diff --git a/Mailman/Queue/CommandRunner.py b/Mailman/Queue/CommandRunner.py index 92bac6859..d4bcabbf6 100644 --- a/Mailman/Queue/CommandRunner.py +++ b/Mailman/Queue/CommandRunner.py @@ -23,6 +23,7 @@ from Mailman import mm_cfg from Mailman.Bouncers import BouncerAPI +from Mailman.Handlers import SpamDetect from Mailman.Queue.Runner import Runner from Mailman.Queue.sbcache import get_switchboard @@ -98,18 +99,7 @@ class CommandRunner(Runner): if mlist.bounce_processing: if BouncerAPI.ScanMessages(mlist, msg): return - # Either bounce processing isn't turned on or the bounce - # detector found no recognizable bounce format in the message. - # In either case, forward the dang thing off to the list - # owners. Be sure to munge the headers so that any bounces - # from the list owners goes to the -owner address instead of - # the -admin address. This will avoid bounce loops. - virginq = get_switchboard(mm_cfg.VIRGINQUEUE_DIR) - virginq.enqueue(msg, msgdata, - recips = mlist.owner[:], - errorsto = mlist.GetOwnerEmail(), - noack = 0 # enable Replybot - ) + self._toadmins(mlist, msg, msgdata) return elif msgdata.get('toowner'): # The message could have been a bounce from a broken list @@ -125,18 +115,7 @@ class CommandRunner(Runner): if senderlhs in mm_cfg.LIKELY_BOUNCE_SENDERS: syslog('error', 'bounce loop detected from: %s', sender) return - # Any messages to the owner address must have Errors-To: set - # back to the owners address so bounce loops can be broken, as - # per the code above. - recips = mlist.owner[:] - if msgdata.get('tomoderators'): - recips.extend(mlist.moderator) - virginq = get_switchboard(mm_cfg.VIRGINQUEUE_DIR) - virginq.enqueue(msg, msgdata, - recips = recips, - errorsto = mlist.GetOwnerEmail(), - noack = 0 # enable Replybot - ) + self._toadmins(mlist, msg, msgdata) return elif msgdata.get('torequest'): # Just pass the message off the command handler @@ -152,6 +131,38 @@ class CommandRunner(Runner): msg['Subject'] = 'leave' msg.set_payload('') mlist.ParseMailCommands(msg, msgdata) - finally: mlist.Save() + finally: mlist.Unlock() + + def _toadmins(self, mlist, msg, msgdata): + sender = msg.get_sender() + # Send the message through the SpamDetect blocker, hopefully + # reducing the amount of spam our poor admins receive. + try: + SpamDetect.process(mlist, msg, msgdata) + except SpamDetect.SpamDetected: + syslog('spam', + 'Spam to %s-owner address detected from %s', + mlist.internal_name(), sender) + return + # Any messages to the owner address must have Errors-To: set + # back to the owners address so bounce loops can be broken, as + # per the code above. + recips = mlist.owner[:] + # BAW: should we have a separate -moderators address or should all + # correspondences to -owner/-admin also go to the moderators. + # Definition time: owners have access to both the admin and admindb + # pages, while moderators only have access to the admindb pages. + # +## if msgdata.get('tomoderators'): +## recips.extend(mlist.moderator) + # + # For now, we'll always send such email to the moderators as well. + recips.extend(mlist.moderator) + virginq = get_switchboard(mm_cfg.VIRGINQUEUE_DIR) + virginq.enqueue(msg, msgdata, + recips=recips, + errorsto=mlist.GetOwnerEmail(), + noack=0 # enable Replybot + ) -- cgit v1.2.3-70-g09d2