Merge authors:
  Jim Popovitch (jimpop)
Related merge proposals:
  https://code.launchpad.net/~jimpop/mailman/subscriber-dbl-check/+merge/347789
  proposed by: Jim Popovitch (jimpop)
------------------------------------------------------------
revno: 1770 [merge]
committer: Mark Sapiro <m...@msapiro.net>
branch nick: 2.1
timestamp: Tue 2018-06-12 06:55:49 -0700
message:
  Implemented BLOCK_SPAMHAUS_LISTED_DBL_SUBSCRIBE.
modified:
  Mailman/Defaults.py.in
  Mailman/MailList.py
  Mailman/Utils.py
  NEWS


--
lp:mailman/2.1
https://code.launchpad.net/~mailman-coders/mailman/2.1

Your team Mailman Checkins is subscribed to branch lp:mailman/2.1.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/2.1/+edit-subscription
=== modified file 'Mailman/Defaults.py.in'
--- Mailman/Defaults.py.in	2018-06-05 02:19:31 +0000
+++ Mailman/Defaults.py.in	2018-06-11 17:55:03 +0000
@@ -150,6 +150,10 @@
 # will be blocked.
 BLOCK_SPAMHAUS_LISTED_IP_SUBSCRIBE = No
 
+# IF the following is set to Yes, and a subscriper uses a domain that is
+# listed in the Spamhaus DBL, the subscription will be blocked.
+BLOCK_SPAMHAUS_LISTED_DBL_SUBSCRIBE = No
+
 # Command that is used to convert text/html parts into plain text.  This
 # should output results to standard output.  %(filename)s will contain the
 # name of the temporary file that the program should operate on.

=== modified file 'Mailman/MailList.py'
--- Mailman/MailList.py	2018-06-12 02:29:33 +0000
+++ Mailman/MailList.py	2018-06-12 13:55:49 +0000
@@ -915,6 +915,12 @@
                 syslog('vette', '%s banned subscription: %s%s (Spamhaus IP)',
                        realname, email, whence)
                 raise Errors.MembershipIsBanned, 'Spamhaus IP'
+        # See if this is from a spamhaus listed domain.
+        if email and mm_cfg.BLOCK_SPAMHAUS_LISTED_DBL_SUBSCRIBE:
+            if Utils.banned_domain(email):
+                syslog('vette', '%s banned subscription: %s (Spamhaus DBL)',
+                       realname, email)
+                raise Errors.MembershipIsBanned, 'Spamhaus DBL'
         # Sanity check the digest flag
         if digest and not self.digestable:
             raise Errors.MMCantDigestError

=== modified file 'Mailman/Utils.py'
--- Mailman/Utils.py	2018-06-11 16:59:26 +0000
+++ Mailman/Utils.py	2018-06-12 13:55:49 +0000
@@ -1535,3 +1535,25 @@
     if re.search(r'127\.0\.0\.[2-7]$', text, re.MULTILINE):
         return True
     return False
+
+def banned_domain(email):
+    if not dns_resolver:
+        return False
+
+    email = email.lower()
+    user, domain = ParseEmail(email)
+
+    lookup = '%s.zen.spamhaus.org' % (domain)
+
+    resolver = dns.resolver.Resolver()
+    try:
+        ans = resolver.query(lookup, dns.rdatatype.A)
+    except DNSException:
+        return False
+    if not ans:
+        return False
+    text = ans.rrset.to_text()
+    if re.search(r'127\.0\.1\.\d{1,3}$', text, re.MULTILINE):
+        if not re.search(r'127\.0\.1\.255$', text, re.MULTILINE):
+            return True
+    return False

=== modified file 'NEWS'
--- NEWS	2018-06-12 02:29:33 +0000
+++ NEWS	2018-06-12 13:55:49 +0000
@@ -44,6 +44,10 @@
       that can be added to the admin(un)subscribeack.txt templates.  This
       has been done for the 'en' templates, but not for most others.
 
+    - Thanks to Jim Popovitch, there is a new
+      BLOCK_SPAMHAUS_LISTED_DBL_SUBSCRIBE setting to enable blocking web
+      subscribes for addresses in domains listed in the Spamhaus DBL.
+
   i18n
 
     - The Japanese translation has been updated by Yasuhito FUTATSUKI.

_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to