[Mailman-Users] Additional questions about ban_list
Mark Sapiro
mark at msapiro.net
Fri Oct 16 06:33:47 CEST 2015
Mark Sapiro wrote:
> On 10/15/2015 02:37 PM, Chris Nulk wrote:
>> to the following ( I have added ** at the beginning of the lines I added
>> to indicate the changes - in practice the ** would be spaces)
>>
>> def GetBannedPattern(self, email):
>> """Returns matched entry in ban_list if email matches.
>> Otherwise returns None.
>> """
>> ban = False
>> for pattern in self.ban_list:
>> if pattern.startswith('^'):
>> # This is a regular expression match
>> try:
>> if re.search(pattern, email, re.IGNORECASE):
>> ban = True
>> break
>> except re.error:
>> # BAW: we should probably remove this pattern
>> pass
>> ** elif pattern.startswith('@'):
>> ** listname = self.internal_name() # is this correct?
>> ** try:
>> ** mname = pattern[1:].lower().strip()
>> ** if mname == listname:
>> ** # don't reference your own list
>> ** syslog('error',
>> ** 'Ban_list listfor %s references own list',
>> ** listname)
>> ** else:
>> ** mother = MailList(mname, lock=0)
>> ** if mother.isMember(email):
>> ** ban = True
>> ** break
>> ** except Errors.MMUnknownListError:
>> ** syslog('error',
>> ** 'Ban_list for list %s references non-existent
>> list %s',
>> ** listname, mname)
>> else:
>> # Do the comparison case insensitively
>> if pattern.lower() == email.lower():
>> ban = True
>> break
>> if ban:
>> return pattern
>> else:
>> return None
>>
>> Am I on the correct path?
>
>
> Yes.
One more thing however. While the above code looks good for processing
@listname entries in ban_list, you won't be able to add them via the
list admin GUI unless you also modify Mailman/Gui/GUIBase.py. You need
to find the lines in that module that in 2.1.18-1 are
elif (wtype == mm_cfg.EmailListEx and addr.startswith('@')
and property.endswith('_these_nonmembers')):
only indented more than above and change them to
elif (wtype == mm_cfg.EmailListEx and addr.startswith('@')
and (property.endswith('_these_nonmembers') or
property == 'ban_list')):
If you don't make that change, you will still be able to add @listname
entries to a list's ban_list with withlist or other scripts, but the web
admin GUI will report them as bad email addresses.
--
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-Users
mailing list