[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Sun Mar 3 23:34:02 UTC 2024


The branch, master has been updated
       via  ee94d708557 ldb: Update ldb.get_opaque() to return talloc‐managed opaque values
       via  256320532a4 ldb: Update ldb.set_opaque() to accept only supported types
       via  81fd42165e9 ldb: Remove trailing whitespace
       via  ab6cb4bc972 ldb: Pass a supported opaque type to ldb.set_opaque()
       via  35e7ce88dd7 ldb: Add tests for Python set_opaque() and get_opaque()
       via  757036cefe5 pyldb: Remove unused and broken Python access to LDB module API
       via  7a38a98871b pyldb: Improve docstric for whoami(), which takes no arguments.
       via  f8fcd21812d pyldb: Remove last caller to and definition of PyLdb_Check()
       via  61e5958a3ac pyldb: Use "O!" to specify the type of py_ldb
       via  8b0d00a8e3e pyldb: Move PyErr_LDB_OR_RAISE() and PyErr_LDB_DN_OR_RAISE() into pyldb.h
       via  6c3ca9e4967 dns: Use pyldb_check_type() in PyErr_LDB_DN_OR_RAISE()
       via  0839999c948 dns: Use pyldb_Ldb_AsLdbContext() in PyErr_LDB_OR_RAISE()
       via  2ba8e656dab dsdb: Use pyldb_check_type() in PyErr_LDB_DN_OR_RAISE()
       via  da63ee78b34 dsdb: Use pyldb_Ldb_AsLdbContext() in PyErr_LDB_OR_RAISE()
       via  dbdecac5f89 ldb/pyldb: Call Py_DECREF(list) on failure in PyLdbResult_FromResult()
       via  53cdfff711a ldb/pyldb: Check errors from PyLdbMessage_FromMessage
      from  cabe817f63e netcmd: models: Create ClaimType in the model layer instead

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ee94d7085570da981b0772c141a76a899c7b0e66
Author: Jo Sutton <josutton at catalyst.net.nz>
Date:   Fri Mar 1 16:23:58 2024 +1300

    ldb: Update ldb.get_opaque() to return talloc‐managed opaque values
    
    Signed-off-by: Jo Sutton <josutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Sun Mar  3 23:33:44 UTC 2024 on atb-devel-224

commit 256320532a45e1e8ff94d2c7b246797a5f8291b6
Author: Jo Sutton <josutton at catalyst.net.nz>
Date:   Fri Mar 1 16:23:53 2024 +1300

    ldb: Update ldb.set_opaque() to accept only supported types
    
    Signed-off-by: Jo Sutton <josutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 81fd42165e9fd55fd15e4abd3172e3e291edc527
Author: Jo Sutton <josutton at catalyst.net.nz>
Date:   Thu Feb 29 13:07:47 2024 +1300

    ldb: Remove trailing whitespace
    
    Signed-off-by: Jo Sutton <josutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ab6cb4bc97255296d53415eafbeb1a71a9d17cc8
Author: Jo Sutton <josutton at catalyst.net.nz>
Date:   Fri Mar 1 16:18:10 2024 +1300

    ldb: Pass a supported opaque type to ldb.set_opaque()
    
    We are about to modify ldb.set_opaque() to accept only certain types,
    and ldb.Ldb is not one of those types.
    
    Pass in a value that is supported and whose lifetime is guaranteed to
    outlive the Ldb object.
    
    Signed-off-by: Jo Sutton <josutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 35e7ce88dd7694663a0c5f171f6a0fa751265902
Author: Jo Sutton <josutton at catalyst.net.nz>
Date:   Fri Mar 1 16:06:49 2024 +1300

    ldb: Add tests for Python set_opaque() and get_opaque()
    
    Signed-off-by: Jo Sutton <josutton at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 757036cefe589248ace0d6da2ef70f9a7ff19554
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Nov 14 19:12:02 2023 +1300

    pyldb: Remove unused and broken Python access to LDB module API
    
    These exposed the private LDB modules API to python, and was
    untested and broken since LDB was made async internally as
    it never called ldb_wait() on the result.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 7a38a98871b63b57ae4e8bbb6c59213f8271a1b5
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Dec 6 11:18:47 2023 +1300

    pyldb: Improve docstric for whoami(), which takes no arguments.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit f8fcd21812d307d63639755221662568203e6e53
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Dec 5 11:59:46 2023 +1300

    pyldb: Remove last caller to and definition of PyLdb_Check()
    
    This is now checked by PyArg_ParseTupleAndKeywords().
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 61e5958a3acf2169fc25ba7ec71b67ad08c38012
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Dec 5 11:53:58 2023 +1300

    pyldb: Use "O!" to specify the type of py_ldb
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 8b0d00a8e3e9fb427db6eef565de7b09e42784f8
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Dec 5 10:34:56 2023 +1300

    pyldb: Move PyErr_LDB_OR_RAISE() and PyErr_LDB_DN_OR_RAISE() into pyldb.h
    
    While these style of macros are against our coding style, it is still better
    to have them in a single place, and while pyldb.h is technically public
    Samba is the only user of the C bindings.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 6c3ca9e4967746af5bf087a339e368d4a0bf9e96
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Dec 5 10:31:48 2023 +1300

    dns: Use pyldb_check_type() in PyErr_LDB_DN_OR_RAISE()
    
    This prepares to move this macro into pyldb.h
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 0839999c94838d7d7624be35e8da7dc55100423a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Dec 5 10:30:50 2023 +1300

    dns: Use pyldb_Ldb_AsLdbContext() in PyErr_LDB_OR_RAISE()
    
    This prepares to move this macro into pyldb.h
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 2ba8e656dab4c8cfd7fbde71ecfbbb0930a963b5
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Dec 5 10:27:54 2023 +1300

    dsdb: Use pyldb_check_type() in PyErr_LDB_DN_OR_RAISE()
    
    This prepares to move this macro into pyldb.h
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit da63ee78b3427865b51631a2ffb690b356e0f521
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Dec 5 10:08:23 2023 +1300

    dsdb: Use pyldb_Ldb_AsLdbContext() in PyErr_LDB_OR_RAISE()
    
    This macro already checks the type, so we do not need to call
    py_check_dcerpc_type() and prepares to move this macro into pyldb.h
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit dbdecac5f89c672456940caa4eb526a30837ed6a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jan 31 17:26:45 2024 +1300

    ldb/pyldb: Call Py_DECREF(list) on failure in PyLdbResult_FromResult()
    
    We need to drop the reference to the list we created if we
    are going to fail.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit 53cdfff711aa43d8294648fee209351aaace75aa
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Nov 22 15:01:47 2023 +1300

    ldb/pyldb: Check errors from PyLdbMessage_FromMessage
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

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

Summary of changes:
 WHATSNEW.txt                   |   9 +
 lib/ldb/pyldb.c                | 929 ++++++-----------------------------------
 lib/ldb/pyldb.h                |  21 +-
 lib/ldb/tests/python/api.py    | 128 +++---
 python/samba/tests/segfault.py |   4 -
 source4/dns_server/pydns.c     |  15 -
 source4/dsdb/pydsdb.c          |  15 -
 7 files changed, 217 insertions(+), 904 deletions(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index cad6e08815a..bdd296909d3 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -37,6 +37,15 @@ building Samba and LDB is this way.
 As part of this work, the pyldb-util public library, not known to be
 used by any other software, is made private to Samba.
 
+LDB Module API Python bindings removed
+--------------------------------------
+
+The LDB Modules API, which we do not promise a stable ABI or API for,
+was wrapped in python in early LDB development.  However that wrapping
+never took into account later changes, and so has not worked for a
+number of years.  Samba 4.21 and LDB 2.10 removes this unused and
+broken feature.
+
 REMOVED FEATURES
 ================
 
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index 20b3c26f958..435f2477672 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -66,17 +66,13 @@ static PyTypeObject PyLdbResult;
 static PyTypeObject PyLdbSearchIterator;
 static PyTypeObject PyLdbMessage;
 #define PyLdbMessage_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessage)
-static PyTypeObject PyLdbModule;
 static PyTypeObject PyLdbDn;
 #define pyldb_Dn_Check(ob) PyObject_TypeCheck(ob, &PyLdbDn)
 static PyTypeObject PyLdb;
-#define PyLdb_Check(ob) PyObject_TypeCheck(ob, &PyLdb)
 static PyTypeObject PyLdbMessageElement;
 #define pyldb_MessageElement_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessageElement)
 
 static PyTypeObject PyLdbTree;
-static PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx);
-static PyObject *PyLdbModule_FromModule(struct ldb_module *mod);
 static struct ldb_message_element *PyObject_AsMessageElement(
 						      TALLOC_CTX *mem_ctx,
 						      PyObject *set_obj,
@@ -381,7 +377,13 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
 	}
 
 	for (i = 0; i < result->count; i++) {
-		PyList_SetItem(list, i, PyLdbMessage_FromMessage(result->msgs[i]));
+		PyObject *pymessage = PyLdbMessage_FromMessage(result->msgs[i]);
+		if (pymessage == NULL) {
+			Py_DECREF(ret);
+			Py_DECREF(list);
+			return NULL;
+		}
+		PyList_SetItem(list, i, pymessage);
 	}
 
 	ret->mem_ctx = talloc_new(NULL);
@@ -402,6 +404,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
 		controls = PyList_New(i);
 		if (controls == NULL) {
 			Py_DECREF(ret);
+			Py_DECREF(list);
 			PyErr_NoMemory();
 			return NULL;
 		}
@@ -409,6 +412,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
 			PyObject *ctrl = (PyObject*) PyLdbControl_FromControl(result->controls[i]);
 			if (ctrl == NULL) {
 				Py_DECREF(ret);
+				Py_DECREF(list);
 				Py_DECREF(controls);
 				PyErr_NoMemory();
 				return NULL;
@@ -422,6 +426,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
 		controls = PyList_New(0);
 		if (controls == NULL) {
 			Py_DECREF(ret);
+			Py_DECREF(list);
 			PyErr_NoMemory();
 			return NULL;
 		}
@@ -438,6 +443,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
 	referals = PyList_New(i);
 	if (referals == NULL) {
 		Py_DECREF(ret);
+		Py_DECREF(list);
 		PyErr_NoMemory();
 		return NULL;
 	}
@@ -449,54 +455,6 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
 	return (PyObject *)ret;
 }
 
-/**
- * Create a LDB Result from a Python object.
- * If conversion fails, NULL will be returned and a Python exception set.
- *
- * Note: the result object only includes the messages at the moment; extended
- * result, controls and referrals are ignored.
- *
- * @param mem_ctx Memory context in which to allocate the LDB Result
- * @param obj Python object to convert
- * @return a ldb_result, or NULL if the conversion failed
- */
-static struct ldb_result *PyLdbResult_AsResult(TALLOC_CTX *mem_ctx, 
-					       PyObject *obj)
-{
-	struct ldb_result *res;
-	Py_ssize_t i;
-
-	if (obj == Py_None)
-		return NULL;
-
-	if (!PyList_Check(obj)) {
-		PyErr_SetString(PyExc_ValueError, "Expected list of LDB results");
-		return NULL;
-	}
-
-	res = talloc_zero(mem_ctx, struct ldb_result);
-	if (res == NULL) {
-		PyErr_NoMemory();
-		return NULL;
-	}
-	res->count = PyList_Size(obj);
-	res->msgs = talloc_array(res, struct ldb_message *, res->count);
-	if (res->msgs == NULL) {
-		talloc_free(res);
-		PyErr_NoMemory();
-		return NULL;
-	}
-	for (i = 0; i < res->count; i++) {
-		PyObject *item = PyList_GetItem(obj, i);
-		if (item == NULL) {
-			talloc_free(res);
-			return NULL;
-		}
-		res->msgs[i] = pyldb_Message_AsMessage(item);
-	}
-	return res;
-}
-
 static PyObject *py_ldb_dn_validate(PyLdbDnObject *self,
 		PyObject *Py_UNUSED(ignored))
 {
@@ -520,7 +478,7 @@ static PyObject *py_ldb_dn_is_null(PyLdbDnObject *self,
 {
 	return PyBool_FromLong(ldb_dn_is_null(self->dn));
 }
- 
+
 static PyObject *py_ldb_dn_get_casefold(PyLdbDnObject *self,
 		PyObject *Py_UNUSED(ignored))
 {
@@ -844,7 +802,7 @@ static PyObject *py_ldb_dn_get_rdn_value(PyLdbDnObject *self,
 }
 
 static PyMethodDef py_ldb_dn_methods[] = {
-	{ "validate", (PyCFunction)py_ldb_dn_validate, METH_NOARGS, 
+	{ "validate", (PyCFunction)py_ldb_dn_validate, METH_NOARGS,
 		"S.validate() -> bool\n"
 		"Validate DN is correct." },
 	{ "is_valid", (PyCFunction)py_ldb_dn_is_valid, METH_NOARGS,
@@ -876,7 +834,7 @@ static PyMethodDef py_ldb_dn_methods[] = {
 	{ "parent", (PyCFunction)py_ldb_dn_get_parent, METH_NOARGS,
    		"S.parent() -> dn\n"
 		"Get the parent for this DN." },
-	{ "add_child", (PyCFunction)py_ldb_dn_add_child, METH_VARARGS, 
+	{ "add_child", (PyCFunction)py_ldb_dn_add_child, METH_VARARGS,
 		"S.add_child(dn) -> bool\n"
 		"Add a child DN to this DN." },
 	{ "add_base", (PyCFunction)py_ldb_dn_add_base, METH_VARARGS,
@@ -1003,15 +961,11 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa
 	PyLdbDnObject *py_ret = NULL;
 	const char * const kwnames[] = { "ldb", "dn", NULL };
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O"PYARG_STR_UNI,
+	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!"PYARG_STR_UNI,
 					 discard_const_p(char *, kwnames),
-					 &py_ldb, "utf8", &str))
+					 &PyLdb, &py_ldb, "utf8", &str))
 		goto out;
 
-	if (!PyLdb_Check(py_ldb)) {
-		PyErr_SetString(PyExc_TypeError, "Expected Ldb");
-		goto out;
-	}
 	ldb_ctx = pyldb_Ldb_AS_LDBCONTEXT(py_ldb);
 
 	mem_ctx = talloc_new(NULL);
@@ -2460,54 +2414,120 @@ static PyObject *py_ldb_get_opaque(PyLdbObject *self, PyObject *args)
 	if (data == NULL)
 		Py_RETURN_NONE;
 
-	/* FIXME: More interpretation */
+	if (data == (void *)1) {
+		/*
+		 * This value is sometimes used to indicate that a opaque is
+		 * set.
+		 */
+		Py_RETURN_TRUE;
+	}
 
-	Py_RETURN_TRUE;
+	{
+		/*
+		 * Let’s hope the opaque data is actually a talloc pointer,
+		 * otherwise calling this would be Very Bad.
+		 */
+		const bool *opaque = talloc_get_type(data, bool);
+		if (opaque != NULL) {
+			return PyBool_FromLong(*opaque);
+		}
+	}
+
+	{
+		const unsigned long long *opaque = talloc_get_type(
+			data, unsigned long long);
+		if (opaque != NULL) {
+			return PyLong_FromUnsignedLongLong(*opaque);
+		}
+	}
+
+	{
+		const char *opaque = talloc_get_type(data, char);
+		if (opaque != NULL) {
+			return PyUnicode_FromString(opaque);
+		}
+	}
+
+	PyErr_SetString(PyExc_ValueError, "Unsupported type for opaque");
+	return NULL;
 }
 
 static PyObject *py_ldb_set_opaque(PyLdbObject *self, PyObject *args)
 {
 	char *name;
 	PyObject *data;
+	void *value = NULL;
+	int ret;
 
 	if (!PyArg_ParseTuple(args, "sO", &name, &data))
 		return NULL;
 
-	/* FIXME: More interpretation */
-
-	ldb_set_opaque(pyldb_Ldb_AS_LDBCONTEXT(self), name, data);
-
-	Py_RETURN_NONE;
-}
-
-static PyObject *py_ldb_modules(PyLdbObject *self,
-		PyObject *Py_UNUSED(ignored))
-{
-	struct ldb_context *ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
-	PyObject *ret = PyList_New(0);
-	struct ldb_module *mod;
+	if (data == Py_None) {
+		value = NULL;
+	} else if (PyBool_Check(data)) {
+		bool *opaque = NULL;
+		bool b;
+		{
+			const int is_true = PyObject_IsTrue(data);
+			if (is_true == -1) {
+				return NULL;
+			}
+			b = is_true;
+		}
 
-	if (ret == NULL) {
-		return PyErr_NoMemory();
-	}
-	for (mod = ldb->modules; mod; mod = mod->next) {
-		PyObject *item = PyLdbModule_FromModule(mod);
-		int res = 0;
-		if (item == NULL) {
-			PyErr_SetString(PyExc_RuntimeError,
-				"Failed to load LdbModule");
-			Py_CLEAR(ret);
+		opaque = talloc(self->mem_ctx, bool);
+		if (opaque == NULL) {
+			return PyErr_NoMemory();
+		}
+		*opaque = b;
+		value = opaque;
+	} else if (PyLong_Check(data)) {
+		unsigned long long *opaque = NULL;
+		const unsigned long long n = PyLong_AsUnsignedLongLong(data);
+		if (n == -1 && PyErr_Occurred()) {
 			return NULL;
 		}
-		res = PyList_Append(ret, item);
-		Py_CLEAR(item);
-		if (res == -1) {
-			Py_CLEAR(ret);
+
+		opaque = talloc(self->mem_ctx, unsigned long long);
+		if (opaque == NULL) {
+			return PyErr_NoMemory();
+		}
+		*opaque = n;
+		value = opaque;
+	} else if (PyUnicode_Check(data)) {
+		char *opaque = NULL;
+		const char *s = PyUnicode_AsUTF8(data);
+		if (s == NULL) {
 			return NULL;
 		}
+
+		opaque = talloc_strdup(self->mem_ctx, s);
+		if (opaque == NULL) {
+			return PyErr_NoMemory();
+		}
+
+		/*
+		 * Assign the right type to the talloc pointer, so that
+		 * py_ldb_get_opaque() can recognize it.
+		 */
+		talloc_set_name_const(opaque, "char");
+
+		value = opaque;
+	} else {
+		PyErr_SetString(PyExc_ValueError,
+				"Unsupported type for opaque");
+		return NULL;
 	}
 
-	return ret;
+	ret = ldb_set_opaque(pyldb_Ldb_AS_LDBCONTEXT(self), name, value);
+	if (ret) {
+		PyErr_SetLdbError(PyExc_LdbError,
+				  ret,
+				  pyldb_Ldb_AS_LDBCONTEXT(self));
+		return NULL;
+	}
+
+	Py_RETURN_NONE;
 }
 
 static PyObject *py_ldb_sequence_number(PyLdbObject *self, PyObject *args)
@@ -2581,29 +2601,29 @@ static PyObject *py_ldb_register_test_extensions(PyLdbObject *self,
 
 
 static PyMethodDef py_ldb_methods[] = {
-	{ "set_debug", (PyCFunction)py_ldb_set_debug, METH_VARARGS, 
+	{ "set_debug", (PyCFunction)py_ldb_set_debug, METH_VARARGS,
 		"S.set_debug(callback) -> None\n"
 		"Set callback for LDB debug messages.\n"
 		"The callback should accept a debug level and debug text." },
-	{ "set_create_perms", (PyCFunction)py_ldb_set_create_perms, METH_VARARGS, 
+	{ "set_create_perms", (PyCFunction)py_ldb_set_create_perms, METH_VARARGS,
 		"S.set_create_perms(mode) -> None\n"
 		"Set mode to use when creating new LDB files." },
 	{ "set_modules_dir", (PyCFunction)py_ldb_set_modules_dir, METH_VARARGS,
 		"S.set_modules_dir(path) -> None\n"
 		"Set path LDB should search for modules" },
-	{ "transaction_start", (PyCFunction)py_ldb_transaction_start, METH_NOARGS, 
+	{ "transaction_start", (PyCFunction)py_ldb_transaction_start, METH_NOARGS,
 		"S.transaction_start() -> None\n"
 		"Start a new transaction." },
 	{ "transaction_prepare_commit", (PyCFunction)py_ldb_transaction_prepare_commit, METH_NOARGS,
 		"S.transaction_prepare_commit() -> None\n"
 		"prepare to commit a new transaction (2-stage commit)." },
-	{ "transaction_commit", (PyCFunction)py_ldb_transaction_commit, METH_NOARGS, 
+	{ "transaction_commit", (PyCFunction)py_ldb_transaction_commit, METH_NOARGS,
 		"S.transaction_commit() -> None\n"
 		"commit a new transaction." },
-	{ "transaction_cancel", (PyCFunction)py_ldb_transaction_cancel, METH_NOARGS, 
+	{ "transaction_cancel", (PyCFunction)py_ldb_transaction_cancel, METH_NOARGS,
 		"S.transaction_cancel() -> None\n"
 		"cancel a new transaction." },
-	{ "setup_wellknown_attributes", (PyCFunction)py_ldb_setup_wellknown_attributes, METH_NOARGS, 
+	{ "setup_wellknown_attributes", (PyCFunction)py_ldb_setup_wellknown_attributes, METH_NOARGS,
 		NULL },
 	{ "get_root_basedn", (PyCFunction)py_ldb_get_root_basedn, METH_NOARGS,
 		NULL },
@@ -2683,16 +2703,13 @@ static PyMethodDef py_ldb_methods[] = {
 		"S.set_opaque(name, value) -> None\n"
 		"Set an opaque value on this LDB connection. \n"
 		":note: Passing incorrect values may cause crashes." },
-	{ "modules", (PyCFunction)py_ldb_modules, METH_NOARGS,
-		"S.modules() -> list\n"
-		"Return the list of modules on this LDB connection " },
 	{ "sequence_number", (PyCFunction)py_ldb_sequence_number, METH_VARARGS,
 		"S.sequence_number(type) -> value\n"
 		"Return the value of the sequence according to the requested type" },
 	{ "whoami",
 	  (PyCFunction)py_ldb_whoami,
 	  METH_NOARGS,
-	  "S.whoami(type) -> value\n"
+	  "S.whoami() -> value\n"
 	  "Return the RFC4532 whoami string",
 	},
 	{ "_register_test_extensions", (PyCFunction)py_ldb_register_test_extensions, METH_NOARGS,
@@ -2701,51 +2718,6 @@ static PyMethodDef py_ldb_methods[] = {
 	{0},
 };
 
-static PyObject *PyLdbModule_FromModule(struct ldb_module *mod)
-{
-	TALLOC_CTX *mem_ctx = NULL;
-	struct ldb_module *mod_ref = NULL;
-	PyLdbModuleObject *ret;
-
-	mem_ctx = talloc_new(NULL);
-	if (mem_ctx == NULL) {
-		return PyErr_NoMemory();
-	}
-
-	mod_ref = talloc_reference(mem_ctx, mod);
-	if (mod_ref == NULL) {
-		talloc_free(mem_ctx);
-		return PyErr_NoMemory();
-	}
-
-	ret = (PyLdbModuleObject *)PyLdbModule.tp_alloc(&PyLdbModule, 0);
-	if (ret == NULL) {
-		talloc_free(mem_ctx);
-		PyErr_NoMemory();
-		return NULL;
-	}
-	ret->mem_ctx = mem_ctx;
-	ret->mod = mod_ref;
-	return (PyObject *)ret;
-}
-
-static PyObject *py_ldb_get_firstmodule(PyLdbObject *self, void *closure)
-{
-	struct ldb_module *mod = pyldb_Ldb_AS_LDBCONTEXT(self)->modules;
-	if (mod == NULL) {
-		Py_RETURN_NONE;
-	}
-	return PyLdbModule_FromModule(mod);
-}
-
-static PyGetSetDef py_ldb_getset[] = {
-	{
-		.name = discard_const_p(char, "firstmodule"),
-		.get  = (getter)py_ldb_get_firstmodule,
-	},
-	{ .name = NULL },
-};
-
 static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
 {
 	struct ldb_context *ldb_ctx = pyldb_Ldb_AS_LDBCONTEXT(self);
@@ -2784,34 +2756,6 @@ static PySequenceMethods py_ldb_seq = {
 	.sq_contains = (objobjproc)py_ldb_contains,
 };
 
-static PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx)
-{
-	TALLOC_CTX *mem_ctx = NULL;
-	struct ldb_context *ldb_ctx_ref = NULL;
-	PyLdbObject *ret;
-
-	mem_ctx = talloc_new(NULL);
-	if (mem_ctx == NULL) {
-		return PyErr_NoMemory();
-	}
-
-	ldb_ctx_ref = talloc_reference(mem_ctx, ldb_ctx);
-	if (ldb_ctx_ref == NULL) {
-		talloc_free(mem_ctx);
-		return PyErr_NoMemory();
-	}
-
-	ret = (PyLdbObject *)PyLdb.tp_alloc(&PyLdb, 0);
-	if (ret == NULL) {
-		talloc_free(mem_ctx);
-		PyErr_NoMemory();
-		return NULL;
-	}
-	ret->mem_ctx = mem_ctx;
-	ret->ldb_ctx = ldb_ctx_ref;
-	return (PyObject *)ret;
-}
-
 static void py_ldb_dealloc(PyLdbObject *self)
 {
 	talloc_free(self->mem_ctx);
@@ -2825,7 +2769,6 @@ static PyTypeObject PyLdb = {
 	.tp_new = py_ldb_new,
 	.tp_init = (initproc)py_ldb_init,
 	.tp_dealloc = (destructor)py_ldb_dealloc,
-	.tp_getset = py_ldb_getset,
 	.tp_getattro = PyObject_GenericGetAttr,
 	.tp_basicsize = sizeof(PyLdbObject),
 	.tp_doc = "Connection to a LDB database.",
@@ -3074,229 +3017,10 @@ static PyTypeObject PyLdbSearchIterator = {
 	.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
 };
 
-static PyObject *py_ldb_module_repr(PyLdbModuleObject *self)
-{
-	return PyUnicode_FromFormat("<ldb module '%s'>",
-		pyldb_Module_AsModule(self)->ops->name);
-}
-
-static PyObject *py_ldb_module_str(PyLdbModuleObject *self)


-- 
Samba Shared Repository



More information about the samba-cvs mailing list