diff options
author | Yasuhito FUTATSUKI at POEM <futatuki@poem.co.jp> | 2018-06-13 17:22:47 +0900 |
---|---|---|
committer | Yasuhito FUTATSUKI at POEM <futatuki@poem.co.jp> | 2018-06-13 17:22:47 +0900 |
commit | f9ad5c209b47c5b4677f5f6678667049ceea9baf (patch) | |
tree | 07359919522b45c79abe1648fb8e6b995cb7cc7a /Mailman/Utils.py | |
parent | f4212b4845d8f5d1e3bb1cd5271f49e4641a3051 (diff) | |
parent | d4bf95bd97ebaeebb5291c4f7d9f1d90ff7414fd (diff) | |
download | mailman2-f9ad5c209b47c5b4677f5f6678667049ceea9baf.tar.gz mailman2-f9ad5c209b47c5b4677f5f6678667049ceea9baf.tar.xz mailman2-f9ad5c209b47c5b4677f5f6678667049ceea9baf.zip |
merge lp:mailman/2.1 up to rev 1770
Diffstat (limited to 'Mailman/Utils.py')
-rw-r--r-- | Mailman/Utils.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py index 6038667b..d504ecce 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -111,7 +111,12 @@ def list_exists(listname): # But first ensure the list name doesn't contain a path traversal # attack. if len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, '', listname)) > 0: - syslog('mischief', 'Hostile listname: %s', listname) + remote = os.environ.get('HTTP_FORWARDED_FOR', + os.environ.get('HTTP_X_FORWARDED_FOR', + os.environ.get('REMOTE_ADDR', + 'unidentified origin'))) + syslog('mischief', + 'Hostile listname: listname=%s: remote=%s', listname, remote) return False basepath = Site.get_listpath(listname) for ext in ('.pck', '.pck.last', '.db', '.db.last'): @@ -1530,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 |