Hi, 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 -- Tomas Babej Associate Software Engineer | Red Hat | Identity Management RHCE | Brno Site | IRC: tbabej | freeipa.org
>From 877c273784a2c8d6ff2b2a312e7256fff928e684 Mon Sep 17 00:00:00 2001 From: Tomas Babej <tba...@redhat.com> Date: Wed, 17 Sep 2014 17:17:54 +0200 Subject: [PATCH] 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 --- ipalib/plugins/baseldap.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index a3cfe3ce33ffd999ea725cdf72bcf82cb11d5c84..13487aa9bc9d2e780fe8afbac86c25c822d23216 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 -- 1.9.3
_______________________________________________ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel