Bug 33703 - Setting sambaLogonHours causes a udm traceback
Setting sambaLogonHours causes a udm traceback
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Users
UCS 3.1
Other Linux
: P5 normal (vote)
: UCS 3.2-0-errata
Assigned To: Dirk Wiesenthal
Florian Best
:
: 28664 (view as bug list)
Depends on:
Blocks: 34022
  Show dependency treegraph
 
Reported: 2013-12-10 12:10 CET by Jan Christoph Ebersbach
Modified: 2014-01-31 09:03 CET (History)
3 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:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Christoph Ebersbach univentionstaff 2013-12-10 12:10:35 CET
A customer (Ticket #2013112621003776) set the LDAP attribute sambaLogonHours on the account tab selecting multiple entries.  After that, displaying the user using the udm command line is not possible anymore.  The following traceback occurs:

# udm users/user list --filter username=testuserunivention
Traceback (most recent call last):
  File "/usr/share/univention-directory-manager-tools/univention-cli-server", line 237, in doit
    output = univention.admincli.admin.doit(arglist)
  File "/usr/lib/pymodules/python2.6/univention/admincli/admin.py", line 394, in doit
    out=_doit(arglist)
  File "/usr/lib/pymodules/python2.6/univention/admincli/admin.py", line 1138, in _doit
    out.append('  %s: %s' % ( _2utf8( key ), _2utf8( s.tostring( value ) ) ) )
  File "/usr/lib/pymodules/python2.6/univention/admincli/admin.py", line 250, in _2utf8
    return text.decode( 'iso-8859-1' )
AttributeError: 'list' object has no attribute 'decode'
Comment 1 Jan Christoph Ebersbach univentionstaff 2013-12-10 12:14:01 CET
In one case this even lead to the problem that the UMC didn't display anything on the account tab anymore, just a blank page.
Comment 2 Dirk Wiesenthal univentionstaff 2014-01-06 22:45:40 CET
(In reply to Jan Christoph Ebersbach from comment #1)
> In one case this even lead to the problem that the UMC didn't display
> anything on the account tab anymore, just a blank page.

Confirmed: "Just" select all possible checkboxes (took me five minutes...)

throw new Error(this.declaredClass + ": Invalid item argument.");
Error: dojo.data.ItemFileWriteStore: Invalid item argument.
// item was null
Comment 3 Dirk Wiesenthal univentionstaff 2014-01-06 22:46:58 CET
Just selecting the first item (Su 0-1) (and nothing else) seems to be the same as selecting none at all
Comment 4 Dirk Wiesenthal univentionstaff 2014-01-06 22:50:40 CET
(In reply to Jan Christoph Ebersbach from comment #0)
> A customer (Ticket #2013112621003776) set the LDAP attribute sambaLogonHours
> on the account tab selecting multiple entries.  After that, displaying the
> user using the udm command line is not possible anymore.  The following
> traceback occurs:
> 
> # udm users/user list --filter username=testuserunivention
> Traceback (most recent call last):
>   File
> "/usr/share/univention-directory-manager-tools/univention-cli-server", line
> 237, in doit
>     output = univention.admincli.admin.doit(arglist)
>   File "/usr/lib/pymodules/python2.6/univention/admincli/admin.py", line
> 394, in doit
>     out=_doit(arglist)
>   File "/usr/lib/pymodules/python2.6/univention/admincli/admin.py", line
> 1138, in _doit
>     out.append('  %s: %s' % ( _2utf8( key ), _2utf8( s.tostring( value ) ) )
> )
>   File "/usr/lib/pymodules/python2.6/univention/admincli/admin.py", line
> 250, in _2utf8
>     return text.decode( 'iso-8859-1' )
> AttributeError: 'list' object has no attribute 'decode'

Problem is:
if module.property_descriptions[key].multivalue: # False for SambaLogonHours
else: # udm-cli does not assume a list here

but:

logonHoursUnmap (users/user) returns a list - probably for the UMC widget
Comment 5 Philipp Hahn univentionstaff 2014-01-13 10:00:36 CET
This is a duplicate of Bug #28664.
Also see Bug #28496 for other issues.
Comment 6 Stefan Gohmann univentionstaff 2014-01-13 14:17:03 CET
*** Bug 28664 has been marked as a duplicate of this bug. ***
Comment 7 Dirk Wiesenthal univentionstaff 2014-01-20 14:39:46 CET
(In reply to Dirk Wiesenthal from comment #3)
> Just selecting the first item (Su 0-1) (and nothing else) seems to be the
> same as selecting none at all

Just Su 0-1 is [0] which means:

univention/admin/mapping.py
def mapValue(self, map_name, value):
  [...]
    empty=1
    for v in value:
      if v:
        empty=0
    if empty:
      return ''
Comment 8 Dirk Wiesenthal univentionstaff 2014-01-20 15:38:11 CET
root@master250:~# udm users/user modify --dn uid=klober,cn=users,dc=dwiesent,dc=ucs32,dc=dev --set sambaLogonHours=""
Traceback (most recent call last):
  File "/usr/share/univention-directory-manager-tools/univention-cli-server", line 222, in doit
    output = univention.admincli.admin.doit(arglist)
  File "/usr/lib/pymodules/python2.6/univention/admincli/admin.py", line 393, in doit
    out=_doit(arglist)
  File "/usr/lib/pymodules/python2.6/univention/admincli/admin.py", line 978, in _doit
    if object.hasChanged(input.keys()) or object.hasChanged(append.keys()) or object.hasChanged(remove.keys()) or parsed_append_options or parsed_options:
  File "/usr/lib/pymodules/python2.6/univention/admin/handlers/users/user.py", line 1599, in hasChanged
    return super(object, self).hasChanged(key)
  File "/usr/lib/pymodules/python2.6/univention/admin/handlers/__init__.py", line 161, in hasChanged
    if self.hasChanged(i):
  File "/usr/lib/pymodules/python2.6/univention/admin/handlers/users/user.py", line 1599, in hasChanged
    return super(object, self).hasChanged(key)
  File "/usr/lib/pymodules/python2.6/univention/admin/handlers/__init__.py", line 158, in hasChanged
    return not univention.admin.mapping.mapCmp(self.mapping, key, self.oldinfo.get(key, ''), self.info.get(key, ''))
  File "/usr/lib/pymodules/python2.6/univention/admin/mapping.py", line 193, in mapCmp
    return map[1](old) == map[1](new)
  File "/usr/lib/pymodules/python2.6/univention/admin/handlers/users/user.py", line 1022, in logonHoursMap
    bitstring = ''.join( map( lambda x: x in logontimes and '1' or '0', range( 168 ) ) )
  File "/usr/lib/pymodules/python2.6/univention/admin/handlers/users/user.py", line 1022, in <lambda>
    bitstring = ''.join( map( lambda x: x in logontimes and '1' or '0', range( 168 ) ) )
TypeError: 'in <string>' requires string as left operand, not int

logontimes is '', because of self.info.get(key, '')
Comment 9 Dirk Wiesenthal univentionstaff 2014-01-21 13:36:42 CET
To summarize:

cli:
  (1) Showing sambaLogonHours was nearly always broken (Comment 0)
  (2) Setting sambaLogonHours was commonly broken (Comment 8)
umc-udm:
  (3) Showing sambaLogonHours was sometimes broken (Comment 1)
  (4) Setting sambaLogonHours was broken in one case (Comment 3)

None of these four issues had something to do with each other.

(1) and (4) were fixed by checking key == 'sambaLogonHours' in order to rule out side effects.
(2) was fixed in the dedicated mapping function
(3) was the only "general bug" - which is only known to show up in UDM's sambaLogonHours, though - and was fixed in the umc-frontend.

Fixed in
  univention-directory-manager-modules 9.0.75-13.1166.201401211304
  univention-management-console-frontend 3.0.152-10.807.201401211314

YAMLs updated
Comment 10 Florian Best univentionstaff 2014-01-22 10:43:10 CET
(In reply to Dirk Wiesenthal from comment #9)
> To summarize:
> 
> cli:
>   (1) Showing sambaLogonHours was nearly always broken (Comment 0)
* OK, it is displayed now.

>   (2) Setting sambaLogonHours was commonly broken (Comment 8)
* OK, i can set an empty value

> umc-udm:
>   (3) Showing sambaLogonHours was sometimes broken (Comment 1)
* OK, the detailpage renders correctly now

>   (4) Setting sambaLogonHours was broken in one case (Comment 3)
* OK, setting the first, all, some and unsetting works

> YAMLs updated
* OK
Comment 11 Moritz Muehlenhoff univentionstaff 2014-01-29 11:21:33 CET
http://errata.univention.de/ucs/3.2/42.html
Comment 12 Moritz Muehlenhoff univentionstaff 2014-01-29 11:22:20 CET
http://errata.univention.de/ucs/3.2/45.html