From 29f51f1e3b79040d67f827e655029d17dbb6c226 Mon Sep 17 00:00:00 2001
From: Mark Sapiro <mark@msapiro.net>
Date: Tue, 17 May 2016 13:54:43 -0700
Subject: Improved logging of banned subscription and address change attempts.

---
 Mailman/MailList.py | 13 ++++++++++++-
 NEWS                |  3 +++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 00ee4c04..99cbbd2f 100755
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2015 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2016 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
@@ -809,6 +809,8 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
         # check for banned address
         pattern = self.GetBannedPattern(invitee)
         if pattern:
+            syslog('vette', '%s banned invitation: %s (matched: %s)',
+                   self.real_name, invitee, pattern)
             raise Errors.MembershipIsBanned, pattern
         # Hack alert!  Squirrel away a flag that only invitations have, so
         # that we can do something slightly different when an invitation
@@ -1011,6 +1013,12 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
         # and confirmations.
         pattern = self.GetBannedPattern(email)
         if pattern:
+            if whence:
+                source = ' from %s' % whence
+            else:
+                source = ''
+            syslog('vette', '%s banned subscription: %s%s (matched: %s)',
+                   self.real_name, email, source, pattern)
             raise Errors.MembershipIsBanned, pattern
         # Do the actual addition
         self.addNewMember(email, realname=name, digest=digest,
@@ -1175,6 +1183,9 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
         # exception.
         pattern = self.GetBannedPattern(newaddr)
         if pattern:
+            syslog('vette',
+                   '%s banned address change: %s -> %s (matched: %s)',
+                   self.real_name, oldaddr, newaddr, pattern)
             raise Errors.MembershipIsBanned, pattern
         # It's possible they were a member of this list, but choose to change
         # their membership globally.  In that case, we simply remove the old
diff --git a/NEWS b/NEWS
index 5eda4c28..aa35687e 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,9 @@ Here is a history of user visible changes to Mailman.
 
   Bug fixes and other patches
 
+    - Improved logging of banned subscription and address change attempts.
+      (LP: #1582856)
+
     - In rare circumstances a list can be removed while the admin or listinfo
       CGI or bin/list_lists is running causing an uncaught MMUnknownListError
       to be thrown.  The exception is now caught and handled.  (LP: #1582532)
-- 
cgit v1.2.3