From 934489a03705964deaff93d7d6428ee819fb4622 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Sat, 26 Jan 2002 23:28:53 +0000 Subject: dequeue(): Handle the case when the email package throws a MessageParseError during parsing of the message. Most likely cause is because of bad MIME encapsulation. /That's/ likely caused by the message being a virus . Disposition depends on QRUNNER_SAVE_BAD_MESSAGES. When true, the message text is saved in qfiles/bad. When false, it is discarded. We always log the error. --- Mailman/Queue/Switchboard.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Mailman/Queue/Switchboard.py b/Mailman/Queue/Switchboard.py index f0714dd80..a71d6c146 100644 --- a/Mailman/Queue/Switchboard.py +++ b/Mailman/Queue/Switchboard.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001 by the Free Software Foundation, Inc. +# Copyright (C) 2001,2002 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -157,6 +157,22 @@ class _Switchboard: os.unlink(msgfile) except EnvironmentError, e: if e.errno <> errno.ENOENT: raise + except email.Errors.MessageParseError, e: + # This message was unparsable, most likely because its + # MIME encapsulation was broken. For now, there's not + # much we can do about it. + syslog('error', 'message is unparsable: %s', filebase) + msgfp.close() + msgfp = None + if mm_cfg.QRUNNER_SAVE_BAD_MESSAGES: + # Cheapo way to ensure the directory exists w/ the + # proper permissions. + sb = Switchboard(mm_cfg.BADQUEUE_DIR) + os.rename(msgfile, os.path.join( + mm_cfg.BADQUEUE_DIR, filebase + '.txt')) + else: + os.unlink(msgfile) + msg = data = None finally: if msgfp: msgfp.close() -- cgit v1.3.1