diff options
author | Tomas Babej <tbabej@redhat.com> | 2014-09-17 17:17:54 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2014-09-29 15:24:58 +0200 |
commit | d83af7d38d65dfc50c70cb4ecf48f5c4c57d6979 (patch) | |
tree | 9c796262a3987c53e44c9d6983ece7864d4bf698 /ipalib/plugins/baseldap.py | |
parent | f8f3d5868820136422c63f80540f1e1ff5387861 (diff) | |
download | freeipa-d83af7d38d65dfc50c70cb4ecf48f5c4c57d6979.tar.gz freeipa-d83af7d38d65dfc50c70cb4ecf48f5c4c57d6979.tar.xz freeipa-d83af7d38d65dfc50c70cb4ecf48f5c4c57d6979.zip |
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
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipalib/plugins/baseldap.py')
-rw-r--r-- | ipalib/plugins/baseldap.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 26b43b90d..e589a5321 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 |