Print expected error message in hbac-mod

This patch catches NotFound exception and calls handling function
which then sends exception with unified error message.

https://fedorahosted.org/freeipa/ticket/487
This commit is contained in:
Jan Zeleny 2010-12-10 19:15:53 +01:00 committed by Rob Crittenden
parent e8e274c9e0
commit 8fd288df08

View File

@ -231,7 +231,11 @@ class hbac_mod(LDAPUpdate):
"""
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
(dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
try:
(dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
except errors.NotFound:
self.obj.handle_not_found(*keys)
if is_all(options, 'usercategory') and 'memberuser' in entry_attrs:
raise errors.MutuallyExclusiveError(reason="user category cannot be set to 'all' while there are allowed users")
if is_all(options, 'hostcategory') and 'memberhost' in entry_attrs: