diff options
author | Rob Crittenden <rcritten@redhat.com> | 2008-02-11 16:32:54 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2008-02-11 16:32:54 -0500 |
commit | 73a674ed497c8f39c9c2aa9d352b20cb1d95abd9 (patch) | |
tree | ce907d41a396b0ab5a066933f044c4992a3c2cbe | |
parent | 5b1e7e3a5f65d193f850e2b282c611e9e2541b5c (diff) | |
download | freeipa-73a674ed497c8f39c9c2aa9d352b20cb1d95abd9.tar.gz freeipa-73a674ed497c8f39c9c2aa9d352b20cb1d95abd9.tar.xz freeipa-73a674ed497c8f39c9c2aa9d352b20cb1d95abd9.zip |
Fix bug that prevented single-character fields
Fix bug in exception handling where we were sending the wrong thing as detail.
Basically we were catching an LDAP error, generating an IPAError from it,
catching that, then setting the detail of the 2nd exception to another IPAError
rather than the root exception. This caused anything looking at e.detail to
crap out
Resolves 432136
-rw-r--r-- | ipa-server/xmlrpc-server/funcs.py | 10 | ||||
-rw-r--r-- | ipa-server/xmlrpc-server/ipaxmlrpc.py | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py index cc2705d24..7634b5951 100644 --- a/ipa-server/xmlrpc-server/funcs.py +++ b/ipa-server/xmlrpc-server/funcs.py @@ -486,7 +486,7 @@ class IPAServer: # get to LDAP, like: # TypeError: ('expected a string in the list', None) for k in user.keys(): - if not user[k] or len(user[k]) == 0 or (len(user[k]) == 1 and '' in user[k]): + if not user[k] or len(user[k]) == 0 or (isinstance(user[k],list) and len(user[k]) == 1 and '' in user[k]): del user[k] dn="uid=%s,%s,%s" % (ldap.dn.escape_dn_chars(user['uid']), @@ -516,6 +516,8 @@ class IPAServer: default_group = self.get_entry_by_dn(group_dn, ['dn','gidNumber'], opts) if default_group: user['gidnumber'] = default_group.get('gidnumber') + except ipaerror.exception_for(ipaerror.LDAP_DATABASE_ERROR), e: + raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, message=None, nested_exception=e.detail) except ipaerror.exception_for(ipaerror.LDAP_DATABASE_ERROR): # Fake an LDAP error so we can return something useful to the user raise ipaerror.gen_exception(ipaerror.LDAP_NOT_FOUND, "No default group for new users can be found.") @@ -545,10 +547,14 @@ class IPAServer: res = conn.addEntry(entry) except TypeError, e: raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, "There is a problem with one of the data types.") + except ipaerror.exception_for(ipaerror.LDAP_DATABASE_ERROR), e: + raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, message=None, nested_exception=e.detail) except Exception, e: - raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, e) + raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, nested_exception=e) try: self.add_user_to_group(user.get('uid'), group_dn, opts) + except ipaerror.exception_for(ipaerror.LDAP_DATABASE_ERROR), e: + raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, message=None, nested_exception=e.detail) except Exception, e: raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, "The user was created but adding to group %s failed" % group_dn) finally: diff --git a/ipa-server/xmlrpc-server/ipaxmlrpc.py b/ipa-server/xmlrpc-server/ipaxmlrpc.py index 59f5e596c..0634f59ac 100644 --- a/ipa-server/xmlrpc-server/ipaxmlrpc.py +++ b/ipa-server/xmlrpc-server/ipaxmlrpc.py @@ -175,8 +175,8 @@ class ModXMLRPCRequestHandler(object): except ipaerror.IPAError, e: self.traceback = True - if (isinstance(e.detail, ldap.LDAPError)): - err = ": %s: %s" % (e.detail.args[0]['desc'], e.detail.args[0].get('info','')) + if (isinstance(e.detail, ldap.LDAPError)) and len(e.detail[0].get('desc') > 1): + err = ": %s: %s" % (e.detail[0].get('desc'), e.detail[0].get('info','')) response = dumps(Fault(e.code, str(e) + err)) else: response = dumps(Fault(e.code, str(e))) |