Univention Bugzilla – Bug 32787
UMC-Server: crash with UnicodeEncodeError while dumping ACLs to file
Last modified: 2017-06-19 13:16:04 CEST
The following error occurred from time to time with the test case 60_umc/03_acls: 02.10.13 01:10:12.250 MAIN ( ERROR ) : Traceback (most recent call last): File "/usr/sbin/univention-management-console-server", line 209, in <module> umc_daemon.do_action() File "/usr/lib/pymodules/python2.6/daemon/runner.py", line 186, in do_action func(self) File "/usr/lib/pymodules/python2.6/daemon/runner.py", line 131, in _start self.app.run() File "/usr/sbin/univention-management-console-server", line 192, in run notifier.loop() File "/usr/lib/pymodules/python2.6/notifier/nf_generic.py", line 284, in loop step() File "/usr/lib/pymodules/python2.6/notifier/nf_generic.py", line 271, in step not __sockets[ cond ][ fd ]( sock_obj ): File "/usr/lib/pymodules/python2.6/univention/management/console/protocol/server.py", line 165, in _receive self._handle( state, msg ) File "/usr/lib/pymodules/python2.6/univention/management/console/protocol/server.py", line 279, in _handle state.processor = Processor( *state.credentials() ) File "/usr/lib/pymodules/python2.6/univention/management/console/protocol/session.py", line 216, in __init__ self.acls = LDAP_ACLs( self.lo, self.__username, ucr[ 'ldap/base' ] ) File "/usr/lib/pymodules/python2.6/univention/management/console/acl.py", line 348, in __init__ self._write_to_file( self.username ) File "/usr/lib/pymodules/python2.6/univention/management/console/acl.py", line 324, in _write_to_file file = os.open( filename, os.O_WRONLY | os.O_TRUNC | os.O_CREAT, 0600 ) UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 46: ordinal not in range(128) If the bug has fixed r44669 in ucs-test should be reverted.
Created attachment 5529 [details] UMC Server patch The UMC Server crashes while trying to write the ACL's for a USER into a file. acl.py 323 » » filename = os.path.join( ACLs.CACHE_DIR, username ) 324 325 » » file = os.open( filename, os.O_WRONLY | os.O_TRUNC | os.O_CREAT, 0600 ) username in this case is probably an unicode object instead of bytes (str). This only happens when: 281 » » » if not state.processor: 282 » » » » state.processor = Processor( *state.credentials() ) I tried to reproduce but could not (works probably only with the first request to the umc server). Would be nice to see what jenkins (the running UMC server process) returns for locale.getdefaultlocale(). The attached patch should fix this, but i am not sure what impact this have because __username and __password for every module and every UMC Server process is then a bytes/Str instance instead of an unicode instance if the string contains umlauts (because the builtin json lib returns sometimes bytes and sometimes unicode).
Created attachment 5775 [details] patch without side effects on type of attributes It's better to not modify the type of the username attribute, this could have side effects in the modules / elsewhere. This patch only encodes the attributes if they are unicode.
This issue has been filed against UCS 3. UCS 3 is out of the normal maintenance and many UCS components have vastly changed in UCS 4. If this issue is still valid, please change the version to a newer UCS version otherwise this issue will be automatically closed in the next weeks.
I tested this, didn't occur again. Therefore reverted ucs-test: r80290 | Bug #32787: revert svn r44669