Bug 48441 - udm users/user create traceback when using --set name=foo instead of username=foo
udm users/user create traceback when using --set name=foo instead of username...
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM - CLI
UCS 4.3
Other Linux
: P5 minor (vote)
: UCS 4.4-0-errata
Assigned To: Florian Best
Julia Bremer
:
: 48244 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-01-09 12:41 CET by Arvid Requate
Modified: 2019-03-27 13:29 CET (History)
2 users (show)

See Also:
What kind of report is it?: Development Internal
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
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arvid Requate univentionstaff 2019-01-09 12:41:20 CET
The error handling of udm cli should be improved: When creating a users/user object and specifying the fantasy property "name" instead of the mandatory property "username" I get this traceback:


root@master10:~# udm users/user create --position cn=users,dc=ar41i1,dc=qa \
                                       --set name=user1 \
                                       --set lastname=last1 \
                                       --set password=univention
Traceback (most recent call last):
  File "/usr/share/univention-directory-manager-tools/univention-cli-server", line 218, in doit
    output = univention.admincli.admin.doit(arglist)
  File "/usr/lib/pymodules/python2.7/univention/admincli/admin.py", line 395, in doit
    out = _doit(arglist)
  File "/usr/lib/pymodules/python2.7/univention/admincli/admin.py", line 741, in _doit
    dn = object.create()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 536, in create
    self._ldap_pre_ready()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 1885, in _ldap_pre_ready
    self.alloc.append(('uid', univention.admin.allocators.request(self.lo, self.position, 'uid', value=self['username'])))
  File "/usr/lib/pymodules/python2.7/univention/admin/allocators.py", line 196, in request
    return acquireUnique(lo, position, type, value, _type2attr[type], scope=_type2scope[type])
  File "/usr/lib/pymodules/python2.7/univention/admin/allocators.py", line 174, in acquireUnique
    univention.admin.locking.lock(lo, position, type, value, scope=scope)
  File "/usr/lib/pymodules/python2.7/univention/admin/locking.py", line 71, in lock
    if not lo.get(dn, ['lockTime']):
  File "/usr/lib/pymodules/python2.7/univention/admin/uldap.py", line 656, in get
    return self.lo.get(dn, attr, required)
  File "/usr/lib/pymodules/python2.7/univention/uldap.py", line 273, in get
    result = self.lo.search_s(dn, ldap.SCOPE_BASE, '(objectClass=*)', attr)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 597, in search_s
    return self.search_ext_s(base,scope,filterstr,attrlist,attrsonly,None,None,timeout=self.timeout)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 993, in search_ext_s
    return self._apply_method_s(SimpleLDAPObject.search_ext_s,*args,**kwargs)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 931, in _apply_method_s
    return func(self,*args,**kwargs)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 591, in search_ext_s
    return self.result(msgid,all=1,timeout=timeout)[1]
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 503, in result
    resp_type, resp_data, resp_msgid = self.result2(msgid,all,timeout)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 507, in result2
    resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all,timeout)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 514, in result3
    resp_ctrl_classes=resp_ctrl_classes
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 521, in result4
    ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 106, in _ldap_call
    result = func(*args,**kwargs)
INVALID_DN_SYNTAX: {'info': 'invalid DN', 'desc': 'Invalid DN syntax'}

## Proof that the udm generally works on my system:
root@master10:~# udm users/user create --position cn=users,dc=ar41i1,dc=qa \
                                       --set username=user1 \
                                       --set lastname=last1 \
                                       --set password=univention
Object created: uid=user1,cn=users,dc=ar41i1,dc=qa
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2019-01-10 09:56:34 CET
*** Bug 48244 has been marked as a duplicate of this bug. ***
Comment 2 Florian Best univentionstaff 2019-03-14 08:24:38 CET
> /usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py(1888)_ldap_pre_ready()
-> self.alloc.append(('uid', univention.admin.allocators.request(self.lo, self.position, 'uid', value=self['username'])))

> /usr/lib/pymodules/python2.7/univention/admin/uldap.py(656)get()
-> return self.lo.get(dn, attr, required)
(Pdb) dn
'cn=,cn=uid,cn=temporary,cn=univention,dc=school,dc=dev'
→ This happens when trying to create temporary lock objects. And unfortionately before the code which checks if all required properties are set.

Prevented with a simple if self['username'].

univention-directory-manager-modules (14.0.12-2)
f00c390a9503 | Bug #48441: prevent traceback when not setting --set username= on users/user create
Comment 3 Julia Bremer univentionstaff 2019-03-14 09:20:04 CET
Verified:
* Code review
* No traceback when creating users/user without username
* Advisory
Comment 4 Arvid Requate univentionstaff 2019-03-27 13:29:27 CET
<http://errata.software-univention.de/ucs/4.4/19.html>