From 0ed1632ac9f659734f9397c21d0b2de3c2c2d895 Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <flo@redhat.com>
Date: Tue, 15 Jan 2019 17:53:55 +0100
Subject: [PATCH] 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>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
---
ipaserver/install/bindinstance.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index 7c858aab4417ccf3a4999fcaaa1c7e0f93464e4d..3b03e536117677f0f073fc1f06a28ebab0cfe006 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -844,10 +844,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:
@@ -1063,6 +1066,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)
--
2.20.1