diff options
author | Petr Spacek <pspacek@redhat.com> | 2016-04-27 13:26:48 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-05-30 20:14:32 +0200 |
commit | c978ad5b425a564b6bd3b97fb7a5e25219000e52 (patch) | |
tree | 18d2f0061803a2b1966acf8dde19aa45db905de1 /ipapython | |
parent | a4da9a23788d9f09f562c12d80353fca42f73441 (diff) | |
download | freeipa-c978ad5b425a564b6bd3b97fb7a5e25219000e52.tar.gz freeipa-c978ad5b425a564b6bd3b97fb7a5e25219000e52.tar.xz freeipa-c978ad5b425a564b6bd3b97fb7a5e25219000e52.zip |
Add function ipapython.dnsutil.related_to_auto_empty_zone()
It allows to test if given DNS name is sub/super domain
of an automatic empty zone.
https://fedorahosted.org/freeipa/ticket/5710
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/dnsutil.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ipapython/dnsutil.py b/ipapython/dnsutil.py index 7fa7646d9..98fcc1bfc 100644 --- a/ipapython/dnsutil.py +++ b/ipapython/dnsutil.py @@ -234,6 +234,36 @@ def inside_auto_empty_zone(name): return False +def related_to_auto_empty_zone(name): + """True if specified absolute name is a sub/superdomain of an automatic + empty zone. + + DNS domain is a subdomain of itself so this function + returns True for zone apexes, too. + + >>> related_to_auto_empty_zone(DNSName('.')) + True + >>> related_to_auto_empty_zone(DNSName('in-addr.arpa.')) + True + >>> related_to_auto_empty_zone(DNSName('10.in-addr.arpa.')) + True + >>> related_to_auto_empty_zone(DNSName('1.10.in-addr.arpa.')) + True + >>> related_to_auto_empty_zone(DNSName('unrelated.example.')) + False + >>> related_to_auto_empty_zone(DNSName('1.10.in-addr.arpa')) + Traceback (most recent call last): + ... + AssertionError: ... + """ + assert_absolute_dnsname(name) + relations = {dns.name.NAMERELN_SUBDOMAIN, + dns.name.NAMERELN_EQUAL, + dns.name.NAMERELN_SUPERDOMAIN} + return any(name.fullcompare(aez)[0] in relations + for aez in EMPTY_ZONES) + + def resolve_rrsets(fqdn, rdtypes): """ Get Resource Record sets for given FQDN. |