Univention Bugzilla – Attachment 9095 Details for
Bug 41574
Handling of userexpiry is unexact
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
41574-s4c-user-expiry-421.patch
41574-s4c-user-expiry-421.patch (text/plain), 4.59 KB, created by
Lukas Oyen
on 2017-08-07 12:16 CEST
(
hide
)
Description:
41574-s4c-user-expiry-421.patch
Filename:
MIME Type:
Creator:
Lukas Oyen
Created:
2017-08-07 12:16 CEST
Size:
4.59 KB
patch
obsolete
>From 21bdfc763156710094f21f0d0f311fe7c757c964 Mon Sep 17 00:00:00 2001 >From: Lukas Oyen <oyen@univention.de> >Date: Mon, 7 Aug 2017 10:23:49 +0200 >Subject: [PATCH 1/2] Bug #41574: s4c: fix time conversions > >With this commit, samba2s4_time(), s42samba_time(), unix2s4_time() and >s42unix_time() no longer assume a time-zone, but handle the timestamps as UTC. > >unix2s4_time() and s42unix_time() are now truly invers: > >>>> 42unix_time(unix2s4_time('2016-11-09')) >'2016-11-09' >--- > .../modules/univention/s4connector/s4/__init__.py | 31 ++++++++++++---------- > 1 file changed, 17 insertions(+), 14 deletions(-) > >diff --git a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py b/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py >index c7b9ffb..b8b1f47 100644 >--- a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py >+++ b/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py >@@ -39,6 +39,7 @@ import string > import re > import sys > import time >+import calendar > import types > import array > import univention.uldap >@@ -215,26 +216,28 @@ def encode_s4_resultlist(s4_resultlist): > return s4_resultlist > > >-def unix2s4_time(l): >- d = 116444736000000000L # difference between 1601 and 1970 >- return long(time.mktime(time.gmtime(time.mktime(time.strptime(l, "%Y-%m-%d")) + 90000))) * 10000000 + d # 90000s are one day and one hour >+def samba2s4_time(unix_ts): >+ delta = 116444736000000000L # difference between 1601 and 1970 >+ as_nanoseconds = unix_ts * 10000000 >+ return as_nanoseconds + delta > > >-def s42unix_time(l): >- d = 116444736000000000L # difference between 1601 and 1970 >- return time.strftime("%d.%m.%y", time.gmtime((l - d) / 10000000)) >+def s42samba_time(s4_ts): >+ delta = 116444736000000000L # difference between 1601 and 1970 >+ if s4_ts == 0: >+ return 0 >+ nanoseconds_since_epoch = s4_ts - delta >+ return nanoseconds_since_epoch / 10000000 > > >-def samba2s4_time(l): >- d = 116444736000000000L # difference between 1601 and 1970 >- return long(time.mktime(time.localtime(l))) * 10000000 + d >+def unix2s4_time(iso_date): >+ since_epoch = calendar.timegm(time.strptime(iso_date, '%Y-%m-%d')) >+ return samba2s4_time(since_epoch) > > >-def s42samba_time(l): >- if l == 0: >- return l >- d = 116444736000000000L # difference between 1601 and 1970 >- return long(((l - d)) / 10000000) >+def s42unix_time(s4_ts): >+ since_epoch = s42samba_time(s4_ts) >+ return time.strftime('%Y-%m-%d', time.gmtime(since_epoch)) > > # mapping funtions > >-- >2.7.4 > > >From 3eeda5cb6671ea8f2a6146e697c30a029a0b95e4 Mon Sep 17 00:00:00 2001 >From: Lukas Oyen <oyen@univention.de> >Date: Mon, 7 Aug 2017 09:42:21 +0200 >Subject: [PATCH 2/2] Bug #41574: s4c: cleanup accountExpires handling > >--- > .../modules/univention/s4connector/s4/__init__.py | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > >diff --git a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py b/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py >index b8b1f47..0424f51 100644 >--- a/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py >+++ b/services/univention-s4-connector/modules/univention/s4connector/s4/__init__.py >@@ -2164,7 +2164,8 @@ class s4(univention.s4connector.ucs): > # user enabled in UCS -> change > ucs_admin_object['disabled'] = 'all' > modified = 1 >- if 'accountExpires' in ldap_object_s4 and (long(ldap_object_s4['accountExpires'][0]) == long(9223372036854775807) or ldap_object_s4['accountExpires'][0] == '0'): >+ account_expires = long(ldap_object_s4['accountExpires'][0]) >+ if 'accountExpires' in ldap_object_s4 and account_expires in (9223372036854775807, 0): > # s4 account not expired > if ucs_admin_object['userexpiry']: > # ucs account expired -> change >@@ -2172,11 +2173,11 @@ class s4(univention.s4connector.ucs): > modified = 1 > else: > # s4 account expired >- ud.debug(ud.LDAP, ud.INFO, "sync account_expire: s4time: %s unixtime: %s" % (long(ldap_object_s4['accountExpires'][0]), ucs_admin_object['userexpiry'])) >+ ud.debug(ud.LDAP, ud.INFO, "sync account_expire: s4time: %s unixtime: %s" % (account_expires, ucs_admin_object['userexpiry'])) > >- if s42unix_time(long(ldap_object_s4['accountExpires'][0])) != ucs_admin_object['userexpiry']: >+ if s42unix_time(account_expires) != ucs_admin_object['userexpiry']: > # ucs account not expired -> change >- ucs_admin_object['userexpiry'] = s42unix_time(long(ldap_object_s4['accountExpires'][0])) >+ ucs_admin_object['userexpiry'] = s42unix_time(account_expires) > modified = 1 > > if modified: >-- >2.7.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 41574
: 9095 |
9407
|
9408
|
9412