------------------------------------------------------------ revno: 1762 committer: Mark Sapiro <[email protected]> branch nick: 2.1 timestamp: Mon 2018-06-04 18:02:12 -0700 message: Added BLOCK_SPAMHAUS_LISTED_IP_SUBSCRIBE Feature 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-04 01:12:09 +0000 +++ Mailman/Defaults.py.in 2018-06-05 01:02:12 +0000 @@ -142,9 +142,14 @@ # in the installation. This supplements the individual list's ban_list. # For example, to ban [email protected] and any @gmail.com address beginning with # yyy, set -# GLOBAL_BAN_LIST = ['[email protected]', '^yyy.*@gmail\.com$'] +# GLOBAL_BAN_LIST = ['xxx@aol\.com', '^yyy.*@gmail\.com$'] GLOBAL_BAN_LIST = [] +# IF the following is set to Yes, and a web subscribe comes from an IPv4 +# address and the IP is listed in Spamhaus ZEN, the subscription will be +# blocked. +BLOCK_SPAMHAUS_LISTED_IP_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-04-11 09:36:40 +0000 +++ Mailman/MailList.py 2018-06-05 01:02:12 +0000 @@ -908,6 +908,13 @@ syslog('vette', '%s banned subscription: %s%s (matched: %s)', realname, email, whence, pattern) raise Errors.MembershipIsBanned, pattern + # See if this is from a spamhaus listed IP. + if remote and BLOCK_SPAMHAUS_LISTED_IP_SUBSCRIBE: + if Utils.banned_ip(remote): + whence = ' from %s' % remote + syslog('vette', '%s banned subscription: %s%s (Spamhaus IP)', + realname, email, whence) + raise Errors.MembershipIsBanned, pattern # Sanity check the digest flag if digest and not self.digestable: raise Errors.MMCantDigestError === modified file 'Mailman/Utils.py' --- Mailman/Utils.py 2018-04-11 09:36:40 +0000 +++ Mailman/Utils.py 2018-06-05 01:02:12 +0000 @@ -1495,3 +1495,24 @@ else: return s +def banned_ip(ip): + if not dns_resolver: + return False + parts = ip.split('.') + if len(parts) != 4: + return False + lookup = '{}.{}.{}.{}.zen.spamhaus.org'.format(parts[3], + parts[2], + parts[1], + parts[0]) + 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\.0\.\d{1,2}$', text, re.MULTILINE): + return True + return False === modified file 'NEWS' --- NEWS 2018-06-04 15:54:31 +0000 +++ NEWS 2018-06-05 01:02:12 +0000 @@ -24,6 +24,10 @@ - An option has been added to bin/add_members to issue invitations instead of immediately adding members. (LP: #1773064) + - A new BLOCK_SPAMHAUS_LISTED_IP_SUBSCRIBE setting has been added to + enable blocking web subscribes from IPv4 addresses listed in Spamhaus + ZEN. + i18n - The Japanese translation has been updated by Yasuhito FUTATSUKI.
_______________________________________________ Mailman-checkins mailing list [email protected] Unsubscribe: https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org
