Univention Bugzilla – Bug 38616
_err2str fails if ldap exception is not a dict
Last modified: 2015-07-03 14:10:26 CEST
Created attachment 6926 [details] patch We received the following traceback, 4.0-2 errata194 (Walle): Die Ausführung des Kommandos udm/syntax/choices/info users/user ist fehlgeschlagen: Traceback (most recent call last): File "%PY2.7%/univention/management/console/modules/__init__.py", line 176, in _decorated return function(self, request, *args, **kwargs) File "%PY2.7%/univention/management/console/modules/decorators.py", line 316, in _response result = _multi_response(self, request) File "%PY2.7%/univention/management/console/modules/decorators.py", line 460, in _response return list(function(self, iterator, *nones)) File "%PY2.7%/univention/management/console/modules/decorators.py", line 282, in _fake_func yield function(self, *args) File "%PY2.7%/univention/management/console/modules/udm/__init__.py", line 923, in syntax_choices_info return info_syntax_choices(syntax) File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 1315, in info_syntax_choices size += len(module.search(filter=filter_s, simple=not syn.use_objects)) File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 163, in _decorated return func(*args, **kwargs) File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 146, in wrapper_func return _func(*args, **kwargs) File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 139, in _func ret = func(*args, **kwargs) File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 582, in search result = self.module.lookup(None, ldap_connection, filter_s, base=container, superordinate=superordinate, scope=scope, sizelimit=sizelimit) File "%PY2.7%/univention/admin/handlers/computers/computer.py", line 175, in lookup res.extend( computer.lookup(co, lo, filter_s, base, superordinate, scope, unique, required, timeout, sizelimit) ) File "%PY2.7%/univention/admin/handlers/computers/memberserver.py", line 721, in lookup for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit): File "%PY2.7%/univention/admin/uldap.py", line 358, in search raise univention.admin.uexceptions.ldapError(_err2str(msg), original_exception=msg) File "%PY2.7%/univention/admin/uldap.py", line 82, in _err2str msg = ': '.join([str(m) for m in (iarg.get('desc'), iarg.get('info')) if m]) AttributeError: 'str' object has no attribute 'get' Remark: Benutzer aufgerufen I had a quick look into python-ldap. There are some exceptions which doesn't have a dict as argument. Instead exceptions are raised with a string: ./controls/__init__.py: raise ldap.UNAVAILABLE_CRITICAL_EXTENSION('Received unexpected critical response control with controlType %s' % (repr(controlType))) ./ldapobject.py: raise ldap.PROTOCOL_ERROR("Wrong OID in extended response! Expected %s, got %s" % (extop_resp_class.responseName,respoid)) ./ldapobject.py: raise NO_UNIQUE_ENTRY('No or non-unique search result for %s' % (repr(filterstr))) ./ldapobject.py: raise ldap.TIMEOUT( "LDAP time limit (%d secs) exceeded." % (timeout) ) Attached is a patch which fixes it.
python-ldap violates it's own documentation here: http://python-ldap.org/doc/html/ldap.html#exceptions
Previously: >>> import ldap >>> from univention.admin.uldap import _err2str >>> _err2str(ldap.TIMEOUT("LDAP time limit (%d secs) exceeded.")) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/pymodules/python2.7/univention/admin/uldap.py", line 82, in _err2str msg = ': '.join([str(m) for m in (iarg.get('desc'), iarg.get('info')) if m]) AttributeError: 'str' object has no attribute 'get' Afterwards: >>> import ldap >>> from univention.admin.uldap import _err2str >>> _err2str(ldap.TIMEOUT("LDAP time limit (%d secs) exceeded.")) 'LDAP time limit (%d secs) exceeded.' Fix: svn r60938 YAML: 2015-05-28-univention-directory-manager-modules.yaml
Fix: OK YAML: OK
Reported again, (from intern/support?), 4.0-2 errata194 (Walle)
Reported again, 4.0-2 errata213 (Walle)
<http://errata.univention.de/ucs/4.0/217.html>