Bug 37665 - traceback when logging attributes: TypeError: must be string without null bytes, not str
traceback when logging attributes: TypeError: must be string without null by...
Status: RESOLVED DUPLICATE of bug 42114
Product: UCS
Classification: Unclassified
Component: UMC - Users
UCS 4.0
Other Linux
: P5 normal (vote)
: UCS 4.0-x
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-02-02 09:14 CET by Florian Best
Modified: 2016-09-13 13:52 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): Error handling, External feedback
Max CVSS v3 score:


Attachments
patch for sanitizing input before logging (9.35 KB, patch)
2015-02-17 14:00 CET, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2015-02-02 09:14:18 CET
4.0-0 errata66 (Walle)

Traceback:
Die Ausführung des Kommandos udm/put users/user ist fehlgeschlagen:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/management/console/modules/__init__.py",
line 176, in _decorated
    return function(self, request, *args, **kwargs)
  File "/usr/lib/pymodules/python2.7/notifier/threads.py", line 82, in _run
    tmp = self._function()
  File "/usr/lib/pymodules/python2.7/notifier/__init__.py", line 104, in __call__
    return self._function( *tmp, **self._kwargs )
  File
"/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/__init__.py", line
408, in _thread
    module.modify(properties)
  File
"/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/udm_ldap.py", line
159, in _decorated
    return func(*args, **kwargs)
  File
"/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/udm_ldap.py", line
139, in wrapper_func
    ret = func(*args, **kwargs)
  File
"/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/udm_ldap.py", line
545, in modify
    self._map_properties(obj, ldap_object)
  File
"/usr/lib/pymodules/python2.7/univention/management/console/modules/udm/udm_ldap.py", line
404, in _map_properties
    MODULE.info('Setting property %s to %s' % (property_name, value))
  File "/usr/lib/pymodules/python2.7/univention/management/console/log.py", line 148, in
info
    ud.debug(self._id, ud.INFO, message)
  File "/usr/lib/pymodules/python2.7/univention/debug.py", line 49, in debug
    _debug.debug(id, level, ustring)
TypeError: must be string without null bytes, not str


Remark:
unter Konto - Windows einen Laufwerkbuchstaben (P:) für das Heimatverzeichnis und den Pfad
zum Heimatverzeichnis (\\ucs\mr) eingetragen

Remark:
Versuch einem Benutzer ein Windows-Profile-UNC-Pfad hinzuzufügen
Comment 1 Florian Best univentionstaff 2015-02-02 09:58:50 CET
Got more feedback:
ich habe noch eine kleine Anmerkung zu dem Fehler ...
Ich hatte die Pfadfreigabe aus der Explorer-Adressleiste aus Windows per Copy'n'Paste in das Feld übertragen und damit den Fehler produzieren können.

Als ich dann einen halben Tag später das Ganze noch einmal testen wollte trug ich den Pfad manuell ein und es funktionierte.
Keine Ahnung, was da in der Zwischenablage für ein Fehler drin war, aber diese Info wollte ich auf jeden Fall noch mitteilen, damit nicht an einer falschen Stelle nach einem möglichen Fehler gesucht wird.

Passieren sollte so etwas aber natürlich trotzdem nicht :-)
Comment 2 Florian Best univentionstaff 2015-02-02 10:00:12 CET
From the feedback I would say that he copied some nullbytes and this was sent to the backend. univention-debug ofc. raises when it gets nullbytes.
Comment 3 Florian Best univentionstaff 2015-02-17 14:00:12 CET
Created attachment 6681 [details]
patch for sanitizing input before logging

As first step we should not allow user input to crash the module by replacing the logentries %s by %r.
After this the user should receive the correct error message from the syntax class telling him that the entered value is invalid.
Comment 4 Florian Best univentionstaff 2016-09-13 13:52:10 CEST
TypeError is now catched and the logging is re-done with repr() to increase security.

*** This bug has been marked as a duplicate of bug 42114 ***