aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Sapiro <mark@msapiro.net>2018-06-12 06:55:49 -0700
committerMark Sapiro <mark@msapiro.net>2018-06-12 06:55:49 -0700
commitd4bf95bd97ebaeebb5291c4f7d9f1d90ff7414fd (patch)
tree0bf62e3d1796bac1aa7d40895de0cceca04acbcc
parentd2da11a73ee15a4e467fdacbb0f5c36447b144f6 (diff)
parente7fff57cf267b6a4c5ba8ce25db19806fe172b32 (diff)
downloadmailman2-d4bf95bd97ebaeebb5291c4f7d9f1d90ff7414fd.tar.gz
mailman2-d4bf95bd97ebaeebb5291c4f7d9f1d90ff7414fd.tar.xz
mailman2-d4bf95bd97ebaeebb5291c4f7d9f1d90ff7414fd.zip
Implemented BLOCK_SPAMHAUS_LISTED_DBL_SUBSCRIBE.
Diffstat (limited to '')
-rwxr-xr-xMailman/Defaults.py.in4
-rwxr-xr-xMailman/MailList.py6
-rw-r--r--Mailman/Utils.py22
-rw-r--r--NEWS4
4 files changed, 36 insertions, 0 deletions
diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in
index 7a86f63c..63a8e99f 100755
--- a/Mailman/Defaults.py.in
+++ b/Mailman/Defaults.py.in
@@ -150,6 +150,10 @@ GLOBAL_BAN_LIST = []
# 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.
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 7cd86bf7..cc1be3b5 100755
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -915,6 +915,12 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
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
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index 9a3b4a8c..d504ecce 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -1535,3 +1535,25 @@ def banned_ip(ip):
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
diff --git a/NEWS b/NEWS
index 149c9838..23cb0271 100644
--- a/NEWS
+++ b/NEWS
@@ -44,6 +44,10 @@ Here is a history of user visible changes to Mailman.
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.