Bug 17852 - Maskierungsprobleme in univention/admin/locking.py
Maskierungsprobleme in univention/admin/locking.py
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 2.3
Other Linux
: P5 normal (vote)
: UCS 2.3-2
Assigned To: Janek Walkenhorst
Felix Botner
:
: 11552 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-03-10 16:41 CET by Janek Walkenhorst
Modified: 2010-05-18 10:00 CEST (History)
2 users (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:


Attachments
Patch zur Behebung der Probleme (860 bytes, patch)
2010-03-10 16:41 CET, Janek Walkenhorst
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Janek Walkenhorst univentionstaff 2010-03-10 16:41:30 CET
Created attachment 2331 [details]
Patch zur Behebung der Probleme

Die Synchronisierungsmethoden in univention/admin/locking.py verwenden die
Funktion "lockDn" (aus der gleichen Datei)
Diese Funktion übernimmt die Argumente per String-Operationen direkt in den zu
erstellenden DN. Dementsprechend werden die Maskierungsregeln des
LDAP-Standards nicht befolgt.
Dies führt zum Beispiel zu Problemen mit dem Zeichen "+".

Es gibt Funktionen dafür von python-ldap: ("str2dn" und "dn2str")
http://www.python-ldap.org/doc/html/ldap-dn.html

Der angehängte Patch nutzt diese Funktionen um das Problem zu beheben.
Comment 1 Janek Walkenhorst univentionstaff 2010-03-10 17:30:04 CET
Zwei weitere mögliche Probleme in univention/admin/locking.py

Die Funktion "getLock" gibt 0 zurück, wenn kein Lock-Objekt existiert.
Wenn ein Lock-Objekt existiert, das keinen Timeout gesetzt hat, so wird auch 0 zurückgegeben.

Die Funktion "unlock" aus "univention/admin/locking.py" ignoriert die Meldung, dass das Objekt nicht gelöscht werden konnte:
  except ldap.NO_SUCH_OBJECT:
    pass
Der Fall sollte jedoch nicht auftreten. (Es sei denn ein Objekt wird mehrmals "unlock"t)
Es sollte geprüft werden, ob die Exception wirklich ignoriert, oder zumindest protokolliert werden sollte.
Comment 2 Stefan Gohmann univentionstaff 2010-03-11 06:49:56 CET
(In reply to comment #1)
> Zwei weitere mögliche Probleme in univention/admin/locking.py
> 
> Die Funktion "getLock" gibt 0 zurück, wenn kein Lock-Objekt existiert.
> Wenn ein Lock-Objekt existiert, das keinen Timeout gesetzt hat, so wird auch 0
> zurückgegeben.
> 
> Die Funktion "unlock" aus "univention/admin/locking.py" ignoriert die Meldung,
> dass das Objekt nicht gelöscht werden konnte:
>   except ldap.NO_SUCH_OBJECT:
>     pass
> Der Fall sollte jedoch nicht auftreten. (Es sei denn ein Objekt wird mehrmals
> "unlock"t)
> Es sollte geprüft werden, ob die Exception wirklich ignoriert, oder zumindest
> protokolliert werden sollte.

Die beiden bitte erstmal nicht im Rahmen des Bugs bearbeiten. 
Der erste Fall tritt nicht auf, da lockTime vom Schema her vorgegeben ist, es kann also kein Lock-Objekt ohne lockTime geben.
Beim zweiten Fall sollte die Meldung ignoriert werden, da die Module teilweise so implementiert wurden, so dass die lock-Objekte mehrfach freigegeben werden.
Comment 3 Janek Walkenhorst univentionstaff 2010-03-22 14:37:38 CET
Probleme auch mit Benutzernamen mit " oder ,

# udm users/user create --set username=foo\"bar --set lastname=lastname --set password=univention
Traceback (most recent call last):
  File "/usr/share/univention-directory-manager-tools/univention-cli-server", line 231, in doit
    output = univention.admincli.admin.doit(arglist)
  File "/usr/lib/python2.4/site-packages/univention/admincli/admin.py", line 740, in doit
    dn=object.create()
  File "/usr/lib/python2.4/site-packages/univention/admin/handlers/__init__.py", line 305, in create
    return self._create()
  File "/usr/lib/python2.4/site-packages/univention/admin/handlers/__init__.py", line 569, in _create
    al=self._ldap_addlist()
  File "/usr/lib/python2.4/site-packages/univention/admin/handlers/users/user.py", line 1965, in _ldap_addlist
    uid=univention.admin.allocators.request(self.lo, self.position, 'uid', value=self['username'])
  File "/usr/lib/python2.4/site-packages/univention/admin/allocators.py", line 165, in request
    return acquireUnique(lo, position, type, value, _type2attr[type], scope = _type2scope[type])
  File "/usr/lib/python2.4/site-packages/univention/admin/allocators.py", line 154, in acquireUnique
    univention.admin.locking.lock(lo, position, type, value, scope=scope)
  File "/usr/lib/python2.4/site-packages/univention/admin/locking.py", line 58, in lock
    if not lo.get(dn, ['lockTime']):
  File "/usr/lib/python2.4/site-packages/univention/admin/uldap.py", line 292, in get
    return self.lo.get(dn, attr, required)
  File "/usr/lib/python2.4/site-packages/univention/uldap.py", line 218, in get
    '(objectClass=*)',attr )
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 508, in search_s
    return self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,None,None,timeout=self.timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 502, in search_ext_s
    return self.result(msgid,all=1,timeout=timeout)[1]
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 428, in result
    res_type,res_data,res_msgid = self.result2(msgid,all,timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 432, in result2
    res_type, res_data, res_msgid, srv_ctrls = self.result3(msgid,all,timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 438, in result3
    ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 96, in _ldap_call
    result = func(*args,**kwargs)
INVALID_DN_SYNTAX: {'info': 'invalid DN', 'desc': 'Invalid DN syntax'}


# udm users/user create --set username=foo,bar --set lastname=lastname --set password=univention
Traceback (most recent call last):
  File "/usr/share/univention-directory-manager-tools/univention-cli-server", line 231, in doit
    output = univention.admincli.admin.doit(arglist)
  File "/usr/lib/python2.4/site-packages/univention/admincli/admin.py", line 740, in doit
    dn=object.create()
  File "/usr/lib/python2.4/site-packages/univention/admin/handlers/__init__.py", line 305, in create
    return self._create()
  File "/usr/lib/python2.4/site-packages/univention/admin/handlers/__init__.py", line 569, in _create
    al=self._ldap_addlist()
  File "/usr/lib/python2.4/site-packages/univention/admin/handlers/users/user.py", line 1965, in _ldap_addlist
    uid=univention.admin.allocators.request(self.lo, self.position, 'uid', value=self['username'])
  File "/usr/lib/python2.4/site-packages/univention/admin/allocators.py", line 165, in request
    return acquireUnique(lo, position, type, value, _type2attr[type], scope = _type2scope[type])
  File "/usr/lib/python2.4/site-packages/univention/admin/allocators.py", line 154, in acquireUnique
    univention.admin.locking.lock(lo, position, type, value, scope=scope)
  File "/usr/lib/python2.4/site-packages/univention/admin/locking.py", line 58, in lock
    if not lo.get(dn, ['lockTime']):
  File "/usr/lib/python2.4/site-packages/univention/admin/uldap.py", line 292, in get
    return self.lo.get(dn, attr, required)
  File "/usr/lib/python2.4/site-packages/univention/uldap.py", line 218, in get
    '(objectClass=*)',attr )
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 508, in search_s
    return self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,None,None,timeout=self.timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 502, in search_ext_s
    return self.result(msgid,all=1,timeout=timeout)[1]
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 428, in result
    res_type,res_data,res_msgid = self.result2(msgid,all,timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 432, in result2
    res_type, res_data, res_msgid, srv_ctrls = self.result3(msgid,all,timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 438, in result3
    ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 96, in _ldap_call
    result = func(*args,**kwargs)
INVALID_DN_SYNTAX: {'info': 'invalid DN', 'desc': 'Invalid DN syntax'}
Comment 4 Janek Walkenhorst univentionstaff 2010-03-29 13:32:37 CEST
Fixed:
Patch angewendet
SVN Revision 16019 16020

univention-directory-manager-modules (5.0.58-1) unstable; urgency=low

  * locking.py: properly escape lock name (Bug #17852)

Changelog:
\item Interne Locking-Funktionalität im Umgang mit Sonderzeichen verbessert. (\ucsBug{17852})


@QA: Dies sollte ausführlichst getestet werden
Comment 5 Felix Botner univentionstaff 2010-05-06 13:56:10 CEST
*** Bug 11552 has been marked as a duplicate of this bug. ***
Comment 6 Felix Botner univentionstaff 2010-05-06 15:37:54 CEST
ok, die locking DN's werden nun wenn nötig richtig maskiert angelegt.

udm users/user create --set username=foo+bar --set lastname=lastname --set
password=univention
cn=foo\+bar,cn=uid,cn=temporary,cn=univention,dc=univention,dc=qa

udm users/user create --set username="foo,,,bar" --set lastname=lastname --set
password=univention
cn=foo\,\,\,bar,cn=uid,cn=temporary,cn=univention,dc=univention,dc=qa

root@qamaster:~# udm users/user create --set mailPrimaryAddress="2aa,aaa@aa.de"
--set lastname=aa --set password=univention --set username=a2
cn=aa\,aaa@aa.de,cn=mailPrimaryAddress,cn=temporary,cn=univention,dc=univention,dc=qa


root@qamaster:~# udm users/user create --set mailPrimaryAddress="2aa+aaa@aa.de"
--set lastname=aa --set password=univention --set username=a3
cn=2aa\+aaa@aa.de,cn=mailPrimaryAddress,cn=temporary,cn=univention,dc=univention,dc=qa


udm groups/group create --set name='foo ,,,sss +sssss'
cn=foo \,\,\,sss
\+sssss,cn=groupName,cn=temporary,cn=univention,dc=univention,dc=qa

udm groups/group create --set name='foo"bar'
cn=foo\"bar,cn=groupName,cn=temporary,cn=univention,dc=univention,dc=qa

udm users/user create --set password=univention --set lastname=a --set
username='äö,+ ""aa'
cn=äö\,\+ \"\"aa,cn=uid,cn=temporary,cn=univention,dc=univention,dc=qa

Changelog angepasst.
Comment 7 Stefan Gohmann univentionstaff 2010-05-18 10:00:14 CEST
UCS 2.3-2 wurde veröffentlicht. Sollte der hier beschriebene Bug mit einer neueren Version von UCS erneut auftreten, so sollte der Bug dupliziert werden:
"Clone This Bug".