replica installation: add master record only if in managed zone

Scenario: install a replica with DNS, whose IP address is part of a
forward zone.
Currently, the replica installation fails because the installer is
trying to add a A/AAAA record for the replica in the zone
when setting up the bind instance, and addition of records in a
forward zone is forbidden.

The bind installer should check if the IP address is in a master zone
(i.e. a DNS zone managed by IdM, not a forward zone), and avoid
creating the record if it's not the case.

During uninstallation, perform the same check before removing the
DNS record (if in a forward zone, no need to call dnsrecord-del).
Fixes: https://pagure.io/freeipa/issue/7369
Reviewed-By: Francois Cami <fcami@redhat.com>
This commit is contained in:
Florence Blanc-Renaud
2019-01-22 16:38:59 +01:00
committed by François Cami
parent 165a941109
commit 63fa87a36e
+10 -3
View File
@@ -880,10 +880,13 @@ class BindInstance(service.Service):
# Add forward and reverse records to self
for addr in addrs:
try:
# Check first if the zone is a master zone
# (if it is a forward zone, dns_zone_exists will return False)
if dns_zone_exists(zone, api=self.api):
add_fwd_rr(zone, host, addr, self.api)
except errors.NotFound:
pass
else:
logger.debug("Skip adding record %s to a zone %s "
"not managed by IPA", addr, zone)
reverse_zone = find_reverse_zone(addr, self.api)
if reverse_zone:
@@ -1099,6 +1102,10 @@ class BindInstance(service.Service):
self.fqdn = fqdn
self.domain = domain_name
if not dns_zone_exists(zone, api=self.api):
# Zone may be a forward zone, skip update
return
areclist = get_fwd_rr(zone, host, api=self.api)
for rdata in areclist:
del_fwd_rr(zone, host, rdata, api=self.api)