[SCM] Samba Shared Repository - branch v4-15-test updated

Stefan Metzmacher metze at samba.org
Tue Oct 26 15:10:01 UTC 2021


The branch, v4-15-test has been updated
       via  a795e0c8459 Release ldb 2.4.1
       via  9e2da222f7f pyldb: Make ldb.Message containment testing consistent with indexing
       via  b4601d0db20 pyldb: Add tests for ldb.Message containment testing
       via  2311987af25 pyldb: Raise TypeError for an invalid ldb.Message index
       via  bef676475fe pyldb: Add test for an invalid ldb.Message index type
       via  ba4032b73a4 s4/torture/drs/python: Fix attribute existence check
       via  d32f732c796 pyldb: Fix deleting an ldb.Control critical flag
       via  3b6c8bd55b3 pytest:segfault: Add test for deleting an ldb.Control critical flag
       via  6db664a07da pyldb: Fix deleting an ldb.Message dn
       via  f4ca03b0cc2 pytest:segfault: Add test for deleting an ldb.Message dn
       via  34d50f415ae Fix Python docstrings
      from  753e0dfc6c9 lib/krb5_wrap: Fix missing error check in new salt code

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-15-test


- Log -----------------------------------------------------------------
commit a795e0c84597aa045d011e663dbad3cdabf0f1e6
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Sep 29 11:27:41 2021 +1300

    Release ldb 2.4.1
    
    * Corrected python behaviour for 'in' for LDAP attributes
      contained as part of ldb.Message (bug 14845)
    * Fix memory handling in ldb.msg_diff (bug 14836)
    * Corrected python docstrings
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14836
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14848
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 76899e236149ff3b86cd9032a3c6bdafe3a2f036)
    
    Autobuild-User(v4-15-test): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(v4-15-test): Tue Oct 26 15:09:58 UTC 2021 on sn-devel-184

commit 9e2da222f7f9993443cabcd42cd38e61abcd7a5d
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 14:39:59 2021 +1200

    pyldb: Make ldb.Message containment testing consistent with indexing
    
    Previously, containment testing using the 'in' operator was handled by
    performing an equality comparison between the chosen object and each of
    the message's keys in turn. This behaviour was prone to errors due to
    not considering differences in case between otherwise equal elements, as
    the indexing operations do.
    
    Containment testing should now be more consistent with the indexing
    operations and with the get() method of ldb.Message.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 860d8902a9c502d4be83396598cf4a53c80fea69)

commit b4601d0db20c4ccb933c0264c577fe0df07923c1
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 13:48:57 2021 +1200

    pyldb: Add tests for ldb.Message containment testing
    
    These tests verify that the 'in' operator on ldb.Message is consistent
    with indexing and the get() method. This means that the 'dn' element
    should always be present, lookups should be case-insensitive, and use of
    an invalid type should result in a TypeError.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 865fe238599a732360b77e06e592cb85d459acf8)

commit 2311987af25e43596cda5bfa8505e0acfd4477bd
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 13:39:56 2021 +1200

    pyldb: Raise TypeError for an invalid ldb.Message index
    
    Previously, a TypeError was raised and subsequently overridden by a
    KeyError.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 22353767ca75af9d9e8fa1e7da372dcb5eddfcb7)

commit bef676475fe25846172152f6492839e74b588ed6
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 13:22:05 2021 +1200

    pyldb: Add test for an invalid ldb.Message index type
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit b018e51d2725a23b2fedd3058644b8021f6a6a06)

commit ba4032b73a49246f4987549666d7b6880a85990f
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 19:18:39 2021 +1200

    s4/torture/drs/python: Fix attribute existence check
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit fb758c32e7633178f42dc2c031667b10c2ca6e90)

commit d32f732c7964c56445394abc080243e564ff2585
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 11:16:09 2021 +1200

    pyldb: Fix deleting an ldb.Control critical flag
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 9d25a21d6024c6c2f8e4634f45e3944d8acbf8b8)

commit 3b6c8bd55b38c8498dc340f5ed3d8300099e3ae5
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 11:13:02 2021 +1200

    pytest:segfault: Add test for deleting an ldb.Control critical flag
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit b1adaa517c1237a473bdcf818523f5107df3d6b0)

commit 6db664a07dab079c60fde9413e48bfd91edd6878
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 11:12:16 2021 +1200

    pyldb: Fix deleting an ldb.Message dn
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit d7af772de88885f46708329ff7bb5798da91d2c7)

