From: Bob Halley Date: Sun, 31 Oct 2010 13:40:00 +0000 (+0000) Subject: dns.resolver.zone_for_name() would return the wrong answer sometimes if the response... X-Git-Tag: v1.9.0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=513f7c96a0dcfad5c1347a73bd86fe09fef343b0;p=thirdparty%2Fdnspython.git dns.resolver.zone_for_name() would return the wrong answer sometimes if the response had a CNAME or DNAME --- diff --git a/ChangeLog b/ChangeLog index 45a660b4..4a064748 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-10-31 Bob Halley + * dns/resolver.py (zone_for_name): A query name resulting in a + CNAME or DNAME response to a node which had an SOA was incorrectly + treated as a zone origin. In these cases, we should just look + higher. + * Added zonediff.py to examples. This program compares two zones and shows the differences either in diff-like plain text, or HTML. Thanks to Dennis Kaarsemaker for contributing this diff --git a/dns/resolver.py b/dns/resolver.py index edeac014..f803eb6d 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -754,9 +754,12 @@ def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None): while 1: try: answer = resolver.query(name, dns.rdatatype.SOA, rdclass, tcp) - return name + if answer.rrset.name == name: + return name + # otherwise we were CNAMEd or DNAMEd and need to look higher except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer): - try: - name = name.parent() - except dns.name.NoParent: - raise NoRootSOA + pass + try: + name = name.parent() + except dns.name.NoParent: + raise NoRootSOA