|
|
0201d8 |
From 9b01d87626de2c5a0cb9b5e0d10959b13f03fbba Mon Sep 17 00:00:00 2001
|
|
|
0201d8 |
From: Martin Basti <mbasti@redhat.com>
|
|
|
0201d8 |
Date: Thu, 15 Jan 2015 13:13:55 +0100
|
|
|
0201d8 |
Subject: [PATCH] Always return absolute idnsname in dnszone commands
|
|
|
0201d8 |
|
|
|
0201d8 |
Ticket: https://fedorahosted.org/freeipa/ticket/4722
|
|
|
0201d8 |
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
|
|
|
0201d8 |
---
|
|
|
0201d8 |
ipalib/plugins/dns.py | 36 ++++++++++++++++++++++++++++++++++--
|
|
|
0201d8 |
1 file changed, 34 insertions(+), 2 deletions(-)
|
|
|
0201d8 |
|
|
|
0201d8 |
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
|
|
|
0201d8 |
index 34afc189866993481229bb68a5edd77e0a4eaff3..ea4c212b42631e8513a13d2a7f5a859b2176376b 100644
|
|
|
0201d8 |
--- a/ipalib/plugins/dns.py
|
|
|
0201d8 |
+++ b/ipalib/plugins/dns.py
|
|
|
0201d8 |
@@ -1848,6 +1848,18 @@ class DNSZoneBase(LDAPObject):
|
|
|
0201d8 |
except errors.NotFound:
|
|
|
0201d8 |
raise e # re-raise original exception
|
|
|
0201d8 |
|
|
|
0201d8 |
+ def _make_zonename_absolute(self, entry_attrs, **options):
|
|
|
0201d8 |
+ """
|
|
|
0201d8 |
+ Zone names can be relative in IPA < 4.0, make sure we always return
|
|
|
0201d8 |
+ absolute zone name from ldap
|
|
|
0201d8 |
+ """
|
|
|
0201d8 |
+ if options.get('raw'):
|
|
|
0201d8 |
+ return
|
|
|
0201d8 |
+
|
|
|
0201d8 |
+ if "idnsname" in entry_attrs:
|
|
|
0201d8 |
+ entry_attrs.single_value['idnsname'] = (
|
|
|
0201d8 |
+ entry_attrs.single_value['idnsname'].make_absolute())
|
|
|
0201d8 |
+
|
|
|
0201d8 |
|
|
|
0201d8 |
class DNSZoneBase_add(LDAPCreate):
|
|
|
0201d8 |
|
|
|
0201d8 |
@@ -1895,6 +1907,11 @@ class DNSZoneBase_del(LDAPDelete):
|
|
|
0201d8 |
class DNSZoneBase_mod(LDAPUpdate):
|
|
|
0201d8 |
has_output_params = LDAPUpdate.has_output_params + dnszone_output_params
|
|
|
0201d8 |
|
|
|
0201d8 |
+ def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
|
|
|
0201d8 |
+ assert isinstance(dn, DN)
|
|
|
0201d8 |
+ self.obj._make_zonename_absolute(entry_attrs, **options)
|
|
|
0201d8 |
+ return dn
|
|
|
0201d8 |
+
|
|
|
0201d8 |
|
|
|
0201d8 |
class DNSZoneBase_find(LDAPSearch):
|
|
|
0201d8 |
__doc__ = _('Search for DNS zones (SOA records).')
|
|
|
0201d8 |
@@ -1929,6 +1946,11 @@ class DNSZoneBase_find(LDAPSearch):
|
|
|
0201d8 |
filter = _create_idn_filter(self, ldap, *args, **options)
|
|
|
0201d8 |
return (filter, base_dn, scope)
|
|
|
0201d8 |
|
|
|
0201d8 |
+ def post_callback(self, ldap, entries, truncated, *args, **options):
|
|
|
0201d8 |
+ for entry_attrs in entries:
|
|
|
0201d8 |
+ self.obj._make_zonename_absolute(entry_attrs, **options)
|
|
|
0201d8 |
+ return truncated
|
|
|
0201d8 |
+
|
|
|
0201d8 |
|
|
|
0201d8 |
class DNSZoneBase_show(LDAPRetrieve):
|
|
|
0201d8 |
has_output_params = LDAPRetrieve.has_output_params + dnszone_output_params
|
|
|
0201d8 |
@@ -1939,6 +1961,11 @@ class DNSZoneBase_show(LDAPRetrieve):
|
|
|
0201d8 |
self.obj.handle_not_found(*keys)
|
|
|
0201d8 |
return dn
|
|
|
0201d8 |
|
|
|
0201d8 |
+ def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
|
|
|
0201d8 |
+ assert isinstance(dn, DN)
|
|
|
0201d8 |
+ self.obj._make_zonename_absolute(entry_attrs, **options)
|
|
|
0201d8 |
+ return dn
|
|
|
0201d8 |
+
|
|
|
0201d8 |
|
|
|
0201d8 |
class DNSZoneBase_disable(LDAPQuery):
|
|
|
0201d8 |
has_output = output.standard_value
|
|
|
0201d8 |
@@ -2539,7 +2566,8 @@ class dnszone_mod(DNSZoneBase_mod):
|
|
|
0201d8 |
return result
|
|
|
0201d8 |
|
|
|
0201d8 |
def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
|
|
|
0201d8 |
- assert isinstance(dn, DN)
|
|
|
0201d8 |
+ dn = super(dnszone_mod, self).post_callback(ldap, dn, entry_attrs,
|
|
|
0201d8 |
+ *keys, **options)
|
|
|
0201d8 |
self.obj._rr_zone_postprocess(entry_attrs, **options)
|
|
|
0201d8 |
return dn
|
|
|
0201d8 |
|
|
|
0201d8 |
@@ -2576,6 +2604,9 @@ class dnszone_find(DNSZoneBase_find):
|
|
|
0201d8 |
return (filter, base_dn, scope)
|
|
|
0201d8 |
|
|
|
0201d8 |
def post_callback(self, ldap, entries, truncated, *args, **options):
|
|
|
0201d8 |
+ truncated = super(dnszone_find, self).post_callback(ldap, entries,
|
|
|
0201d8 |
+ truncated, *args,
|
|
|
0201d8 |
+ **options)
|
|
|
0201d8 |
for entry_attrs in entries:
|
|
|
0201d8 |
self.obj._rr_zone_postprocess(entry_attrs, **options)
|
|
|
0201d8 |
return truncated
|
|
|
0201d8 |
@@ -2592,7 +2623,8 @@ class dnszone_show(DNSZoneBase_show):
|
|
|
0201d8 |
return result
|
|
|
0201d8 |
|
|
|
0201d8 |
def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
|
|
|
0201d8 |
- assert isinstance(dn, DN)
|
|
|
0201d8 |
+ dn = super(dnszone_show, self).post_callback(ldap, dn, entry_attrs,
|
|
|
0201d8 |
+ *keys, **options)
|
|
|
0201d8 |
self.obj._rr_zone_postprocess(entry_attrs, **options)
|
|
|
0201d8 |
return dn
|
|
|
0201d8 |
|
|
|
0201d8 |
--
|
|
|
0201d8 |
2.1.0
|
|
|
0201d8 |
|