[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Thu Nov 19 19:22:36 MST 2009


The branch, master has been updated
       via  a2707a3... ldb:ldb_tdb backend/indexes - Outside API
       via  afb70f9... ldb:ldb_tdb backend/indexes - DN comparison
       via  dda28a9... s4-dsdb: make sure mod_usn list is zeroed on each transaction
       via  47923ea... s4-ldb: added a double-rename test
       via  c99b310... s4-ldb: when -v is specified, show progress of ldbadd/ldbmodify
       via  79a43fb... s4-ldb: make ldb tools line buffered
       via  3b96d08... s4-ldb: fixed an issue in rename/modify indexing
       via  2e46df4... s4-ldb: allow ldap.py test suite to run directly against a file
      from  5cd8b0e... PC Oota Edits.

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


- Log -----------------------------------------------------------------
commit a2707a3248f13a95e1cd7deecdbd2c26226a78b1
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Wed Nov 18 10:44:56 2009 +0100

    ldb:ldb_tdb backend/indexes - Outside API
    
    - The outside API contains "DN" string arguments: Bad. Since in this way we
      fully rely on the outside calls regarding the right DN format. Solution: Use
      always a "struct ldb_dn" entry. Since this one is interchangeable and we can
      handle it in our preferred way.

commit afb70f9176563e2d96886c086ec7d57bf78393b2
Author: Matthias Dieter Wallnöfer <mwallnoefer at yahoo.de>
Date:   Wed Nov 18 10:44:56 2009 +0100

    ldb:ldb_tdb backend/indexes - DN comparison
    
    - DN comparison: The function doesn't seem that efficient. I "upgraded" it a bit
      to be more powerful (added a second length check and do both before the string
      comparison)

commit dda28a9a787c31426f6d653dbdb5a0585b3dc25f
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 20 12:09:24 2009 +1100

    s4-dsdb: make sure mod_usn list is zeroed on each transaction

commit 47923ea5071ba6dca842edb8eb124030576fd4ca
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 20 11:47:54 2009 +1100

    s4-ldb: added a double-rename test
    
    This tests the fix for double rename/add and indexing

commit c99b3100632227dd32c11676b76343f2523cf0de
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 20 11:34:24 2009 +1100

    s4-ldb: when -v is specified, show progress of ldbadd/ldbmodify
    
    This is useful for speed tests with large numbers of records.

commit 79a43fb74313d9ae88d72709e46ab385906af136
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 20 11:33:43 2009 +1100

    s4-ldb: make ldb tools line buffered
    
    this prevents output being buffered when redirected to a file. Useful
    for larger ldb command line operations

commit 3b96d08b299e2fc20fa1c860fcc37fa1a02a72b5
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Nov 18 21:56:24 2009 +1100

    s4-ldb: fixed an issue in rename/modify indexing
    
    When we rename or modify a record, we need to update the indexes at
    the same time. It is important that we use the DN of the actual
    message that is stored in the database to do this, not the DN that was
    passed in by the user. If the two differ in case then the index
    records needs to use the 'real' record DN, as index handling is
    currently case sensitive.

commit 2e46df492ccbfd327e2d37e3951ec995a09c9a7e
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Nov 18 13:27:50 2009 +1100

    s4-ldb: allow ldap.py test suite to run directly against a file
    
    This makes it much easier to debug (as you can break in the ldb
    modules by running gdb on /usr/bin/python)

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

Summary of changes:
 source4/dsdb/samdb/ldb_modules/repl_meta_data.c |   17 ++++---
 source4/lib/ldb/ldb_tdb/ldb_index.c             |   52 +++++++++++++----------
 source4/lib/ldb/ldb_tdb/ldb_tdb.c               |   42 ++++++++----------
 source4/lib/ldb/ldb_tdb/ldb_tdb.h               |    5 +-
 source4/lib/ldb/tests/python/ldap.py            |   30 +++++++++++++-
 source4/lib/ldb/tools/cmdline.c                 |    3 +
 source4/lib/ldb/tools/ldbadd.c                  |    5 ++-
 source4/lib/ldb/tools/ldbmodify.c               |    5 ++-
 8 files changed, 101 insertions(+), 58 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 6c23964..37aa399 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -49,7 +49,6 @@
 struct replmd_private {
 	TALLOC_CTX *la_ctx;
 	struct la_entry *la_list;
-	uint32_t num_ncs;
 	struct nc_entry {
 		struct nc_entry *prev, *next;
 		struct ldb_dn *dn;
@@ -208,11 +207,10 @@ static int replmd_notify_store(struct ldb_module *module)
 	struct replmd_private *replmd_private = 
 		talloc_get_type(ldb_module_get_private(module), struct replmd_private);
 	struct ldb_context *ldb = ldb_module_get_ctx(module);
-	struct nc_entry *modified_partition;
 
-	for (modified_partition = replmd_private->ncs; modified_partition; 
-	     modified_partition = modified_partition->next) {
+	while (replmd_private->ncs) {
 		int ret;
+		struct nc_entry *modified_partition = replmd_private->ncs;
 
 		ret = dsdb_save_partition_usn(ldb, modified_partition->dn, modified_partition->mod_usn);
 		if (ret != LDB_SUCCESS) {
@@ -220,6 +218,8 @@ static int replmd_notify_store(struct ldb_module *module)
 				 ldb_dn_get_linearized(modified_partition->dn)));
 			return ret;
 		}
+		DLIST_REMOVE(replmd_private->ncs, modified_partition);
+		talloc_free(modified_partition);
 	}
 
 	return LDB_SUCCESS;
@@ -2202,15 +2202,18 @@ static int replmd_extended(struct ldb_module *module, struct ldb_request *req)
 static int replmd_start_transaction(struct ldb_module *module)
 {
 	/* create our private structure for this transaction */
-	int i;
 	struct replmd_private *replmd_private = talloc_get_type(ldb_module_get_private(module),
 								struct replmd_private);
 	talloc_free(replmd_private->la_ctx);
 	replmd_private->la_list = NULL;
 	replmd_private->la_ctx = NULL;
 
-	for (i=0; i<replmd_private->num_ncs; i++) {
-		replmd_private->ncs[i].mod_usn = 0;
+	/* free any leftover mod_usn records from cancelled
+	   transactions */
+	while (replmd_private->ncs) {
+		struct nc_entry *e = replmd_private->ncs;
+		DLIST_REMOVE(replmd_private->ncs, e);
+		talloc_free(e);
 	}
 
 	return ldb_next_start_trans(module);
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 55c5c9c..52f9f00 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -60,12 +60,13 @@ int ltdb_index_transaction_start(struct ldb_module *module)
  * differences in string termination */
 static int dn_list_cmp(const struct ldb_val *v1, const struct ldb_val *v2)
 {
-	int ret = strncmp((char *)v1->data, (char *)v2->data, v1->length);
-	if (ret != 0) return ret;
-	if (v2->length > v1->length && v2->data[v1->length] != 0) {
+	if (v1->length > v2->length && v1->data[v2->length] != 0) {
+		return -1;
+	}
+	if (v1->length < v2->length && v2->data[v1->length] != 0) {
 		return 1;
 	}
-	return 0;
+	return strncmp((char *)v1->data, (char *)v2->data, v1->length);
 }
 
 
@@ -1217,7 +1218,7 @@ static int ltdb_index_onelevel(struct ldb_module *module, const struct ldb_messa
 	if (add) {
 		ret = ltdb_index_add1(module, dn, &el, 0);
 	} else { /* delete */
-		ret = ltdb_index_del_value(module, dn, &el, 0);
+		ret = ltdb_index_del_value(module, msg->dn, &el, 0);
 	}
 
 	talloc_free(pdn);
@@ -1271,17 +1272,23 @@ int ltdb_index_add_new(struct ldb_module *module, const struct ldb_message *msg)
 /*
   delete an index entry for one message element
 */
-int ltdb_index_del_value(struct ldb_module *module, const char *dn,
+int ltdb_index_del_value(struct ldb_module *module, struct ldb_dn *dn,
 			 struct ldb_message_element *el, int v_idx)
 {
 	struct ldb_context *ldb;
 	struct ldb_dn *dn_key;
+	const char *dn_str;
 	int ret, i;
 	struct dn_list *list;
 
 	ldb = ldb_module_get_ctx(module);
 
-	if (dn[0] == '@') {
+	dn_str = ldb_dn_get_linearized(dn);
+	if (dn_str == NULL) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	if (dn_str[0] == '@') {
 		return LDB_SUCCESS;
 	}
 
@@ -1309,7 +1316,7 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
 		return ret;
 	}
 
-	i = ltdb_dn_list_find_str(list, dn);
+	i = ltdb_dn_list_find_str(list, dn_str);
 	if (i == -1) {
 		/* nothing to delete */
 		talloc_free(dn_key);
@@ -1333,9 +1340,11 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
   delete the index entries for a element
   return -1 on failure
 */
-int ltdb_index_del_element(struct ldb_module *module, const char *dn, struct ldb_message_element *el)
+int ltdb_index_del_element(struct ldb_module *module, struct ldb_dn *dn,
+			   struct ldb_message_element *el)
 {
 	struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private);
+	const char *dn_str;
 	int ret;
 	unsigned int i;
 
@@ -1344,7 +1353,12 @@ int ltdb_index_del_element(struct ldb_module *module, const char *dn, struct ldb
 		return LDB_SUCCESS;
 	}
 
-	if (dn[0] == '@') {
+	dn_str = ldb_dn_get_linearized(dn);
+	if (dn_str == NULL) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	if (dn_str[0] == '@') {
 		return LDB_SUCCESS;
 	}
 
@@ -1369,7 +1383,6 @@ int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg)
 {
 	struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private);
 	int ret;
-	const char *dn;
 	unsigned int i;
 
 	if (ldb_dn_is_special(msg->dn)) {
@@ -1386,13 +1399,8 @@ int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg)
 		return LDB_SUCCESS;
 	}
 
-	dn = ldb_dn_get_linearized(msg->dn);
-	if (dn == NULL) {
-		return LDB_ERR_OPERATIONS_ERROR;
-	}
-
 	for (i = 0; i < msg->num_elements; i++) {
-		ret = ltdb_index_del_element(module, dn, &msg->elements[i]);
+		ret = ltdb_index_del_element(module, msg->dn, &msg->elements[i]);
 		if (ret != LDB_SUCCESS) {
 			return ret;
 		}
@@ -1430,7 +1438,7 @@ static int delete_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, vo
 	if (ret != LDB_SUCCESS) {
 		ldb_asprintf_errstring(ldb_module_get_ctx(module), 
 				       "Unable to store null index for %s\n",
-				       ldb_dn_get_linearized(dn));
+						ldb_dn_get_linearized(dn));
 		talloc_free(dn);
 		return -1;
 	}
@@ -1465,7 +1473,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
 	ret = ltdb_unpack_data(module, &data, msg);
 	if (ret != 0) {
 		ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid data for index %s\n",
-			  ldb_dn_get_linearized(msg->dn));
+						ldb_dn_get_linearized(msg->dn));
 		talloc_free(msg);
 		return -1;
 	}
@@ -1476,7 +1484,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
 	if (key2.dptr == NULL) {
 		/* probably a corrupt record ... darn */
 		ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s",
-							ldb_dn_get_linearized(msg->dn));
+						ldb_dn_get_linearized(msg->dn));
 		talloc_free(msg);
 		return 0;
 	}
@@ -1495,8 +1503,8 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
 	ret = ltdb_index_onelevel(module, msg, 1);
 	if (ret != LDB_SUCCESS) {
 		ldb_debug(ldb, LDB_DEBUG_ERROR,
-			"Adding special ONE LEVEL index failed (%s)!",
-			ldb_dn_get_linearized(msg->dn));
+			  "Adding special ONE LEVEL index failed (%s)!",
+						ldb_dn_get_linearized(msg->dn));
 		talloc_free(msg);
 		return -1;
 	}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 0a77df7..7fb3cdc 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -498,23 +498,17 @@ static int msg_delete_attribute(struct ldb_module *module,
 				struct ldb_context *ldb,
 				struct ldb_message *msg, const char *name)
 {
-	const char *dn;
 	unsigned int i;
 	int ret;
 	struct ldb_message_element *el;
 
-	dn = ldb_dn_get_linearized(msg->dn);
-	if (dn == NULL) {
-		return -1;
-	}
-
 	el = ldb_msg_find_element(msg, name);
 	if (el == NULL) {
 		return -1;
 	}
 	i = el - msg->elements;
 
-	ret = ltdb_index_del_element(module, dn, el);
+	ret = ltdb_index_del_element(module, msg->dn, el);
 	if (ret != LDB_SUCCESS) {
 		return ret;
 	}
@@ -562,7 +556,7 @@ static int msg_delete_element(struct ldb_module *module,
 				return msg_delete_attribute(module, ldb, msg, name);
 			}
 
-			ret = ltdb_index_del_value(module, ldb_dn_get_linearized(msg->dn), el, i);
+			ret = ltdb_index_del_value(module, msg->dn, el, i);
 			if (ret != LDB_SUCCESS) {
 				return -1;
 			}
@@ -640,7 +634,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 
 		if (ldb_attr_cmp(el->name, "distinguishedName") == 0) {
 			ldb_asprintf_errstring(ldb, "it is not permitted to perform a modify on 'distinguishedName' (use rename instead): %s",
-					       ldb_dn_get_linearized(msg->dn));
+					       ldb_dn_get_linearized(msg2->dn));
 			ret = LDB_ERR_CONSTRAINT_VIOLATION;
 			goto done;
 		}
@@ -649,7 +643,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 		case LDB_FLAG_MOD_ADD:
 			if (el->num_values == 0) {
 				ldb_asprintf_errstring(ldb, "attribute %s on %s specified, but with 0 values (illigal)",
-						       el->name, ldb_dn_get_linearized(msg->dn));
+						       el->name, ldb_dn_get_linearized(msg2->dn));
 				ret = LDB_ERR_CONSTRAINT_VIOLATION;
 				goto done;
 			}
@@ -657,7 +651,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 			if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
 				if (el->num_values > 1) {
 					ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once",
-						               el->name, ldb_dn_get_linearized(msg->dn));
+						               el->name, ldb_dn_get_linearized(msg2->dn));
 					ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
 					goto done;
 				}
