[SCM] Samba Shared Repository - branch master updated

Kamen Mazdrashki kamenim at samba.org
Wed Nov 10 02:03:01 MST 2010


The branch, master has been updated
       via  7e3419f s4-pyldb: Handle internal errors in py_ldb_contains() properly
       via  38585a7 s4-pydsdb: py_dsdb_am_rodc() may call samdb_rodc() only once to get the job done :)
       via  d073c5f s4-pydsdb: py_dsdb_load_partition_usn() - simplify error handling in
       via  89440dd s4-pydsdb-py_samdb_ntds_objectGUID(): Avoid potential memory leak
       via  06b0596 s4-pydsdb-py_dsdb_get_oid_from_attid(): Avoid potential memory leak
       via  ad5a399 s4-pydsdb.c: Fix small memory leak in py_samdb_set_domain_sid()
      from  4b978b3 s4/syntax: Add tests for DN+String and DN+Binary

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


- Log -----------------------------------------------------------------
commit 7e3419f32f0a46cbd4926cbc98bf54da27749d31
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Tue Nov 9 00:21:57 2010 +0200

    s4-pyldb: Handle internal errors in py_ldb_contains() properly
    
    It is an exceptional condition for ldb_search() to return
    more than one results during SCOPE_BASE search on DN
    
    Autobuild-User: Kamen Mazdrashki <kamenim at samba.org>
    Autobuild-Date: Wed Nov 10 09:02:00 UTC 2010 on sn-devel-104

commit 38585a74905185e87494c7326d248495b5e01e49
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Mon Nov 8 23:57:31 2010 +0200

    s4-pydsdb: py_dsdb_am_rodc() may call samdb_rodc() only once to get the job done :)

commit d073c5f23ae6563a65af73fd6dc88886099011da
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Mon Nov 8 23:50:23 2010 +0200

    s4-pydsdb: py_dsdb_load_partition_usn() - simplify error handling in
    
    and print on which partition error has occured

commit 89440dd617eb4ff64cda8bf97f1f22ddf94bf717
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Mon Nov 8 23:40:14 2010 +0200

    s4-pydsdb-py_samdb_ntds_objectGUID(): Avoid potential memory leak
    
    in case py_ldb is not a valid LDB

commit 06b0596537e66ed928b24af059ada0472a375f3b
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Mon Nov 8 23:36:09 2010 +0200

    s4-pydsdb-py_dsdb_get_oid_from_attid(): Avoid potential memory leak
    
    in case py_ldb is not a valid LDB

commit ad5a399d54fba103822ba9cbea4515d52eafd1fe
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Mon Nov 8 23:09:44 2010 +0200

    s4-pydsdb.c: Fix small memory leak in py_samdb_set_domain_sid()

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

Summary of changes:
 source4/dsdb/pydsdb.c   |   26 ++++++++++++++------------
 source4/lib/ldb/pyldb.c |   13 +++++++++----
 2 files changed, 23 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index 2471548..16a4cd4 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -134,6 +134,7 @@ static PyObject *py_samdb_set_domain_sid(PyLdbObject *self, PyObject *args)
 	sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid));
 
 	ret = samdb_set_domain_sid(ldb, sid);
+	talloc_free(sid);
 	if (!ret) {
 		PyErr_SetString(PyExc_RuntimeError, "set_domain_sid failed");
 		return NULL;
@@ -244,14 +245,14 @@ static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid))
 		return NULL;
 
+	PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
 	mem_ctx = talloc_new(NULL);
 	if (mem_ctx == NULL) {
 	   PyErr_NoMemory();
 	   return NULL;
 	}
 
-	PyErr_LDB_OR_RAISE(py_ldb, ldb);
-
 	schema = dsdb_get_schema(ldb, NULL);
 
 	if (!schema) {
@@ -413,19 +414,18 @@ static PyObject *py_samdb_ntds_objectGUID(PyObject *self, PyObject *args)
 	TALLOC_CTX *mem_ctx;
 	const struct GUID *guid;
 
-	mem_ctx = talloc_new(NULL);
-	if (mem_ctx == NULL) {
-		PyErr_NoMemory();
-		return NULL;
-	}
-
 	if (!PyArg_ParseTuple(args, "O", &py_ldb)) {
-		talloc_free(mem_ctx);
 		return NULL;
 	}
 
 	PyErr_LDB_OR_RAISE(py_ldb, ldb);
 
+	mem_ctx = talloc_new(NULL);
+	if (mem_ctx == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
 	guid = samdb_ntds_objectGUID(ldb);
 	if (guid == NULL) {
 		PyErr_SetString(PyExc_RuntimeError, "Failed to find NTDS GUID");
@@ -483,8 +483,10 @@ static PyObject *py_dsdb_load_partition_usn(PyObject *self, PyObject *args)
 
 	ret = dsdb_load_partition_usn(ldb, dn, &highest_uSN, &urgent_uSN);
 	if (ret != LDB_SUCCESS) {
-	   char *errstr = talloc_asprintf(mem_ctx, "Failed to load partition uSN - %s", ldb_errstring(ldb));
-	   PyErr_SetString(PyExc_RuntimeError, errstr);
+	   PyErr_Format(PyExc_RuntimeError,
+			"Failed to load partition [%s] uSN - %s",
+			ldb_dn_get_linearized(dn),
+			ldb_errstring(ldb));
 	   talloc_free(mem_ctx);
 	   return NULL;
 	}
@@ -634,7 +636,7 @@ static PyObject *py_dsdb_am_rodc(PyObject *self, PyObject *args)
 	PyErr_LDB_OR_RAISE(py_ldb, ldb);
 
 	ret = samdb_rodc(ldb, &am_rodc);
-	if (samdb_rodc(ldb, &am_rodc) != LDB_SUCCESS) {
+	if (ret != LDB_SUCCESS) {
 		PyErr_SetString(PyExc_RuntimeError, ldb_errstring(ldb));
 		return NULL;
 	}
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index eddc56f..1f5bd1e 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1428,8 +1428,9 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
 	unsigned int count;
 	int ret;
 
-	if (!PyObject_AsDn(ldb_ctx, obj, ldb_ctx, &dn))
+	if (!PyObject_AsDn(ldb_ctx, obj, ldb_ctx, &dn)) {
 		return -1;
+	}
 
 	ret = ldb_search(ldb_ctx, ldb_ctx, &result, dn, LDB_SCOPE_BASE, NULL,
 			 NULL);
@@ -1442,11 +1443,15 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
 
 	talloc_free(result);
 
-	if (count == 0) {
-		return 0;
+	if (count > 1) {
+		PyErr_Format(PyExc_RuntimeError,
+			     "Searching for [%s] dn gave %u results!",
+			     ldb_dn_get_linearized(dn),
+			     count);
+		return -1;
 	}
 
-	return 1;
+	return count;
 }
 
 static PySequenceMethods py_ldb_seq = {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list