Bug 46544 - OverflowError: mktime argument out of range
OverflowError: mktime argument out of range
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: S4 Connector
UCS 4.3
Other Linux
: P5 normal (vote)
: UCS 4.3
Assigned To: Arvid Requate
Felix Botner
: interim-4
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-03-08 12:18 CET by Arvid Requate
Modified: 2019-02-27 18:04 CET (History)
3 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
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
fix_userexpiry_mapping_1970_to_2070.patch (928 bytes, patch)
2018-03-08 12:58 CET, Arvid Requate
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arvid Requate univentionstaff 2018-03-08 12:18:42 CET
We have seen rejects after migrating a productive server with legacy data containing disabled use accounts:

08.03.2018 12:13:39,961 LDAP        (PROCESS): sync to ucs:   [          user] [    modify] uid=someuser,cn=disabled,cn=users,dc=domain,dc=local
08.03.2018 12:13:41,77 LDAP        (ERROR  ): failed in post_con_modify_functions
08.03.2018 12:13:41,78 LDAP        (ERROR  ): Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/univention/s4connector/__init__.py", line 1600, in sync_to_ucs
    f(self, property_type, object)
  File "/usr/lib/pymodules/python2.7/univention/s4connector/s4/__init__.py", line 107, in disable_user_to_ucs
    return s4connector.disable_user_to_ucs(key, object)
  File "/usr/lib/pymodules/python2.7/univention/s4connector/s4/__init__.py", line 2180, in disable_user_to_ucs
    ucs_admin_object.modify()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 1676, in modify
    return super(object, self).modify(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 526, in modify
    dn = self._modify(modify_childs, ignore_license=ignore_license, response=response)
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.py", line 1068, in _modify
    ml = self._ldap_modlist()
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 1975, in _ldap_modlist
    ml = self._modlist_samba_kickoff_time(ml)
  File "/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.py", line 2221, in _modlist_samba_kickoff_time
    sambaKickoffTime = "%d" % long(time.mktime(time.strptime(self['userexpiry'], "%Y-%m-%d")))
OverflowError: mktime argument out of range
Comment 1 Felix Botner univentionstaff 2018-03-08 12:21:12 CET
samba:
accountExpires: 116446428000000000
Comment 2 Arvid Requate univentionstaff 2018-03-08 12:58:12 CET
Created attachment 9451 [details]
fix_userexpiry_mapping_1970_to_2070.patch

The S4-Connector writes 02.01.70 into the UDM property "userexpiry". The date2 syntax turns that into 2070. That's wrong. The mktime traceback is just a symptom due to the 2038 unix date boundary:

>>> time.mktime(time.strptime("2070-01-02", "%Y-%m-%d"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: mktime argument out of range

The attached patch may be suitable to fix this.
Comment 3 Felix Botner univentionstaff 2018-03-08 13:01:30 CET
ldap account before migration

objectClass: top
objectClass: person
objectClass: univentionPWHistory
objectClass: posixAccount
objectClass: shadowAccount
objectClass: univentionMail
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: kolabInetOrgPerson
objectClass: ownCloudUser
objectClass: oxUserObject
objectClass: univentionObject
objectClass: univentionXMPPAccount
shadowMax: 90
shadowLastChange: 16563
shadowExpire: 1

migration script
[('objectClass', [], ['krb5KDCEntry', 'sambaSamAccount', 'krb5Principal']),
 ('krb5KeyVersionNumber', [], ['1']),
 ('krb5KDCFlags', [], ['254']),
 ('krb5MaxLife', [], ['86400']),
 ('krb5MaxRenew', [], ['604800']),
 ('krb5ValidEnd', [], ['19700102000000Z']),
 ('krb5PasswordEnd', [], ['20150806000000Z']),
 ('sambaSID', [], ['S-1-4-2281']),
 ('sambaAcctFlags', [], ['[UD         ]']),
 ('sambaPwdLastSet', [], ['1431039600'])]
Comment 4 Felix Botner univentionstaff 2018-03-08 13:06:06 CET
maybe at this point it is a good idea to fix the s4 connector ad to userexpiry function?

 def s42unix_time(l):
        d = 116444736000000000L  # difference between 1601 and 1970
-       return time.strftime("%d.%m.%y", time.gmtime((l - d) / 10000000))
+       return time.strftime("%Y-%m-%d", time.gmtime((l - d) / 10000000))
Comment 5 Arvid Requate univentionstaff 2018-03-08 13:29:15 CET
I committed a similar patch. Package rebuilt

Package: univention-directory-manager-modules
Version: 13.0.21-13A~4.3.0.201803081313
Branch: ucs_4.3-0

Changelog adjusted.
Comment 6 Felix Botner univentionstaff 2018-03-08 13:55:11 CET
OK, works
Comment 7 Stefan Gohmann univentionstaff 2018-03-14 14:38:22 CET
UCS 4.3 has been released:
 https://docs.software-univention.de/release-notes-4.3-0-en.html
 https://docs.software-univention.de/release-notes-4.3-0-de.html

If this error occurs again, please use "Clone This Bug".