@@ -670,7 +664,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 					ret = LDB_ERR_OTHER;
 					goto done;
 				}
-				ret = ltdb_index_add_element(module, msg->dn, el);
+				ret = ltdb_index_add_element(module, msg2->dn, el);
 				if (ret != LDB_SUCCESS) {
 					goto done;
 				}
@@ -679,7 +673,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 				   if the attribute is single-valued */
 				if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
 					ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once",
-						               el->name, ldb_dn_get_linearized(msg->dn));
+						               el->name, ldb_dn_get_linearized(msg2->dn));
 					ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
 					goto done;
 				}
@@ -720,7 +714,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 				el2->values = vals;
 				el2->num_values += el->num_values;
 
-				ret = ltdb_index_add_element(module, msg->dn, el);
+				ret = ltdb_index_add_element(module, msg2->dn, el);
 				if (ret != LDB_SUCCESS) {
 					goto done;
 				}
@@ -732,7 +726,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 			if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
 				if (el->num_values > 1) {
 					ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once",
-						               el->name, ldb_dn_get_linearized(msg->dn));
+						               el->name, ldb_dn_get_linearized(msg2->dn));
 					ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
 					goto done;
 				}
@@ -768,7 +762,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 				goto done;
 			}
 
-			ret = ltdb_index_add_element(module, msg->dn, el);
+			ret = ltdb_index_add_element(module, msg2->dn, el);
 			if (ret != LDB_SUCCESS) {
 				goto done;
 			}
