[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Sat Jan 24 12:18:02 MST 2015
The branch, master has been updated
via dc2f910 s4:dsdb/tests: add test_timevalues1() to verify timestamp values
via c7af8ae ldb: version 1.1.20
via d1b5155 lib/ldb: fix logic in ldb_val_to_time()
from 6a56bdf Update the tevent_data.dox tutrial stuff to fix some errors, including white space problems.
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit dc2f91020e3b52942f8aab60fd1db70d2afadd51
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jan 9 08:56:59 2015 +0100
s4:dsdb/tests: add test_timevalues1() to verify timestamp values
Bug: https://bugzilla.samba.org/show_bug.cgi?id=9810
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Günther Deschner <gd at samba.org>
Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
Autobuild-Date(master): Sat Jan 24 20:17:20 CET 2015 on sn-devel-104
commit c7af8ae9d2aa19db2533e69b8a4d7c1b6f8e2d9f
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Jan 19 17:17:13 2015 +0100
ldb: version 1.1.20
- Bug 9810 - validate_ldb of String(Generalized-Time) does not accept millisecond format ".000Z"
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Günther Deschner <gd at samba.org>
commit d1b515535da46591d3a646a848c7427b6ff951a7
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Jan 19 15:47:58 2015 +0100
lib/ldb: fix logic in ldb_val_to_time()
040408072012Z should represent 20040408072012.0Z
as well as 20040408072012.000Z or
20040408072012.RandomIgnoredCharaters...Z
Bug: https://bugzilla.samba.org/show_bug.cgi?id=9810
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Günther Deschner <gd at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/ldb/ABI/{ldb-1.1.19.sigs => ldb-1.1.20.sigs} | 0
...ldb-util-1.1.10.sigs => pyldb-util-1.1.20.sigs} | 0
lib/ldb/common/ldb_msg.c | 38 ++++++++++++++++----
lib/ldb/wscript | 2 +-
source4/dsdb/tests/python/ldap.py | 40 ++++++++++++++++++++++
5 files changed, 73 insertions(+), 7 deletions(-)
copy lib/ldb/ABI/{ldb-1.1.19.sigs => ldb-1.1.20.sigs} (100%)
copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util-1.1.20.sigs} (100%)
Changeset truncated at 500 lines:
diff --git a/lib/ldb/ABI/ldb-1.1.19.sigs b/lib/ldb/ABI/ldb-1.1.20.sigs
similarity index 100%
copy from lib/ldb/ABI/ldb-1.1.19.sigs
copy to lib/ldb/ABI/ldb-1.1.20.sigs
diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util-1.1.20.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs
copy to lib/ldb/ABI/pyldb-util-1.1.20.sigs
diff --git a/lib/ldb/common/ldb_msg.c b/lib/ldb/common/ldb_msg.c
index 809e3af..3f65351 100644
--- a/lib/ldb/common/ldb_msg.c
+++ b/lib/ldb/common/ldb_msg.c
@@ -1090,28 +1090,54 @@ time_t ldb_string_to_time(const char *s)
*/
int ldb_val_to_time(const struct ldb_val *v, time_t *t)
{
- struct tm tm;
+ char val[15] = {};
+ struct tm tm = {};
- if (v == NULL || !v->data || (v->length != 17 && v->length != 13)) {
+ if (v == NULL) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
- memset(&tm, 0, sizeof(tm));
+ if (v->data == NULL) {
+ return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
+ }
+
+ if (v->length < 16 && v->length != 13) {
+ return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
+ }
+
+ if (v->data[v->length - 1] != 'Z') {
+ return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
+ }
if (v->length == 13) {
- if (sscanf((char *)v->data, "%02u%02u%02u%02u%02u%02uZ",
+ memcpy(val, v->data, 12);
+
+ if (sscanf(val, "%02u%02u%02u%02u%02u%02u",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
+ if (tm.tm_year < 50) {
+ tm.tm_year += 100;
+ }
} else {
- if (sscanf((char *)v->data, "%04u%02u%02u%02u%02u%02u.0Z",
+
+ /*
+ * anything between '.' and 'Z' is silently ignored.
+ */
+ if (v->data[14] != '.') {
+ return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
+ }
+
+ memcpy(val, v->data, 14);
+
+ if (sscanf(val, "%04u%02u%02u%02u%02u%02u",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
+ tm.tm_year -= 1900;
}
- tm.tm_year -= 1900;
tm.tm_mon -= 1;
*t = timegm(&tm);
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 4d44a0a..6391e74 100755
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -1,7 +1,7 @@
#!/usr/bin/env python
APPNAME = 'ldb'
-VERSION = '1.1.19'
+VERSION = '1.1.20'
blddir = 'bin'
diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py
index 7139f3c..dc12fea 100755
--- a/source4/dsdb/tests/python/ldap.py
+++ b/source4/dsdb/tests/python/ldap.py
@@ -106,6 +106,7 @@ class BasicTests(samba.tests.TestCase):
delete_force(self.ldb, "description=xyz,cn=users," + self.base_dn)
delete_force(self.ldb, "ou=testou,cn=users," + self.base_dn)
delete_force(self.ldb, "cn=Test Secret,cn=system," + self.base_dn)
+ delete_force(self.ldb, "cn=testtimevaluesuser1,cn=users," + self.base_dn)
def test_objectclasses(self):
"""Test objectClass behaviour"""
@@ -2859,6 +2860,45 @@ nTSecurityDescriptor:: """ + desc_base64
self.assertTrue("whenCreated" in res[0])
self.assertTrue("whenChanged" in res[0])
+ def test_timevalues1(self):
+ """Tests possible syntax of time attributes"""
+
+ user_name = "testtimevaluesuser1"
+ user_dn = "CN=%s,CN=Users,%s" % (user_name, self.base_dn)
+
+ delete_force(self.ldb, user_dn)
+ self.ldb.add({ "dn": user_dn,
+ "objectClass": "user",
+ "sAMAccountName": user_name })
+
+ #
+ # We check the following values:
+ #
+ # 370101000000Z => 20370101000000.0Z
+ # 20370102000000.*Z => 20370102000000.0Z
+ #
+ ext = [ "Z", ".0Z", ".Z", ".000Z", ".RandomIgnoredCharacters...987654321Z" ]
+ for i in range(0, len(ext)):
+ v_raw = "203701%02d000000" % (i + 1)
+ if ext[i] == "Z":
+ v_set = v_raw[2:] + ext[i]
+ else:
+ v_set = v_raw + ext[i]
+ v_get = v_raw + ".0Z"
+
+ m = Message()
+ m.dn = Dn(ldb, user_dn)
+ m["msTSExpireDate"] = MessageElement([v_set],
+ FLAG_MOD_REPLACE,
+ "msTSExpireDate")
+ self.ldb.modify(m)
+
+ res = self.ldb.search(base=user_dn, scope=SCOPE_BASE, attrs=["msTSExpireDate"])
+ self.assertTrue(len(res) == 1)
+ self.assertTrue("msTSExpireDate" in res[0])
+ self.assertTrue(len(res[0]["msTSExpireDate"]) == 1)
+ self.assertEquals(res[0]["msTSExpireDate"][0], v_get)
+
class BaseDnTests(samba.tests.TestCase):
def setUp(self):
--
Samba Shared Repository
More information about the samba-cvs
mailing list