URL: https://github.com/freeipa/freeipa/pull/1335 Author: tiran Title: #1335: [Backport][ipa-4-6] Fix dnsrecord_show for structured record Action: opened
PR body: """ This PR was opened automatically because PR #1324 was pushed to master and backport to ipa-4-6 is required. """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/1335/head:pr1335 git checkout pr1335
From e0c5c2a86d2dc45ec1a5436dc0e4be7e02692dbb Mon Sep 17 00:00:00 2001 From: Christian Heimes <chei...@redhat.com> Date: Wed, 22 Nov 2017 17:30:58 +0100 Subject: [PATCH 1/2] Reproducer for bug in structured dnsrecord_show "RuntimeError: dictionary changed size during iteration" in ipaserver/plugins/dns.py", line 3209, in postprocess_record https://pagure.io/freeipa/issue/7275 Signed-off-by: Christian Heimes <chei...@redhat.com> --- ipatests/test_xmlrpc/test_dns_plugin.py | 57 +++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py index 68d7c4ae29..9fd5266e58 100644 --- a/ipatests/test_xmlrpc/test_dns_plugin.py +++ b/ipatests/test_xmlrpc/test_dns_plugin.py @@ -268,6 +268,7 @@ arec1 = u'172.16.29.111' arec2 = u'172.31.254.222' arec3 = u'172.16.250.123' +aaaarec1 = u'ff02::1' fwd_ip = u'172.16.31.80' allowtransfer_tofwd = u'%s;' % fwd_ip @@ -1087,18 +1088,43 @@ def setup_class(cls): dict( desc='Modify AAAA record in %r in zone %r' % (name1, zone1), - command=('dnsrecord_mod', [zone1, name1], {'aaaarecord': u'ff02::1'}), + command=( + 'dnsrecord_mod', [zone1, name1], {'aaaarecord': aaaarec1} + ), expected={ 'value': name1_dnsname, 'summary': None, 'result': { 'idnsname': [name1_dnsname], 'arecord': [arec3], - 'aaaarecord': [u'ff02::1'], + 'aaaarecord': [aaaarec1], }, }, ), + dict( + desc=('Show record %r in zone %r with --structured and --all ' + 'options' % (name1, zone1)), + command=('dnsrecord_show', [zone1, name1], + {'structured': True, 'all': True}), + expected={ + 'value': name1_dnsname, + 'summary': None, + 'result': { + 'dn': name1_dn, + 'idnsname': [name1_dnsname], + 'objectclass': objectclasses.dnsrecord, + 'dnsrecords': [ + {u'aaaa_part_ip_address': aaaarec1, + u'dnsdata': aaaarec1, + u'dnstype': u'AAAA'}, + {u'a_part_ip_address': arec3, + u'dnsdata': arec3, + u'dnstype': u'A'} + ], + }, + }, + ), dict( desc='Remove AAAA record from %r in zone %r using dnsrecord_mod' % (name1, zone1), @@ -2846,6 +2872,33 @@ def setup_class(cls): }, ), + dict( + desc='Show structured record %r in zone %r' % ( + u'_foo._tcp', idnzone1 + ), + command=( + 'dnsrecord_show', [idnzone1, u'_foo._tcp'], + {u'structured': True, u'all': True} + ), + expected={ + 'value': DNSName(u'_foo._tcp'), + 'summary': None, + 'result': { + 'dn': DN(('idnsname', u'_foo._tcp'), idnzone1_dn), + 'idnsname': [DNSName(u'_foo._tcp')], + 'dnsrecords': [{ + u'dnsdata': u'0 100 1234 {}'.format( + idnzone1_mname_punycoded), + u'dnstype': u'SRV', + u'srv_part_port': u'1234', + u'srv_part_priority': u'0', + u'srv_part_target': idnzone1_mname, + u'srv_part_weight': u'100' + }], + 'objectclass': objectclasses.dnsrecord, + }, + }, + ), dict( desc='Add AFSDB record to %r using dnsrecord_add' % (dnsafsdbres1), From 45ffb49c1d1d213ff31a9ab68c4d6e116e7fcb83 Mon Sep 17 00:00:00 2001 From: Christian Heimes <chei...@redhat.com> Date: Wed, 22 Nov 2017 20:34:57 +0100 Subject: [PATCH 2/2] Fix dict iteration bug in dnsrecord_show In structured mode, dict size is modified by del record[attr]. https://pagure.io/freeipa/issue/7275 Signed-off-by: Christian Heimes <chei...@redhat.com> --- ipaserver/plugins/dns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipaserver/plugins/dns.py b/ipaserver/plugins/dns.py index 1d69cede01..21af740955 100644 --- a/ipaserver/plugins/dns.py +++ b/ipaserver/plugins/dns.py @@ -3206,7 +3206,7 @@ def get_record_entry_attrs(self, entry_attrs): def postprocess_record(self, record, **options): if options.get('structured', False): - for attr in record.keys(): + for attr in tuple(record.keys()): # attributes in LDAPEntry may not be normalized attr = attr.lower() try:
_______________________________________________ FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org