summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2010-05-10 14:48:48 +0200
committerRob Crittenden <rcritten@redhat.com>2010-05-14 11:07:10 -0400
commit64490a3ee08729c5739c0e84b0b50b8ae0e376d3 (patch)
tree1861721842f9aec45058eb9e821a95436b1eccc9 /ipalib
parent7993719329c675d8227bc612a2f8f0db5523c073 (diff)
downloadfreeipa-64490a3ee08729c5739c0e84b0b50b8ae0e376d3.tar.gz
freeipa-64490a3ee08729c5739c0e84b0b50b8ae0e376d3.tar.xz
freeipa-64490a3ee08729c5739c0e84b0b50b8ae0e376d3.zip
Correctly handle EmptyModlist exception in pwpolicy2-mod.
EmptyModlist exception was generated by pwpolicy2-mod when modifying policy priority only. It was because the priority attribute is stored outside of the policy entry (in a CoS entry) and there was nothing left to be changed in the policy entry. This patch uses the new exception callbacks in baseldap.py classes to catch the EmptyModlist exception and checks if there was really nothing to be modified before reraising the exception.
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/pwpolicy2.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/ipalib/plugins/pwpolicy2.py b/ipalib/plugins/pwpolicy2.py
index 797c0810..d6722927 100644
--- a/ipalib/plugins/pwpolicy2.py
+++ b/ipalib/plugins/pwpolicy2.py
@@ -276,12 +276,19 @@ class pwpolicy2_mod(LDAPUpdate):
def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
if not options.get('raw', False):
if options.get('cospriority') is not None:
- entry_attrs['cospriority'] = [unicode(options['copriority'])]
+ entry_attrs['cospriority'] = [unicode(options['cospriority'])]
if keys[-1] is None:
entry_attrs['cn'] = GLOBAL_POLICY_NAME
self.obj.convert_time_for_output(entry_attrs, **options)
return dn
+ def exc_callback(self, keys, options, exc, call_func, *call_args, **call_kwargs):
+ if isinstance(exc, errors.EmptyModlist):
+ entry_attrs = call_args[1]
+ if not entry_attrs and 'cospriority' in options:
+ return
+ raise exc
+
api.register(pwpolicy2_mod)
@@ -340,12 +347,13 @@ class pwpolicy2_find(LDAPSearch):
except errors.NotFound:
pass
self.obj.convert_time_for_output(e[1], **options)
- global_entry = self.api.Command.pwpolicy2_show(
- all=options.get('all', False), raw=options.get('raw', False)
- )['result']
- dn = global_entry['dn']
- del global_entry['dn']
- entries.insert(0, (dn, global_entry))
+ if not args[-1]:
+ global_entry = self.api.Command.pwpolicy2_show(
+ all=options.get('all', False), raw=options.get('raw', False)
+ )['result']
+ dn = global_entry['dn']
+ del global_entry['dn']
+ entries.insert(0, (dn, global_entry))
api.register(pwpolicy2_find)