commit f4ca03b0cc2baab80ec45ae2f3d3f277a4a3c5b3
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Sat Sep 25 10:56:25 2021 +1200

    pytest:segfault: Add test for deleting an ldb.Message dn
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 6a041f6a99c39632d5c32e9d53b06719c20bef2c)

commit 34d50f415aeeba46ff74f3a0e3ab67fa0a5a8eea
Author: Joseph Sutton <josephsutton at catalyst.net.nz>
Date:   Wed Apr 28 16:48:55 2021 +1200

    Fix Python docstrings
    
    Signed-off-by: Joseph Sutton <josephsutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Sep  4 00:55:32 UTC 2021 on sn-devel-184
    
    (cherry picked from commit 02b187303369d3ce0c19dfb72ffa78f86a3911f0)

-----------------------------------------------------------------------

Summary of changes:
 lib/ldb/ABI/{ldb-2.0.5.sigs => ldb-2.4.1.sigs}     |  0
 ...pyldb-util-2.1.0.sigs => pyldb-util-2.4.1.sigs} |  0
 lib/ldb/pyldb.c                                    | 51 +++++++++++++++-------
 lib/ldb/tests/python/api.py                        | 29 ++++++++++++
 lib/ldb/wscript                                    |  2 +-
 lib/tdb/pytdb.c                                    |  2 +-
 lib/tevent/pytevent.c                              |  2 +-
 python/samba/tests/segfault.py                     | 14 ++++++
 source4/librpc/ndr/py_security.c                   |  2 +-
 source4/torture/drs/python/replica_sync.py         |  2 +-
 10 files changed, 84 insertions(+), 20 deletions(-)
 copy lib/ldb/ABI/{ldb-2.0.5.sigs => ldb-2.4.1.sigs} (100%)
 copy lib/ldb/ABI/{pyldb-util-2.1.0.sigs => pyldb-util-2.4.1.sigs} (100%)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/ABI/ldb-2.0.5.sigs b/lib/ldb/ABI/ldb-2.4.1.sigs
