Bug 32787 - UMC-Server: crash with UnicodeEncodeError while dumping ACLs to file
UMC-Server: crash with UnicodeEncodeError while dumping ACLs to file
Status: RESOLVED WORKSFORME
Product: UCS
Classification: Unclassified
Component: UMC (Generic)
UCS 3.1
Other Linux
: P5 normal (vote)
: UCS 3.2-x
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-02 07:24 CEST by Stefan Gohmann
Modified: 2017-06-19 13:16 CEST (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):
Max CVSS v3 score:
best: Patch_Available+


Attachments
UMC Server patch (726 bytes, patch)
2013-10-23 16:06 CEST, Florian Best
Details | Diff
patch without side effects on type of attributes (858 bytes, patch)
2014-02-04 21:53 CET, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Gohmann univentionstaff 2013-10-02 07:24:11 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.
Comment 1 Florian Best univentionstaff 2013-10-23 16:06:07 CEST
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).
Comment 2 Florian Best univentionstaff 2014-02-04 21:53:57 CET
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.
Comment 3 Stefan Gohmann univentionstaff 2017-06-16 20:38:10 CEST
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.
Comment 4 Florian Best univentionstaff 2017-06-19 13:16:04 CEST
I tested this, didn't occur again. Therefore reverted ucs-test:

r80290 | Bug #32787: revert svn r44669