@@ -776,7 +770,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 			break;
 
 		case LDB_FLAG_MOD_DELETE:
-			dn = ldb_dn_get_linearized(msg->dn);
+			dn = ldb_dn_get_linearized(msg2->dn);
 			if (dn == NULL) {
 				ret = LDB_ERR_OTHER;
 				goto done;
@@ -821,7 +815,7 @@ int ltdb_modify_internal(struct ldb_module *module,
 		goto done;
 	}
 
-	ret = ltdb_modified(module, msg->dn);
+	ret = ltdb_modified(module, msg2->dn);
 	if (ret != LDB_SUCCESS) {
 		goto done;
 	}
@@ -885,20 +879,20 @@ static int ltdb_rename(struct ltdb_context *ctx)
 		return ret;
 	}
 
-	msg->dn = ldb_dn_copy(msg, req->op.rename.newdn);
-	if (msg->dn == NULL) {
-		return LDB_ERR_OPERATIONS_ERROR;
-	}
-
 	/* Always delete first then add, to avoid conflicts with
 	 * unique indexes. We rely on the transaction to make this
 	 * atomic
 	 */
-	ret = ltdb_delete_internal(module, req->op.rename.olddn);
+	ret = ltdb_delete_internal(module, msg->dn);
 	if (ret != LDB_SUCCESS) {
 		return ret;
 	}
 
