Bug 41384 - broken code in ucs-school-user-logonscript.py
Summary: broken code in ucs-school-user-logonscript.py
Status: CLOSED DUPLICATE of bug 41304
Alias: None
Product: UCS@school
Classification: Unclassified
Component: Netlogon scripts
Version: UCS@school 4.1
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: Bugzilla Mailingliste
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-30 19:56 CEST by Florian Best
Modified: 2023-03-25 06:50 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Cleanup, Error handling, Troubleshooting
Customer ID:
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2016-05-30 19:56:40 CEST
364 class LDAPConnection(object):
…
391 »   def __exit__(self, exc_type, exc_value, traceback):
392 »   »   if exc_type is not None and isinstance(exc_type, type(ldap.LDAPError)):
393 »   »   »   LDAPConnection.lo = None
394 »   »   »   univention.debug.debug(univention.debug.LISTENER, univention.debug.ERROR, 'ucsschool-user-logonscripts: a LDAP error occurred - invalidating LDAP connection - error=%r' % (exc_value[0]['desc'],))

The check "isinstance(exc_type, type(ldap.LDAPError))" will never become true because type(ldap.LDAPError) is type and exc_type is always an instance of Exception.

Fix:
-               if exc_type is not None and isinstance(exc_type, type(ldap.LDAPError)):
+               if exc_type is not None and isinstance(exc_type, (ldap.LDAPError,)):
Comment 1 Florian Best univentionstaff 2016-05-30 20:01:06 CEST
s/never/always/
s/instance/subclass/
The check "isinstance(exc_type, type(ldap.LDAPError))" will always become true because type(ldap.LDAPError) is type and exc_type is always an subclass of Exception.

-               if exc_type is not None and isinstance(exc_type, type(ldap.LDAPError)):
+               if exc_type is not None and isinstance(exc_value, (ldap.LDAPError,)):
Comment 2 Florian Best univentionstaff 2016-06-16 12:46:17 CEST
I had to fix this bug as otherwise any error results in no script written at all.

*** This bug has been marked as a duplicate of bug 41304 ***
Comment 3 Daniel Tröder univentionstaff 2016-06-16 13:30:06 CEST
ACK: bug crashed script, was fixed.