Univention Bugzilla – Bug 47197
wrong value of unixtime in users/user causes traceback
Last modified: 2018-06-15 11:15:41 CEST
When trying to create a Group-Report the following error occurs: ---------------------------------------------------------------------- "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 1434, in unmapWindowsFiletime return time.strftime('%Y%m%d%H%M%SZ', time.gmtime(unixtime)) ValueError: year out of range ---------------------------------------------------------------------- According to Py/Doc the '%' before the 'Z' (timezone) is missing. While grep-ing through git I found: ---------------------------------------------------------------------- base/univention-pam/lock-user: HOME=/ python -m univention.lib.account lock --dn "$user_dn" --lock-time "$(date --utc '+%Y%m%d%H%M%SZ')" management/univention-directory-logger/directory_logger.py: timestruct = time.strptime(timestamp, "%Y%m%d%H%M%SZ") management/univention-directory-manager-modules/modules/univention/admin/handlers/users/user.py: unixtime = time.strptime(old, '%Y%m%d%H%M%SZ') management/univention-directory-manager-modules/modules/univention/admin/handlers/users/user.py: return time.strftime('%Y%m%d%H%M%SZ', time.gmtime(unixtime)) management/univention-directory-manager-modules/modules/univention/admin/handlers/users/user.py: locked_unixtime = long(calendar.timegm(time.strptime(locked_timestamp, '%Y%m%d%H%M%SZ'))) management/univention-directory-manager-modules/python-lib/account.py: python -m univention.lib.account lock --dn "$user_dn" --lock-time "$(date --utc '+%Y%m%d%H%M%SZ')" management/univention-directory-manager-modules/univention-migrate-users-to-ucs4.3: expiration_date = time.strftime("%Y%m%d%H%M%SZ", user['krb5ValidEnd'][0]) management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/02_certificate_check.py: 11: '%Y%m%d%HZ', 13: '%Y%m%d%H%MZ', 15: '%Y%m%d%H%M%SZ', services/univention-support-info/univention-support-info:timeString = time.strftime('%Y-%m-%d_%H-%M-%SZ', time.gmtime()) test/ucs-test/tests/01_base/47faillog-ssh-smb-krb:python -m univention.lib.account lock --dn "$(user_dn "$NAME")" --lock-time "$(date --utc '+%Y%m%d%H%M%SZ')" || fail_test 110 "Could not manually lock user account!" test/ucs-test/tests/61_udm-users/100_test_users.py: locktime = time.strftime("%Y%m%d%H%M%SZ", time.gmtime()) test/ucs-test/tests/61_udm-users/25_script_lock_expired_accounts: locktime = time.strftime("%Y%m%d%H%M%SZ", time.gmtime()) test/ucs-test/tests/61_udm-users/37_user_modification_set_deactivation_and_locked: locktime = time.strftime("%Y%m%d%H%M%SZ", time.gmtime()) test/ucs-test/tests/61_udm-users/37_user_modification_set_deactivation_and_locked: locktime = time.strftime("%Y%m%d%H%M%SZ", time.gmtime()) virtualization/univention-virtual-machine-manager-daemon/src/univention/uvmm/node.py: now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) ----------------------------------------------------------------------
The Z is an actual "Z", not a template macro for time.strftime. Like so: >>> import time >>> time.strftime('%Y%m%d%H%M%SZ', time.gmtime(time.time())) '20180301162009Z' So my guess is that he value of unixtime is wrong somehow. Like so: >>> time.strftime('%Y%m%d%H%M%SZ', time.gmtime(-999999999999999)) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: year out of range
The full python traceback would be useful to see in which context this is called and where the value comes from.
I can reproduce it: root@master431:~# ldapmodify -x -D cn=admin,$(ucr get ldap/base) -y /etc/ldap.secret -f user-set-sambaBadPasswordTime-to-1467969484.ldif modifying entry "uid=edl,cn=users,dc=deadlock43,dc=intranet" root@master431:~# udm users/user list 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 398, in doit out = _doit(arglist) File "/usr/lib/pymodules/python2.7/univention/admincli/admin.py", line 987, in _doit for object in univention.admin.modules.lookup(module, co, lo, scope='sub', superordinate=superordinate, base=position.getDn(), filter=filter): File "/usr/lib/pymodules/python2.7/univention/admin/modules.py", line 732, in lookup tmpres = module.lookup(co, lo, filter, base=base, superordinate=superordinate, scope=scope, unique=unique, required=required, timeout=timeout, sizelimit=sizelimit) File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 1404, in lookup result.append(cls(co, lo, None, dn=dn, superordinate=superordinate, attributes=attrs)) File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 1520, in __init__ univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes=attributes) File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 230, in __init__ oldinfo = self.mapping.unmapValues(self.oldattr) File "/usr/lib/pymodules/python2.7/univention/admin/mapping.py", line 321, in unmapValues info = mapDict(self, oldattr) File "/usr/lib/pymodules/python2.7/univention/admin/mapping.py", line 377, in mapDict v = mapping.unmapValue(key, value) File "/usr/lib/pymodules/python2.7/univention/admin/mapping.py", line 317, in unmapValue return unmap_value(value) if unmap_value else value File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 1433, in unmapWindowsFiletime return time.strftime('%Y%m%d%H%M%SZ', time.gmtime(unixtime)) ValueError: year out of range root@master431:~# ldapmodify -x -D cn=admin,$(ucr get ldap/base) -y /etc/ldap.secret -f user-set-sambaBadPasswordTime-to-0.ldif modifying entry "uid=edl,cn=users,dc=deadlock43,dc=intranet" root@master431:~# udm users/user list --filter uid=edl | grep -i lock DN: uid=edl,cn=users,dc=deadlock43,dc=intranet groups: cn=Domain Users,cn=groups,dc=deadlock43,dc=intranet locked: 0 lockedTime: 0 primaryGroup: cn=Domain Users,cn=groups,dc=deadlock43,dc=intranet unlock: None unlockTime: None root@master431:~# root@master431:~# tail user-set-sambaBadPasswordTime-to-0.ldif dn: uid=edl,cn=users,dc=deadlock43,dc=intranet changetype: modify replace: sambaBadPasswordTime sambaBadPasswordTime: 0 root@master431:~# tail user-set-sambaBadPasswordTime-to-1467969484.ldif dn: uid=edl,cn=users,dc=deadlock43,dc=intranet changetype: modify replace: sambaBadPasswordTime sambaBadPasswordTime: 1467969484 root@master431:~#
*** This bug has been marked as a duplicate of bug 47170 ***