From b153b23c75a8ddd4170c3ba47774ced219bf20aa Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Mon, 9 Nov 2020 15:22:34 +1100 Subject: [PATCH] dns: allow PTR records in arbitrary zones PTR records in zones other than in-addr.arpa and in6.arpa are legal, e.g. DNS-SD [RFC6763] uses such records. If in a reverse zone proceed with the existing checks, otherwise just accept the record. Fixes: https://pagure.io/freeipa/issue/5566 Reviewed-By: Alexander Bokovoy --- ipaserver/plugins/dns.py | 9 +++++---- ipatests/test_xmlrpc/test_dns_plugin.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ipaserver/plugins/dns.py b/ipaserver/plugins/dns.py index 5fd792254..eb21e3cee 100644 --- a/ipaserver/plugins/dns.py +++ b/ipaserver/plugins/dns.py @@ -3111,10 +3111,11 @@ class dnsrecord(LDAPObject): zone_len = REVERSE_DNS_ZONES[valid_zone] if not zone_len: - allowed_zones = ', '.join([unicode(revzone) for revzone in - REVERSE_DNS_ZONES]) - raise errors.ValidationError(name='ptrrecord', - error=unicode(_('Reverse zone for PTR record should be a sub-zone of one the following fully qualified domains: %s') % allowed_zones)) + # PTR records in zones other than in-addr.arpa and ip6.arpa are + # legal, e.g. DNS-SD [RFC6763] uses such records. If we have + # such a record there's nothing more to do. Otherwise continue + # with the ip4/ip6 reverse zone checks below. + return addr_len = len(addr.labels) diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py index 5bc3e06ae..41a70c451 100644 --- a/ipatests/test_xmlrpc/test_dns_plugin.py +++ b/ipatests/test_xmlrpc/test_dns_plugin.py @@ -3331,6 +3331,24 @@ class test_dns(Declarative): }, ), + dict( + desc='Add PTR record in a non-.arpa zone [DNS-SD]', + command=( + 'dnsrecord_add', + [zone1, '_http._tcp'], + {'ptrrecord': 'home._http._tcp'}, + ), + expected={ + 'value': DNSName('_http._tcp'), + 'summary': None, + 'result': { + 'dn': DN(('idnsname', '_http._tcp'), zone1_dn), + 'idnsname': [DNSName('_http._tcp')], + 'ptrrecord': ['home._http._tcp'], + 'objectclass': objectclasses.dnsrecord, + }, + }, + ), dict( desc='Delete zone %r' % zone1,