+	msg->dn = ldb_dn_copy(msg, req->op.rename.newdn);
+	if (msg->dn == NULL) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
 	ret = ltdb_add_internal(module, msg);
 
 	return ret;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index b3887a6..0f17c82 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -87,10 +87,11 @@ struct ldb_parse_tree;
 int ltdb_search_indexed(struct ltdb_context *ctx, uint32_t *);
 int ltdb_index_add_new(struct ldb_module *module, const struct ldb_message *msg);
 int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg);
-int ltdb_index_del_element(struct ldb_module *module, const char *dn, struct ldb_message_element *el);
+int ltdb_index_del_element(struct ldb_module *module, struct ldb_dn *dn,
+			   struct ldb_message_element *el);
 int ltdb_index_add_element(struct ldb_module *module, struct ldb_dn *dn, 
 			   struct ldb_message_element *el);
-int ltdb_index_del_value(struct ldb_module *module, const char *dn, 
+int ltdb_index_del_value(struct ldb_module *module, struct ldb_dn *dn,
 			 struct ldb_message_element *el, int v_idx);
 int ltdb_reindex(struct ldb_module *module);
 int ltdb_index_transaction_start(struct ldb_module *module);
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index a77a777..f9801e2 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -8,6 +8,7 @@ import sys
 import time
 import random
 import base64
+import os
 
 sys.path.append("bin/python")
 sys.path.append("../lib/subunit/python")
@@ -108,6 +109,7 @@ class BasicTests(unittest.TestCase):
         self.delete_force(self.ldb, "cn=ldaptestuser3,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer2," + self.base_dn)
+        self.delete_force(self.ldb, "cn=ldaptestuser5,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestgroup2,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
@@ -530,6 +532,28 @@ objectClass: container
 
         self.delete_force(self.ldb, "cn=ldaptestuser3,cn=users," + self.base_dn)
 
+    def test_rename_twice(self):
+        """Tests the rename operation twice - this corresponds to a past bug"""
+        print "Tests the rename twice operation"""
+
+        self.ldb.add({
+             "dn": "cn=ldaptestuser5,cn=users," + self.base_dn,
+             "objectclass": ["user", "person"] })
+
+        ldb.rename("cn=ldaptestuser5,cn=users," + self.base_dn, "cn=ldaptestUSER5,cn=users," + self.base_dn)
+        self.delete_force(self.ldb, "cn=ldaptestuser5,cn=users," + self.base_dn)
+        self.ldb.add({
+             "dn": "cn=ldaptestuser5,cn=users," + self.base_dn,
+             "objectclass": ["user", "person"] })
+        ldb.rename("cn=ldaptestuser5,cn=Users," + self.base_dn, "cn=ldaptestUSER5,cn=users," + self.base_dn)
+        res = ldb.search(expression="cn=ldaptestuser5")
+        print "Found %u records" % len(res)
+        self.assertEquals(len(res), 1, "Wrong number of hits for cn=ldaptestuser5")
+        res = ldb.search(expression="(&(cn=ldaptestuser5)(objectclass=user))")
+        print "Found %u records" % len(res)
+        self.assertEquals(len(res), 1, "Wrong number of hits for (&(cn=ldaptestuser5)(objectclass=user))")
+        self.delete_force(self.ldb, "cn=ldaptestuser5,cn=users," + self.base_dn)
+
     def test_parentGUID(self):
         """Test parentGUID behaviour"""
         print "Testing parentGUID behaviour\n"
@@ -1631,6 +1655,7 @@ member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + self.base_dn + """
         self.delete_force(self.ldb, "cn=ldaptestuser3,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer2," + self.base_dn)
+        self.delete_force(self.ldb, "cn=ldaptestuser5,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestgroup2,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
@@ -1981,7 +2006,10 @@ name: """ + object_name + """
         self.delete_force(self.ldb, "cn=%s,cn=Users,%s" % (object_name, self.base_dn))
 
 if not "://" in host:
-    host = "ldap://%s" % host
+    if os.path.isfile(host):
+        host = "tdb://%s" % host
+    else:
+        host = "ldap://%s" % host
 
 ldb = Ldb(host, credentials=creds, session_info=system_session(), lp=lp)
 gc_ldb = Ldb("%s:3268" % host, credentials=creds,
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index 8f610f7..f0cd0a3 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -99,6 +99,9 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
 
 #endif
 
+	/* make the ldb utilities line buffered */
+	setlinebuf(stdout);
+
 	ret = talloc_zero(ldb, struct ldb_cmdline);
 	if (ret == NULL) {
 		fprintf(stderr, "Out of memory!\n");
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index f022486..a87c99a 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -35,6 +35,7 @@
 #include "tools/cmdline.h"
 
 static int failures;
+static struct ldb_cmdline *options;
 
 static void usage(void)
 {
@@ -69,6 +70,9 @@ static int process_file(struct ldb_context *ldb, FILE *f, int *count)
 			failures++;
 		} else {
 			(*count)++;
+			if (options->verbose) {
+				printf("Added %s\n", ldb_dn_get_linearized(ldif->msg->dn));
+			}
 		}
 		ldb_ldif_read_free(ldb, ldif);
 	}
@@ -82,7 +86,6 @@ int main(int argc, const char **argv)
 {
 	struct ldb_context *ldb;
 	int i, ret=0, count=0;
-	struct ldb_cmdline *options;
 
 	ldb = ldb_init(NULL, NULL);
 
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index d0bca04..4936880 100644
--- a/source4/lib/ldb/tools/ldbmodify.c


-- 
Samba Shared Repository


More information about the samba-cvs mailing list