[Mailman-Developers] Adding a message id to the vette log

Mark Sapiro mark at msapiro.net
Sat Jan 29 00:30:01 CET 2011


C Nulk wrote:
>
>I am using Mailman v2.1.9 with some minor local mods on CentOS 5.5.  In
>looking through the vette log, I noticed some of the log entries for
>refused postings and discarded postings do not indicate what message
>(via the message id) was acted upon.  I would like to the message id to
>those entries.  I found where the entries are written to in
>ListAdmin.py.   I made a few changes to the file.  Since I am barely
>literate with python, I thought I would post my changes to the list and
>ask you fine people if I did will work, or am I doomed.  There changes
>are (in diff -u format):
>
>--- /usr/lib/mailman/Mailman/ListAdmin.py    2008-05-24
>13:44:12.000000000 -0700
>+++ ListAdmin.py.SCU    2011-01-28 13:26:12.000000000 -0800
>@@ -340,13 +340,21 @@
>             fmsg.send(self)
>         # Log the rejection
>         if rejection:
>+            try:
>+                msg = readMessage(path)
>+            except IOError, e:
>+                if e.errno <> errno.ENOENT: raise
>+                return LOST
>+            msg = readMessage(path)


I would do this a bit differently for two reasons. First, you may
already have the message, and second, the last of the above added
lines is redundant (I know it's in the source above you copied, but
it's redundant there too and should be removed).

So I would say

        if rejection:
            if not msg:
                try:
                    msg = readMessage(path)
                except IOError, e:
                    if e.errno <> errno.ENOENT: raise
                    return LOST


But, this will not log anything at all in the (rare) case when the
message is lost. So I would go a step further and instead of the above
say

        if rejection:
            if not msg:
                try:
                    msg = readMessage(path)
                except IOError, e:
                    if e.errno <> errno.ENOENT: raise
            if msg:
                messageid = msg.get('message-id', 'n/a')
            else
                messageid = 'n/a'



>             note = '''%(listname)s: %(rejection)s posting:
> \tFrom: %(sender)s
>-\tSubject: %(subject)s''' % {
>+\tSubject: %(subject)s
>+\tMessage-id: %(messageid)''' % {
>                 'listname' : self.internal_name(),
>                 'rejection': rejection,
>                 'sender'   : str(sender).replace('%', '%%'),
>                 'subject'  : str(subject).replace('%', '%%'),
>+                'messageid': msg.get('message-id', 'n/a').replace('%',
>'%%'),


And also replace the line above with

                'messageid': messageid.replace('%','%%')

>                 }
>             if comment:
>                 note += '\n\tReason: ' + comment.replace('%', '%%')
>
>
>Also, are there any other files I may need to change?


That depends. Currently, messages which are automatically rejected due
to member_moderation_action, reject_these_nonmembers or
generic_nonmember_action are not logged at all. If you want logging
for them, look at the "except Errors.RejectMessage" clause in the
_dopipeline() definition in IncomingRunner.py
	

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Developers mailing list