summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2014-09-17 17:17:54 +0200
committerTomas Babej <tbabej@redhat.com>2014-09-22 12:00:13 +0200
commit8ddca01335cd21ac5550fe64ef062e412437c017 (patch)
treea46450181c0b6d5a7ab9be371a9b5b78e09b6338
parentaedefaae4fe2c76cd6353189e5e265644b528b59 (diff)
downloadfreeipa-8ddca01335cd21ac5550fe64ef062e412437c017.zip
freeipa-8ddca01335cd21ac5550fe64ef062e412437c017.tar.gz
freeipa-8ddca01335cd21ac5550fe64ef062e412437c017.tar.xz
baseldap: Properly handle the case of renaming object to the same name
When renaming a object to the same name, errors.EmptyModList is raised. This is not properly handled, and can cause other modifications in the LDAPUpdate command to be ignored. https://fedorahosted.org/freeipa/ticket/4548
-rw-r--r--ipalib/plugins/baseldap.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index a3cfe3c..13487aa 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -1398,16 +1398,23 @@ class LDAPUpdate(LDAPQuery, crud.Update):
entry_attrs[self.obj.primary_key.name] = options['rename']
if self.obj.rdn_is_primary_key and self.obj.primary_key.name in entry_attrs:
- # RDN change
- self._exc_wrapper(keys, options, ldap.update_entry_rdn)(
- entry_attrs.dn,
- RDN((self.obj.primary_key.name,
- entry_attrs[self.obj.primary_key.name])))
- rdnkeys = keys[:-1] + (entry_attrs[self.obj.primary_key.name], )
- entry_attrs.dn = self.obj.get_dn(*rdnkeys)
- del entry_attrs[self.obj.primary_key.name]
- options['rdnupdate'] = True
- rdnupdate = True
+ try:
+ # RDN change
+ self._exc_wrapper(keys, options, ldap.update_entry_rdn)(
+ entry_attrs.dn,
+ RDN((self.obj.primary_key.name,
+ entry_attrs[self.obj.primary_key.name])))
+
+ rdnkeys = keys[:-1] + (entry_attrs[self.obj.primary_key.name], )
+ entry_attrs.dn = self.obj.get_dn(*rdnkeys)
+ options['rdnupdate'] = True
+ rdnupdate = True
+ except errors.EmptyModlist:
+ # Attempt to rename to the current name, ignore
+ pass
+ finally:
+ # Delete the primary_key from entry_attrs either way
+ del entry_attrs[self.obj.primary_key.name]
# Exception callbacks will need to test for options['rdnupdate']
# to decide what to do. An EmptyModlist in this context doesn't