[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-2364-g832b929

Jelmer Vernooij jelmer at samba.org
Wed Jun 17 18:46:18 GMT 2009


The branch, master has been updated
       via  832b929ddec9d5fa24b90850aec4cb26d76f50fb (commit)
       via  4d2baca7be36d7cccbb2c632598a4e43ca1dd55e (commit)
       via  0c3769e181c09f45861f3b9f1d05cad8423372c3 (commit)
       via  f1561cd72be1dd3c084dee3406973ffc5911da28 (commit)
       via  a61e11468a64a156c25ca803667642f64baf685d (commit)
       via  28a2c262acf47a4a1f170375ea5e709a31a61ff4 (commit)
       via  7b8fcacda29954c585746c255598b9b180e56e1f (commit)
       via  0c16676642a1cb41f889fac02351fc2509dbecaa (commit)
       via  d4172bbcc579fd446c252f2d7465275e3ee016b1 (commit)
       via  d558d8ab94874a6acc1ff0c843b47d5319099a84 (commit)
       via  c3770f1dc0121cce0e17d64cf918ff425d1263f0 (commit)
       via  2f27d0c762c8f5be416ed38e00150a8ba58e63ad (commit)
      from  ac1d311e9cc47a45d55b781f5dd2cea8ee8936b3 (commit)

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


- Log -----------------------------------------------------------------
commit 832b929ddec9d5fa24b90850aec4cb26d76f50fb
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 20:43:25 2009 +0200

    pyldb: Fix three more (minor) memory leaks.

commit 4d2baca7be36d7cccbb2c632598a4e43ca1dd55e
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 20:32:35 2009 +0200

    pyldb: Fix memory leak in Dn.get_parent().

commit 0c3769e181c09f45861f3b9f1d05cad8423372c3
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 20:23:54 2009 +0200

    pyldb: Fix memory leak in Dn.concat.

commit f1561cd72be1dd3c084dee3406973ffc5911da28
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 20:17:56 2009 +0200

    pyldb/tests: Use different dn's everywhere, to easily spot which test is
    breaking in gdb.

commit a61e11468a64a156c25ca803667642f64baf685d
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 20:17:35 2009 +0200

    pyldb: Fix another memory leak and reference counting error.

commit 28a2c262acf47a4a1f170375ea5e709a31a61ff4
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 19:07:44 2009 +0200

    param/python: Fix memory leak of LoadParm objects.

commit 7b8fcacda29954c585746c255598b9b180e56e1f
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 19:07:22 2009 +0200

    pycredentials: Raise MemoryError when unable to create objects.

commit 0c16676642a1cb41f889fac02351fc2509dbecaa
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 19:01:06 2009 +0200

    pyldb: Fix memory leak of LdbMessage's created from Python.

commit d4172bbcc579fd446c252f2d7465275e3ee016b1
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 19:00:31 2009 +0200

    pycredentials: Fix memory leak.

commit d558d8ab94874a6acc1ff0c843b47d5319099a84
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 18:36:16 2009 +0200

    pyldb: Fix two memory leaks of attribute lists.

commit c3770f1dc0121cce0e17d64cf918ff425d1263f0
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 18:26:40 2009 +0200

    pyldb: Fix segfault, freeing memory too early in search.

commit 2f27d0c762c8f5be416ed38e00150a8ba58e63ad
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Wed Jun 17 18:25:21 2009 +0200

    pyldb: Support getting the parent of special DNs without segfaulting.
    
    Found by: Андрей Григорьев <andrew at ei-grad.ru>

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

Summary of changes:
 source4/auth/credentials/pycredentials.c |   13 ++-
 source4/lib/ldb/pyldb.c                  |  166 ++++++++++++++++++++++++------
 source4/lib/ldb/tests/python/api.py      |  113 +++++++++++---------
 source4/param/pyparam.c                  |   13 ++-
 4 files changed, 220 insertions(+), 85 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/auth/credentials/pycredentials.c b/source4/auth/credentials/pycredentials.c
index de5cc87..b0433ab 100644
--- a/source4/auth/credentials/pycredentials.c
+++ b/source4/auth/credentials/pycredentials.c
@@ -38,7 +38,18 @@ static PyObject *PyString_FromStringOrNULL(const char *str)
 
 static PyObject *py_creds_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 {
-	return py_talloc_import(type, cli_credentials_init(NULL));
+	py_talloc_Object *ret = (py_talloc_Object *)type->tp_alloc(type, 0);
+	if (ret == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+	ret->talloc_ctx = talloc_new(NULL);
+	if (ret->talloc_ctx == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+	ret->ptr = cli_credentials_init(ret->talloc_ctx);
+	return (PyObject *)ret;
 }
 
 static PyObject *py_creds_get_username(py_talloc_Object *self)
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 52d8530..9bdd71d 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -206,7 +206,25 @@ static int py_ldb_dn_compare(PyLdbDnObject *dn1, PyLdbDnObject *dn2)
 static PyObject *py_ldb_dn_get_parent(PyLdbDnObject *self)
 {
 	struct ldb_dn *dn = PyLdbDn_AsDn((PyObject *)self);
-	return PyLdbDn_FromDn(ldb_dn_get_parent(NULL, dn));
+	struct ldb_dn *parent;
+	PyLdbDnObject *py_ret;
+	TALLOC_CTX *mem_ctx = talloc_new(NULL);
+
+	parent = ldb_dn_get_parent(mem_ctx, dn);
+	if (parent == NULL) {
+		talloc_free(mem_ctx);
+		Py_RETURN_NONE;
+	}
+
+	py_ret = (PyLdbDnObject *)PyLdbDn.tp_alloc(&PyLdbDn, 0);
+	if (py_ret == NULL) {
+		PyErr_NoMemory();
+		talloc_free(mem_ctx);
+		return NULL;
+	}
+	py_ret->mem_ctx = mem_ctx;
+	py_ret->dn = parent;
+	return (PyObject *)py_ret;
 }
 
 #define dn_ldb_ctx(dn) ((struct ldb_context *)dn)
@@ -287,11 +305,20 @@ static PyObject *py_ldb_dn_concat(PyLdbDnObject *self, PyObject *py_other)
 {
 	struct ldb_dn *dn = PyLdbDn_AsDn((PyObject *)self), 
 				  *other;
-	struct ldb_dn *ret = ldb_dn_copy(NULL, dn);
+	PyLdbDnObject *py_ret;
+	
 	if (!PyObject_AsDn(NULL, py_other, NULL, &other))
 		return NULL;
-	ldb_dn_add_child(ret, other);
-	return PyLdbDn_FromDn(ret);
+
+	py_ret = (PyLdbDnObject *)PyLdbDn.tp_alloc(&PyLdbDn, 0);
+	if (py_ret == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+	py_ret->mem_ctx = talloc_new(NULL);
+	py_ret->dn = ldb_dn_copy(py_ret->mem_ctx, dn);
+	ldb_dn_add_child(py_ret->dn, other);
+	return (PyObject *)py_ret;
 }
 
 static PySequenceMethods py_ldb_dn_seq = {
@@ -305,6 +332,7 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa
 	char *str;
 	PyObject *py_ldb;
 	struct ldb_context *ldb_ctx;
+	TALLOC_CTX *mem_ctx;
 	PyLdbDnObject *py_ret;
 	const char * const kwnames[] = { "ldb", "dn", NULL };
 
@@ -315,21 +343,27 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa
 
 	ldb_ctx = PyLdb_AsLdbContext(py_ldb);
 
-	ret = ldb_dn_new(ldb_ctx, ldb_ctx, str);
-	/* ldb_dn_new() doesn't accept NULL as memory context, so 
-	   we do it this way... */
-	talloc_steal(NULL, ret);
+	mem_ctx = talloc_new(NULL);
+	if (mem_ctx == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	ret = ldb_dn_new(mem_ctx, ldb_ctx, str);
 
 	if (ret == NULL || !ldb_dn_validate(ret)) {
+		talloc_free(mem_ctx);
 		PyErr_SetString(PyExc_ValueError, "unable to parse dn string");
 		return NULL;
 	}
 
 	py_ret = (PyLdbDnObject *)type->tp_alloc(type, 0);
 	if (ret == NULL) {
+		talloc_free(mem_ctx);
 		PyErr_NoMemory();
 		return NULL;
 	}
+	py_ret->mem_ctx = mem_ctx;
 	py_ret->dn = ret;
 	return (PyObject *)py_ret;
 }
@@ -337,6 +371,11 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa
 PyObject *PyLdbDn_FromDn(struct ldb_dn *dn)
 {
 	PyLdbDnObject *py_ret;
+
+	if (dn == NULL) {
+		Py_RETURN_NONE;
+	}
+
 	py_ret = (PyLdbDnObject *)PyLdbDn.tp_alloc(&PyLdbDn, 0);
 	if (py_ret == NULL) {
 		PyErr_NoMemory();
@@ -536,17 +575,19 @@ static PyObject *py_ldb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs
 {
 	PyLdbObject *ret;
 	struct ldb_context *ldb;
-	ldb = ldb_init(NULL, NULL);
-	if (ldb == NULL) {
+	ret = (PyLdbObject *)type->tp_alloc(type, 0);
+	if (ret == NULL) {
 		PyErr_NoMemory();
 		return NULL;
 	}
+	ret->mem_ctx = talloc_new(NULL);
+	ldb = ldb_init(ret->mem_ctx, NULL);
 
-	ret = (PyLdbObject *)type->tp_alloc(type, 0);
-	if (ret == NULL) {
+	if (ldb == NULL) {
 		PyErr_NoMemory();
 		return NULL;
 	}
+
 	ret->ldb_ctx = ldb;
 	return (PyObject *)ret;
 }
@@ -607,22 +648,27 @@ static PyObject *py_ldb_add(PyLdbObject *self, PyObject *args)
 	struct ldb_message_element *msgel;
 	struct ldb_message *msg;
 	PyObject *key, *value;
+	TALLOC_CTX *mem_ctx;
 
 	if (!PyArg_ParseTuple(args, "O", &py_msg))
 		return NULL;
 
+	mem_ctx = talloc_new(NULL);
+
 	if (PyDict_Check(py_msg)) {
 		PyObject *dn_value = PyDict_GetItemString(py_msg, "dn");
-		msg = ldb_msg_new(NULL);
+		msg = ldb_msg_new(mem_ctx);
 		msg->elements = talloc_zero_array(msg, struct ldb_message_element, PyDict_Size(py_msg));
 		msg_pos = dict_pos = 0;
 		if (dn_value) {
 		   	if (!PyObject_AsDn(msg, dn_value, PyLdb_AsLdbContext(self), &msg->dn)) {
 		   		PyErr_SetString(PyExc_TypeError, "unable to import dn object");
+				talloc_free(mem_ctx);
 				return NULL;
 			}
 			if (msg->dn == NULL) {
 				PyErr_SetString(PyExc_TypeError, "dn set but not found");
+				talloc_free(mem_ctx);
 				return NULL;
 			}
 		}
@@ -633,6 +679,7 @@ static PyObject *py_ldb_add(PyLdbObject *self, PyObject *args)
 				msgel = PyObject_AsMessageElement(msg->elements, value, 0, key_str);
 				if (msgel == NULL) {
 					PyErr_SetString(PyExc_TypeError, "unable to import element");
+					talloc_free(mem_ctx);
 					return NULL;
 				}
 				memcpy(&msg->elements[msg_pos], msgel, sizeof(*msgel));
@@ -642,6 +689,7 @@ static PyObject *py_ldb_add(PyLdbObject *self, PyObject *args)
 
 		if (msg->dn == NULL) {
 			PyErr_SetString(PyExc_TypeError, "no dn set");
+			talloc_free(mem_ctx);
 			return NULL;
 		}
 
@@ -651,6 +699,7 @@ static PyObject *py_ldb_add(PyLdbObject *self, PyObject *args)
 	}
 
 	ret = ldb_add(PyLdb_AsLdbContext(self), msg);
+	talloc_free(mem_ctx);
 	PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, PyLdb_AsLdbContext(self));
 
 	Py_RETURN_NONE;
@@ -682,17 +731,28 @@ static PyObject *py_ldb_rename(PyLdbObject *self, PyObject *args)
 	struct ldb_dn *dn1, *dn2;
 	int ret;
 	struct ldb_context *ldb;
+	TALLOC_CTX *mem_ctx;
 	if (!PyArg_ParseTuple(args, "OO", &py_dn1, &py_dn2))
 		return NULL;
 
+	mem_ctx = talloc_new(NULL);
+	if (mem_ctx == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
 	ldb = PyLdb_AsLdbContext(self);
-	if (!PyObject_AsDn(NULL, py_dn1, ldb, &dn1))
+	if (!PyObject_AsDn(mem_ctx, py_dn1, ldb, &dn1)) {
+		talloc_free(mem_ctx);
 		return NULL;
+	}
 
-	if (!PyObject_AsDn(NULL, py_dn2, ldb, &dn2))
+	if (!PyObject_AsDn(mem_ctx, py_dn2, ldb, &dn2)) {
+		talloc_free(mem_ctx);
 		return NULL;
+	}
 
 	ret = ldb_rename(ldb, dn1, dn2);
+	talloc_free(mem_ctx);
 	PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, ldb);
 
 	Py_RETURN_NONE;
@@ -805,6 +865,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
 	struct ldb_context *ldb_ctx;
 	struct ldb_control **parsed_controls;
 	struct ldb_dn *base;
+	PyObject *py_ret;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OizOO",
 					 discard_const_p(char *, kwnames),
@@ -816,7 +877,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
 	if (py_attrs == Py_None) {
 		attrs = NULL;
 	} else {
-		attrs = PyList_AsStringList(ldb_ctx, py_attrs, "attrs");
+		attrs = PyList_AsStringList(NULL, py_attrs, "attrs");
 		if (attrs == NULL)
 			return NULL;
 	}
@@ -824,8 +885,10 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
 	if (py_base == Py_None) {
 		base = ldb_get_default_basedn(ldb_ctx);
 	} else {
-		if (!PyObject_AsDn(ldb_ctx, py_base, ldb_ctx, &base))
+		if (!PyObject_AsDn(ldb_ctx, py_base, ldb_ctx, &base)) {
+			talloc_free(attrs);
 			return NULL;
+		}
 	}
 
 	if (py_controls == Py_None) {
@@ -839,6 +902,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
 	res = talloc_zero(ldb_ctx, struct ldb_result);
 	if (res == NULL) {
 		PyErr_NoMemory();
+		talloc_free(attrs);
 		return NULL;
 	}
 
@@ -852,6 +916,8 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
 				   ldb_search_default_callback,
 				   NULL);
 
+	talloc_steal(req, attrs);
+
 	if (ret != LDB_SUCCESS) {
 		talloc_free(res);
 		PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, ldb_ctx);
@@ -872,7 +938,11 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
 		return NULL;
 	}
 
-	return PyLdbResult_FromResult(res);
+	py_ret = PyLdbResult_FromResult(res);
+
+	talloc_free(res);
+
+	return py_ret;
 }
 
 static PyObject *py_ldb_get_opaque(PyLdbObject *self, PyObject *args)
@@ -1118,11 +1188,12 @@ static PyObject *py_ldb_module_del_transaction(PyLdbModuleObject *self)
 
 static PyObject *py_ldb_module_search(PyLdbModuleObject *self, PyObject *args, PyObject *kwargs)
 {
-	PyObject *py_base, *py_tree, *py_attrs;
+	PyObject *py_base, *py_tree, *py_attrs, *py_ret;
 	int ret, scope;
 	struct ldb_request *req;
 	const char * const kwnames[] = { "base", "scope", "tree", "attrs", NULL };
 	struct ldb_module *mod;
+	const char * const*attrs;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiOO",
 					 discard_const_p(char *, kwnames),
@@ -1131,17 +1202,33 @@ static PyObject *py_ldb_module_search(PyLdbModuleObject *self, PyObject *args, P
 
 	mod = self->mod;
 
+	if (py_attrs == Py_None) {
+		attrs = NULL;
+	} else {
+		attrs = PyList_AsStringList(NULL, py_attrs, "attrs");
+		if (attrs == NULL)
+			return NULL;
+	}
+
 	ret = ldb_build_search_req(&req, mod->ldb, NULL, PyLdbDn_AsDn(py_base), 
-			     scope, NULL /* expr */, py_attrs == Py_None?NULL:PyList_AsStringList(req, py_attrs, "attrs"),
+			     scope, NULL /* expr */, attrs,
 			     NULL /* controls */, NULL, NULL, NULL);
+
+	talloc_steal(req, attrs);
+
 	PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, mod->ldb);
 
+	req->op.search.res = NULL;
+
 	ret = mod->ops->search(mod, req);
-	talloc_free(req);
 
 	PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, mod->ldb);
 
-	return PyLdbResult_FromResult(req->op.search.res);
+	py_ret = PyLdbResult_FromResult(req->op.search.res);
+
+	talloc_free(req);
+
+	return py_ret;	
 }
 
 
@@ -1401,13 +1488,20 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
 	char *name = NULL;
 	const char * const kwnames[] = { "elements", "flags", "name", NULL };
 	PyLdbMessageElementObject *ret;
+	TALLOC_CTX *mem_ctx;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Ois",
 					 discard_const_p(char *, kwnames),
 					 &py_elements, &flags, &name))
 		return NULL;
 
-	el = talloc_zero(NULL, struct ldb_message_element);
+	mem_ctx = talloc_new(NULL);
+	if (mem_ctx == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	el = talloc_zero(mem_ctx, struct ldb_message_element);
 
 	if (py_elements != NULL) {
 		int i;
@@ -1427,7 +1521,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
 		} else {
 			PyErr_SetString(PyExc_TypeError, 
 					"Expected string or list");
-			talloc_free(el);
+			talloc_free(mem_ctx);
 			return NULL;
 		}
 	}
@@ -1438,12 +1532,12 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
 	ret = (PyLdbMessageElementObject *)PyLdbMessageElement.tp_alloc(&PyLdbMessageElement, 0);
 	if (ret == NULL) {
 		PyErr_NoMemory();
-		talloc_free(el);
+		talloc_free(mem_ctx);
 		return NULL;
 	}
 
-	ret->mem_ctx = talloc_new(NULL);
-	ret->el = talloc_reference(ret->mem_ctx, el);
+	ret->mem_ctx = mem_ctx;
+	ret->el = el;
 	return (PyObject *)ret;
 }
 
@@ -1642,18 +1736,24 @@ static PyObject *py_ldb_msg_new(PyTypeObject *type, PyObject *args, PyObject *kw
 		return NULL;
 	}
 
-	if (pydn != NULL)
-		if (!PyObject_AsDn(NULL, pydn, NULL, &ret->dn))
+	if (pydn != NULL) {
+		struct ldb_dn *dn;
+		if (!PyObject_AsDn(NULL, pydn, NULL, &dn)) {
+			talloc_free(ret);
 			return NULL;
+		}
+		ret->dn = talloc_reference(ret, dn);
+	}
 
 	py_ret = (PyLdbMessageObject *)type->tp_alloc(type, 0);
 	if (py_ret == NULL) {
 		PyErr_NoMemory();
+		talloc_free(ret);
 		return NULL;
 	}
 
 	py_ret->mem_ctx = talloc_new(NULL);
-	py_ret->msg = talloc_reference(py_ret->mem_ctx, ret);
+	py_ret->msg = talloc_steal(py_ret->mem_ctx, ret);
 	return (PyObject *)py_ret;
 }
 
@@ -1673,12 +1773,14 @@ PyObject *PyLdbMessage_FromMessage(struct ldb_message *msg)
 
 static PyObject *py_ldb_msg_get_dn(PyLdbMessageObject *self, void *closure)
 {
-	return PyLdbDn_FromDn(PyLdbMessage_AsMessage(self)->dn);
+	struct ldb_message *msg = PyLdbMessage_AsMessage(self);
+	return PyLdbDn_FromDn(msg->dn);
 }
 
 static int py_ldb_msg_set_dn(PyLdbMessageObject *self, PyObject *value, void *closure)
 {
-	PyLdbMessage_AsMessage(self)->dn = PyLdbDn_AsDn(value);
+	struct ldb_message *msg = PyLdbMessage_AsMessage(self);
+	msg->dn = talloc_reference(msg, PyLdbDn_AsDn(value));
 	return 0;
 }
 
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 07500e2..05e3da7 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -14,6 +14,7 @@ def filename():
     return os.tempnam()
 
 class NoContextTests(unittest.TestCase):
+
     def test_valid_attr_name(self):
         self.assertTrue(ldb.valid_attr_name("foo"))
         self.assertFalse(ldb.valid_attr_name("24foo"))
@@ -28,6 +29,7 @@ class NoContextTests(unittest.TestCase):
 
 
 class SimpleLdb(unittest.TestCase):
+
     def test_connect(self):
         ldb.Ldb(filename())
 
@@ -86,23 +88,23 @@ class SimpleLdb(unittest.TestCase):
 
     def test_search_scope_base(self):
         l = ldb.Ldb(filename())
-        self.assertEquals(len(l.search(ldb.Dn(l, "dc=foo"), 
+        self.assertEquals(len(l.search(ldb.Dn(l, "dc=foo1"), 
                           ldb.SCOPE_ONELEVEL)), 0)
 
     def test_delete(self):
         l = ldb.Ldb(filename())
-        self.assertRaises(ldb.LdbError, lambda: l.delete(ldb.Dn(l, "dc=foo")))
+        self.assertRaises(ldb.LdbError, lambda: l.delete(ldb.Dn(l, "dc=foo2")))
 
     def test_contains(self):
         l = ldb.Ldb(filename())
-        self.assertFalse(ldb.Dn(l, "dc=foo") in l)
+        self.assertFalse(ldb.Dn(l, "dc=foo3") in l)
         l = ldb.Ldb(filename())
         m = ldb.Message()
-        m.dn = ldb.Dn(l, "dc=foo")
+        m.dn = ldb.Dn(l, "dc=foo3")
         m["b"] = ["a"]
         l.add(m)
         try:
-            self.assertTrue(ldb.Dn(l, "dc=foo") in l)
+            self.assertTrue(ldb.Dn(l, "dc=foo3") in l)
         finally:
             l.delete(m.dn)
 
@@ -125,45 +127,45 @@ class SimpleLdb(unittest.TestCase):
     def test_add(self):
         l = ldb.Ldb(filename())
         m = ldb.Message()
-        m.dn = ldb.Dn(l, "dc=foo")
+        m.dn = ldb.Dn(l, "dc=foo4")
         m["bla"] = "bla"
         self.assertEquals(len(l.search()), 1)
         l.add(m)
         try:


-- 
Samba Shared Repository


More information about the samba-cvs mailing list