|
|
e3ffab |
From c04aa879436f190f82265b87255e2a7a27939975 Mon Sep 17 00:00:00 2001
|
|
|
e3ffab |
From: Martin Basti <mbasti@redhat.com>
|
|
|
e3ffab |
Date: Tue, 6 Jan 2015 10:36:06 +0100
|
|
|
e3ffab |
Subject: [PATCH] Fix: Upgrade forwardzones zones after adding newer replica
|
|
|
e3ffab |
|
|
|
e3ffab |
Patch fixes issue, when forwardzones has not been upgraded after adding
|
|
|
e3ffab |
replica >=4.0 into topology with IPA 3.x servers.
|
|
|
e3ffab |
|
|
|
e3ffab |
Ticket: https://fedorahosted.org/freeipa/ticket/4818
|
|
|
e3ffab |
Reviewed-By: Petr Spacek <pspacek@redhat.com>
|
|
|
e3ffab |
---
|
|
|
e3ffab |
install/share/dns.ldif | 2 ++
|
|
|
e3ffab |
install/updates/40-dns.update | 1 +
|
|
|
e3ffab |
ipaserver/install/plugins/dns.py | 65 +++++++++++++++++++++-------------------
|
|
|
e3ffab |
3 files changed, 37 insertions(+), 31 deletions(-)
|
|
|
e3ffab |
|
|
|
e3ffab |
diff --git a/install/share/dns.ldif b/install/share/dns.ldif
|
|
|
e3ffab |
index 2c6050f8598b82e3f0e476d5bff5522f4b54e521..05f5684c385db653a049a15bf490efe0d95e4a38 100644
|
|
|
e3ffab |
--- a/install/share/dns.ldif
|
|
|
e3ffab |
+++ b/install/share/dns.ldif
|
|
|
e3ffab |
@@ -2,8 +2,10 @@ dn: cn=dns,$SUFFIX
|
|
|
e3ffab |
changetype: add
|
|
|
e3ffab |
objectClass: idnsConfigObject
|
|
|
e3ffab |
objectClass: nsContainer
|
|
|
e3ffab |
+objectClass: ipaConfigObject
|
|
|
e3ffab |
objectClass: top
|
|
|
e3ffab |
cn: dns
|
|
|
e3ffab |
+ipaConfigString: DNSVersion 1
|
|
|
e3ffab |
aci: (targetattr = "*")(version 3.0; acl "Allow read access"; allow (read,search,compare) groupdn = "ldap:///cn=Read DNS Entries,cn=permissions,cn=pbac,$SUFFIX" or userattr = "parent[0,1].managedby#GROUPDN";)
|
|
|
e3ffab |
aci: (target = "ldap:///idnsname=*,cn=dns,$SUFFIX")(version 3.0;acl "Add DNS entries in a zone";allow (add) userattr = "parent[1].managedby#GROUPDN";)
|
|
|
e3ffab |
aci: (target = "ldap:///idnsname=*,cn=dns,$SUFFIX")(version 3.0;acl "Remove DNS entries from a zone";allow (delete) userattr = "parent[1].managedby#GROUPDN";)
|
|
|
e3ffab |
diff --git a/install/updates/40-dns.update b/install/updates/40-dns.update
|
|
|
e3ffab |
index 00fc97fcafc98ee6ef6e0c36b2005635867287b2..251df5907217344fb7bda3adcdef0d5c79c449ab 100644
|
|
|
e3ffab |
--- a/install/updates/40-dns.update
|
|
|
e3ffab |
+++ b/install/updates/40-dns.update
|
|
|
e3ffab |
@@ -2,6 +2,7 @@
|
|
|
e3ffab |
# update DNS container
|
|
|
e3ffab |
dn: cn=dns, $SUFFIX
|
|
|
e3ffab |
addifexist: objectClass: idnsConfigObject
|
|
|
e3ffab |
+addifexist: objectClass: ipaConfigObject
|
|
|
e3ffab |
addifexist: aci:'(target = "ldap:///idnsname=*,cn=dns,$SUFFIX")(version 3.0;acl "Add DNS entries in a zone";allow (add) userattr = "parent[1].managedby#GROUPDN";)'
|
|
|
e3ffab |
addifexist: aci:'(target = "ldap:///idnsname=*,cn=dns,$SUFFIX")(version 3.0;acl "Remove DNS entries from a zone";allow (delete) userattr = "parent[1].managedby#GROUPDN";)'
|
|
|
e3ffab |
addifexist: aci:'(targetattr = "idnsname || cn || idnsallowdynupdate || dnsttl || dnsclass || arecord || aaaarecord || a6record || nsrecord || cnamerecord || ptrrecord || srvrecord || txtrecord || mxrecord || mdrecord || hinforecord || minforecord || afsdbrecord || sigrecord || keyrecord || locrecord || nxtrecord || naptrrecord || kxrecord || certrecord || dnamerecord || dsrecord || sshfprecord || rrsigrecord || nsecrecord || idnsname || idnszoneactive || idnssoamname || idnssoarname || idnssoaserial || idnssoarefresh || idnssoaretry || idnssoaexpire || idnssoaminimum || idnsupdatepolicy || idnsallowquery || idnsallowtransfer || idnsallowsyncptr || idnsforwardpolicy || idnsforwarders || dlvrecord || idnssecinlinesigning || nsec3paramrecord || tlsarecord ")(target = "ldap:///idnsname=*,cn=dns,$SUFFIX")(version 3.0;acl "Update DNS entries in a zone";allow (write) userattr = "parent[0,1].managedby#GROUPDN";)'
|
|
|
e3ffab |
diff --git a/ipaserver/install/plugins/dns.py b/ipaserver/install/plugins/dns.py
|
|
|
e3ffab |
index 62cf588d27155acb03026f69ea09ff15582d26dc..ea4aec9741e4714cacdb677bd850730462623fa7 100644
|
|
|
e3ffab |
--- a/ipaserver/install/plugins/dns.py
|
|
|
e3ffab |
+++ b/ipaserver/install/plugins/dns.py
|
|
|
e3ffab |
@@ -18,6 +18,7 @@
|
|
|
e3ffab |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
e3ffab |
|
|
|
e3ffab |
import ldap as _ldap
|
|
|
e3ffab |
+import re
|
|
|
e3ffab |
import traceback
|
|
|
e3ffab |
import time
|
|
|
e3ffab |
|
|
|
e3ffab |
@@ -144,32 +145,6 @@ class update_dns_limits(PostUpdate):
|
|
|
e3ffab |
api.register(update_dns_limits)
|
|
|
e3ffab |
|
|
|
e3ffab |
|
|
|
e3ffab |
-class update_check_forwardzones(PreSchemaUpdate):
|
|
|
e3ffab |
- """
|
|
|
e3ffab |
- Check if the idnsforwardzone objectclass is in LDAP schema.
|
|
|
e3ffab |
- If not update is required (update_to_forward_zones), set sysupgrade state
|
|
|
e3ffab |
- 'update_to_forward_zones' to True
|
|
|
e3ffab |
- """
|
|
|
e3ffab |
-
|
|
|
e3ffab |
- def execute(self, **options):
|
|
|
e3ffab |
- state = sysupgrade.get_upgrade_state('dns', 'update_to_forward_zones')
|
|
|
e3ffab |
- if state is False:
|
|
|
e3ffab |
- # no upgrade is needed
|
|
|
e3ffab |
- return (False, False, [])
|
|
|
e3ffab |
- ldap = self.obj.backend
|
|
|
e3ffab |
- if not dns_container_exists(ldap): # No DNS installed
|
|
|
e3ffab |
- return (False, False, [])
|
|
|
e3ffab |
- result = ldap.schema.get_obj(_ldap.schema.models.ObjectClass, 'idnsforwardzone')
|
|
|
e3ffab |
- if result is None:
|
|
|
e3ffab |
- sysupgrade.set_upgrade_state('dns', 'update_to_forward_zones', True)
|
|
|
e3ffab |
- self.log.info('Prepared upgrade to forward zones')
|
|
|
e3ffab |
- else:
|
|
|
e3ffab |
- sysupgrade.set_upgrade_state('dns', 'update_to_forward_zones', False)
|
|
|
e3ffab |
- return (False, False, [])
|
|
|
e3ffab |
-
|
|
|
e3ffab |
-api.register(update_check_forwardzones)
|
|
|
e3ffab |
-
|
|
|
e3ffab |
-
|
|
|
e3ffab |
class update_master_to_dnsforwardzones(PostUpdate):
|
|
|
e3ffab |
"""
|
|
|
e3ffab |
Update all zones to meet requirements in the new FreeIPA versions
|
|
|
e3ffab |
@@ -188,10 +163,41 @@ class update_master_to_dnsforwardzones(PostUpdate):
|
|
|
e3ffab |
|
|
|
e3ffab |
def execute(self, **options):
|
|
|
e3ffab |
ldap = self.obj.backend
|
|
|
e3ffab |
- if not sysupgrade.get_upgrade_state('dns', 'update_to_forward_zones'):
|
|
|
e3ffab |
- # forward zones was tranformed before, nothing to do
|
|
|
e3ffab |
+ # check LDAP if forwardzones already uses new semantics
|
|
|
e3ffab |
+ dns_container_dn = DN(api.env.container_dns, api.env.basedn)
|
|
|
e3ffab |
+ try:
|
|
|
e3ffab |
+ container_entry = ldap.get_entry(dns_container_dn)
|
|
|
e3ffab |
+ except errors.NotFound:
|
|
|
e3ffab |
+ # DNS container not found, nothing to upgrade
|
|
|
e3ffab |
return (False, False, [])
|
|
|
e3ffab |
|
|
|
e3ffab |
+ for config_option in container_entry.get("ipaConfigString", []):
|
|
|
e3ffab |
+ matched = re.match("^DNSVersion\s+(?P<version>\d+)$",
|
|
|
e3ffab |
+ config_option, flags=re.I)
|
|
|
e3ffab |
+ if matched and int(matched.group("version")) >= 1:
|
|
|
e3ffab |
+ # forwardzones already uses new semantics,
|
|
|
e3ffab |
+ # no upgrade is required
|
|
|
e3ffab |
+ return (False, False, [])
|
|
|
e3ffab |
+
|
|
|
e3ffab |
+ self.log.info('Updating forward zones')
|
|
|
e3ffab |
+ # update the DNSVersion, following upgrade can be executed only once
|
|
|
e3ffab |
+ container_entry.setdefault(
|
|
|
e3ffab |
+ 'ipaConfigString', []).append(u"DNSVersion 1")
|
|
|
e3ffab |
+ ldap.update_entry(container_entry)
|
|
|
e3ffab |
+
|
|
|
e3ffab |
+ # Updater in IPA version from 4.0 to 4.1.2 doesn't work well, this
|
|
|
e3ffab |
+ # should detect if update in past has been executed, and set proper
|
|
|
e3ffab |
+ # DNSVersion into LDAP
|
|
|
e3ffab |
+ try:
|
|
|
e3ffab |
+ fwzones = api.Command.dnsforwardzone_find()['result']
|
|
|
e3ffab |
+ except errors.NotFound:
|
|
|
e3ffab |
+ # No forwardzones found, update probably has not been executed yet
|
|
|
e3ffab |
+ pass
|
|
|
e3ffab |
+ else:
|
|
|
e3ffab |
+ if fwzones:
|
|
|
e3ffab |
+ # fwzones exist, do not execute upgrade again
|
|
|
e3ffab |
+ return (False, False, [])
|
|
|
e3ffab |
+
|
|
|
e3ffab |
try:
|
|
|
e3ffab |
# raw values are required to store into ldif
|
|
|
e3ffab |
zones = api.Command.dnszone_find(all=True,
|
|
|
e3ffab |
@@ -345,9 +351,6 @@ class update_master_to_dnsforwardzones(PostUpdate):
|
|
|
e3ffab |
self.log.info('Zone %s was sucessfully transformed to forward zone',
|
|
|
e3ffab |
zone['idnsname'][0])
|
|
|
e3ffab |
|
|
|
e3ffab |
-
|
|
|
e3ffab |
- sysupgrade.set_upgrade_state('dns', 'update_to_forward_zones', False)
|
|
|
e3ffab |
-
|
|
|
e3ffab |
return (False, False, [])
|
|
|
e3ffab |
|
|
|
e3ffab |
api.register(update_master_to_dnsforwardzones)
|
|
|
e3ffab |
--
|
|
|
e3ffab |
2.1.0
|
|
|
e3ffab |
|