similarity index 100%
copy from lib/ldb/ABI/ldb-2.0.5.sigs
copy to lib/ldb/ABI/ldb-2.4.1.sigs
diff --git a/lib/ldb/ABI/pyldb-util-2.1.0.sigs b/lib/ldb/ABI/pyldb-util-2.4.1.sigs
similarity index 100%
copy from lib/ldb/ABI/pyldb-util-2.1.0.sigs
copy to lib/ldb/ABI/pyldb-util-2.4.1.sigs
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index c264f361c40..3f4b0c7a45c 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -182,6 +182,10 @@ static PyObject *py_ldb_control_get_critical(PyLdbControlObject *self,
 
 static int py_ldb_control_set_critical(PyLdbControlObject *self, PyObject *value, void *closure)
 {
+	if (value == NULL) {
+		PyErr_SetString(PyExc_AttributeError, "cannot delete critical flag");
+		return -1;
+	}
 	if (PyObject_IsTrue(value)) {
 		self->data->critical = true;
 	} else {
@@ -839,7 +843,7 @@ static PyMethodDef py_ldb_dn_methods[] = {
 		"S.get_component_value(num) -> string\n"
 		"get the attribute value of the specified component as a binary string" },
 	{ "set_component", (PyCFunction)py_ldb_dn_set_component, METH_VARARGS,
-		"S.get_component_value(num, name, value) -> None\n"
+		"S.set_component(num, name, value) -> None\n"
 		"set the attribute name and value of the specified component" },
 	{ "get_rdn_name", (PyCFunction)py_ldb_dn_get_rdn_name, METH_NOARGS,
 		"S.get_rdn_name() -> string\n"
@@ -3429,33 +3433,41 @@ static PyObject *py_ldb_msg_keys(PyLdbMessageObject *self,
 	return obj;
 }
 
-static PyObject *py_ldb_msg_getitem_helper(PyLdbMessageObject *self, PyObject *py_name)
+static int py_ldb_msg_contains(PyLdbMessageObject *self, PyObject *py_name)
 {
-	struct ldb_message_element *el;
-	const char *name;
+	struct ldb_message_element *el = NULL;
+	const char *name = NULL;
 	struct ldb_message *msg = pyldb_Message_AsMessage(self);
 	name = PyUnicode_AsUTF8(py_name);
 	if (name == NULL) {
-		PyErr_SetNone(PyExc_TypeError);
-		return NULL;
+		return -1;
 	}
-	if (!ldb_attr_cmp(name, "dn"))
-		return pyldb_Dn_FromDn(msg->dn);
-	el = ldb_msg_find_element(msg, name);
-	if (el == NULL) {
-		return NULL;
+	if (!ldb_attr_cmp(name, "dn")) {
+		return 1;
 	}
-	return (PyObject *)PyLdbMessageElement_FromMessageElement(el, msg->elements);
+	el = ldb_msg_find_element(msg, name);
+	return el != NULL ? 1 : 0;
 }
 
 static PyObject *py_ldb_msg_getitem(PyLdbMessageObject *self, PyObject *py_name)
 {
-	PyObject *ret = py_ldb_msg_getitem_helper(self, py_name);
-	if (ret == NULL) {
+	struct ldb_message_element *el = NULL;
+	const char *name = NULL;
+	struct ldb_message *msg = pyldb_Message_AsMessage(self);
+	name = PyUnicode_AsUTF8(py_name);
+	if (name == NULL) {
+		return NULL;
+	}
+	if (!ldb_attr_cmp(name, "dn")) {
+		return pyldb_Dn_FromDn(msg->dn);
+	}
+	el = ldb_msg_find_element(msg, name);
+	if (el == NULL) {
 		PyErr_SetString(PyExc_KeyError, "No such element");
 		return NULL;
 	}
-	return ret;
+
+	return PyLdbMessageElement_FromMessageElement(el, msg->elements);
 }
 
 static PyObject *py_ldb_msg_get(PyLdbMessageObject *self, PyObject *args, PyObject *kwargs)
@@ -3665,6 +3677,10 @@ static Py_ssize_t py_ldb_msg_length(PyLdbMessageObject *self)
 	return pyldb_Message_AsMessage(self)->num_elements;
 }
 
+static PySequenceMethods py_ldb_msg_sequence = {
+	.sq_contains = (objobjproc)py_ldb_msg_contains,
+};
+
 static PyMappingMethods py_ldb_msg_mapping = {
 	.mp_length = (lenfunc)py_ldb_msg_length,
 	.mp_subscript = (binaryfunc)py_ldb_msg_getitem,
@@ -3741,6 +3757,10 @@ static PyObject *py_ldb_msg_get_dn(PyLdbMessageObject *self, void *closure)
 static int py_ldb_msg_set_dn(PyLdbMessageObject *self, PyObject *value, void *closure)
 {
 	struct ldb_message *msg = pyldb_Message_AsMessage(self);
+	if (value == NULL) {
+		PyErr_SetString(PyExc_AttributeError, "cannot delete dn");
+		return -1;
+	}
 	if (!pyldb_Dn_Check(value)) {
 		PyErr_SetString(PyExc_TypeError, "expected dn");
 		return -1;
@@ -3838,6 +3858,7 @@ static PyTypeObject PyLdbMessage = {
 	.tp_name = "ldb.Message",
 	.tp_methods = py_ldb_msg_methods,
 	.tp_getset = py_ldb_msg_getset,
+	.tp_as_sequence = &py_ldb_msg_sequence,
 	.tp_as_mapping = &py_ldb_msg_mapping,
 	.tp_basicsize = sizeof(PyLdbMessageObject),
 	.tp_dealloc = (destructor)py_ldb_msg_dealloc,
diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py
index 16b71e2e650..bf6f7ef993d 100755
--- a/lib/ldb/tests/python/api.py
+++ b/lib/ldb/tests/python/api.py
@@ -3082,6 +3082,12 @@ class LdbMsgTests(TestCase):
     def test_notpresent(self):
         self.assertRaises(KeyError, lambda: self.msg["foo"])
 
+    def test_invalid(self):
+        try:
+            self.assertRaises(TypeError, lambda: self.msg[42])
+        except KeyError:
+            self.fail()
+
     def test_del(self):
         del self.msg["foo"]
 
@@ -3197,6 +3203,29 @@ class LdbMsgTests(TestCase):
     def test_get_unknown_text(self):
         self.assertEqual(None, self.msg.text.get("lalalala"))
 
+    def test_contains(self):
+        self.msg['foo'] = ['bar']
+        self.assertIn('foo', self.msg)
+
+        self.msg['Foo'] = ['bar']
+        self.assertIn('Foo', self.msg)
+
+    def test_contains_case(self):
+        self.msg['foo'] = ['bar']
+        self.assertIn('Foo', self.msg)
+
+        self.msg['Foo'] = ['bar']
+        self.assertIn('foo', self.msg)
+
+    def test_contains_dn(self):
+        self.assertIn('dn', self.msg)
+
+    def test_contains_dn_case(self):
+        self.assertIn('DN', self.msg)
+
+    def test_contains_invalid(self):
+        self.assertRaises(TypeError, lambda: None in self.msg)
+
     def test_msg_diff(self):
         l = ldb.Ldb()
         msgs = l.parse_ldif("dn: foo=bar\nfoo: bar\nbaz: do\n\ndn: foo=bar\nfoo: bar\nbaz: dont\n")
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 863dfde9339..986690181ec 100644
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -2,7 +2,7 @@
 
 APPNAME = 'ldb'
 # For Samba 4.15.x
-VERSION = '2.4.0'
+VERSION = '2.4.1'
 
 import sys, os
 
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 2ea2042c1e5..e2f8ace227f 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -577,7 +577,7 @@ static PyMethodDef tdb_object_methods[] = {
 	{ "add_flags", (PyCFunction)obj_add_flags, METH_VARARGS, "S.add_flags(flags) -> None" },
 	{ "remove_flags", (PyCFunction)obj_remove_flags, METH_VARARGS, "S.remove_flags(flags) -> None" },
 #if PY_MAJOR_VERSION >= 3
-	{ "keys", (PyCFunction)tdb_object_iter, METH_NOARGS, "S.iterkeys() -> iterator" },
+	{ "keys", (PyCFunction)tdb_object_iter, METH_NOARGS, "S.keys() -> iterator" },
 #else
 	{ "iterkeys", (PyCFunction)tdb_object_iter, METH_NOARGS, "S.iterkeys() -> iterator" },
 #endif
diff --git a/lib/tevent/pytevent.c b/lib/tevent/pytevent.c
index 93375f71868..62dfe2419ff 100644
--- a/lib/tevent/pytevent.c
+++ b/lib/tevent/pytevent.c
@@ -573,7 +573,7 @@ static PyMethodDef py_tevent_context_methods[] = {
 	{ "add_timer", (PyCFunction)py_tevent_context_add_timer,
 		METH_VARARGS, "S.add_timer(next_event, handler) -> timer" },
 	{ "add_timer_offset", (PyCFunction)py_tevent_context_add_timer_offset,
-		METH_VARARGS, "S.add_timer(offset_seconds, handler) -> timer" },
+		METH_VARARGS, "S.add_timer_offset(offset_seconds, handler) -> timer" },
 	{ "add_fd", (PyCFunction)py_tevent_context_add_fd, 
 		METH_VARARGS, "S.add_fd(fd, flags, handler) -> fd" },
 	{0},
diff --git a/python/samba/tests/segfault.py b/python/samba/tests/segfault.py
index c316bdd5785..6186d60c823 100644
--- a/python/samba/tests/segfault.py
+++ b/python/samba/tests/segfault.py
@@ -222,3 +222,17 @@ class SegfaultTests(samba.tests.TestCase):
 
         del msg
         diff.dn
+
+    @no_gdb_backtrace
+    @segfault_detector
+    def test_ldb_msg_del_dn(self):
+        msg = ldb.Message()
+        del msg.dn
+
+    @no_gdb_backtrace
+    @segfault_detector
+    def test_ldb_control_del_critical(self):
+        samdb = self.get_samdb()
+
+        c = ldb.Control(samdb, 'relax:1')
+        del c.critical
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
index b5531d58304..e79e7170812 100644
--- a/source4/librpc/ndr/py_security.c
+++ b/source4/librpc/ndr/py_security.c
@@ -447,7 +447,7 @@ static PyMethodDef py_token_extra_methods[] = {
 	{ "has_sid", (PyCFunction)py_token_has_sid, METH_VARARGS,
 		NULL },
 	{ "is_anonymous", (PyCFunction)py_token_is_anonymous, METH_NOARGS,
-		"S.is_anonymus() -> bool\n"
+		"S.is_anonymous() -> bool\n"
 		"Check whether this is an anonymous token." },
 	{ "is_system", (PyCFunction)py_token_is_system, METH_NOARGS,
 		NULL },
diff --git a/source4/torture/drs/python/replica_sync.py b/source4/torture/drs/python/replica_sync.py
index 3b0df99b295..cd1c9418549 100644
--- a/source4/torture/drs/python/replica_sync.py
+++ b/source4/torture/drs/python/replica_sync.py
@@ -139,7 +139,7 @@ objectClass: organizationalUnit
         # now check properties of the user
         name_cur = ou_cur["ou"][0]
         self.assertEqual(ou_cur["isDeleted"][0], b"TRUE")
-        self.assertTrue(not(b"objectCategory" in ou_cur))
+        self.assertTrue(not("objectCategory" in ou_cur))
         self.assertTrue(dodn in str(ou_cur["dn"]),
                         "OU %s is deleted but it is not located under %s!" % (name_cur, dodn))
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list