[SCM] Samba Shared Repository - branch master updated

Matthieu Patou mat at samba.org
Fri Mar 30 04:00:02 MDT 2012


The branch, master has been updated
       via  40a4aea ldb: Permit desactivation of autocomit for every ldb_xxx_ctrl function
      from  5df1c11 Start to add truncate checks on all uses of strlcpy(). Reading lwn has it's uses :-).

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


- Log -----------------------------------------------------------------
commit 40a4aea8918c2637703af03383f440d068820e48
Author: Matthieu Patou <mat at matws.net>
Date:   Fri Mar 30 01:24:07 2012 -0700

    ldb: Permit desactivation of autocomit for every ldb_xxx_ctrl function
    
    Autobuild-User: Matthieu Patou <mat at samba.org>
    Autobuild-Date: Fri Mar 30 11:59:09 CEST 2012 on sn-devel-104

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

Summary of changes:
 lib/ldb/tools/cmdline.c   |    1 +
 lib/ldb/tools/cmdline.h   |    1 +
 lib/ldb/tools/ldbadd.c    |    2 +-
 lib/ldb/tools/ldbdel.c    |    8 ++++----
 lib/ldb/tools/ldbedit.c   |    6 +++---
 lib/ldb/tools/ldbmodify.c |   12 ++++++------
 lib/ldb/tools/ldbutil.c   |   15 +++++++++------
 lib/ldb/tools/ldbutil.h   |    6 +++---
 8 files changed, 28 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/tools/cmdline.c b/lib/ldb/tools/cmdline.c
index a06445f..ff3c1cd 100644
--- a/lib/ldb/tools/cmdline.c
+++ b/lib/ldb/tools/cmdline.c
@@ -59,6 +59,7 @@ static struct poptOption builtin_popt_options[] = {
 	{ "relax", 0, POPT_ARG_NONE, NULL, CMDLINE_RELAX, "pass relax control", NULL },
 	{ "cross-ncs", 0, POPT_ARG_NONE, NULL, 'N', "search across NC boundaries", NULL },
 	{ "extended-dn", 0, POPT_ARG_NONE, NULL, 'E', "show extended DNs", NULL },
+	{ "noautocommit", 0, POPT_ARG_NONE, &options.noautocommit, 1, "do not commit after each ldif message", NULL },
 	{ NULL }
 };
 
diff --git a/lib/ldb/tools/cmdline.h b/lib/ldb/tools/cmdline.h
index 416bf51..672c917 100644
--- a/lib/ldb/tools/cmdline.h
+++ b/lib/ldb/tools/cmdline.h
@@ -44,6 +44,7 @@ struct ldb_cmdline {
 	const char **controls;
 	int show_binary;
 	int tracing;
+	bool noautocommit;
 };
 
 struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc,
diff --git a/lib/ldb/tools/ldbadd.c b/lib/ldb/tools/ldbadd.c
index 47fd261..a073f51 100644
--- a/lib/ldb/tools/ldbadd.c
+++ b/lib/ldb/tools/ldbadd.c
@@ -79,7 +79,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
 			continue;
 		}
 
-		ret = ldb_add_ctrl(ldb, ldif->msg,req_ctrls);
+		ret = ldb_add_ctrl(ldb, ldif->msg,req_ctrls, true);
 		if (ret != LDB_SUCCESS) {
 			fprintf(stderr, "ERR: %s : \"%s\" on DN %s\n",
 				ldb_strerror(ret), ldb_errstring(ldb),
diff --git a/lib/ldb/tools/ldbdel.c b/lib/ldb/tools/ldbdel.c
index 8036d09..ae042da 100644
--- a/lib/ldb/tools/ldbdel.c
+++ b/lib/ldb/tools/ldbdel.c
@@ -41,7 +41,7 @@ static int dn_cmp(struct ldb_message **msg1, struct ldb_message **msg2)
 	return ldb_dn_compare((*msg1)->dn, (*msg2)->dn);
 }
 
-static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn,struct ldb_control **req_ctrls)
+static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn,struct ldb_control **req_ctrls, bool doautocommit)
 {
 	int ret;
 	unsigned int i, total=0;
@@ -55,7 +55,7 @@ static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn,struc
 	TYPESAFE_QSORT(res->msgs, res->count, dn_cmp);
 
 	for (i = 0; i < res->count; i++) {
-		if (ldb_delete_ctrl(ldb, res->msgs[i]->dn,req_ctrls) == LDB_SUCCESS) {
+		if (ldb_delete_ctrl(ldb, res->msgs[i]->dn,req_ctrls, doautocommit) == LDB_SUCCESS) {
 			total++;
 		} else {
 			printf("Failed to delete '%s' - %s\n",
@@ -114,9 +114,9 @@ int main(int argc, const char **argv)
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
 		if (options->recursive) {
-			ret = ldb_delete_recursive(ldb, dn,req_ctrls);
+			ret = ldb_delete_recursive(ldb, dn,req_ctrls, !options->noautocommit);
 		} else {
-			ret = ldb_delete_ctrl(ldb, dn,req_ctrls);
+			ret = ldb_delete_ctrl(ldb, dn,req_ctrls, !options->noautocommit);
 			if (ret == LDB_SUCCESS) {
 				printf("Deleted 1 record\n");
 			}
diff --git a/lib/ldb/tools/ldbedit.c b/lib/ldb/tools/ldbedit.c
index cf4ab3f..0a88efa 100644
--- a/lib/ldb/tools/ldbedit.c
+++ b/lib/ldb/tools/ldbedit.c
@@ -81,7 +81,7 @@ static int modify_record(struct ldb_context *ldb,
 		ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_MODIFY, mod);
 	}
 
-	if (ldb_modify_ctrl(ldb, mod, req_ctrls) != LDB_SUCCESS) {
+	if (ldb_modify_ctrl(ldb, mod, req_ctrls, true) != LDB_SUCCESS) {
 		fprintf(stderr, "failed to modify %s - %s\n",
 			ldb_dn_get_linearized(msg1->dn), ldb_errstring(ldb));
 		ret = -1;
@@ -139,7 +139,7 @@ static int merge_edits(struct ldb_context *ldb,
 			if (options->verbose > 0) {
 				ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_ADD, msgs2[i]);
 			}
-			if (ldb_add_ctrl(ldb, msgs2[i], req_ctrls) != LDB_SUCCESS) {
+			if (ldb_add_ctrl(ldb, msgs2[i], req_ctrls, true) != LDB_SUCCESS) {
 				fprintf(stderr, "failed to add %s - %s\n",
 					ldb_dn_get_linearized(msgs2[i]->dn),
 					ldb_errstring(ldb));
@@ -165,7 +165,7 @@ static int merge_edits(struct ldb_context *ldb,
 			if (options->verbose > 0) {
 				ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_DELETE, msgs1[i]);
 			}
-			if (ldb_delete_ctrl(ldb, msgs1[i]->dn, req_ctrls) != LDB_SUCCESS) {
+			if (ldb_delete_ctrl(ldb, msgs1[i]->dn, req_ctrls, true) != LDB_SUCCESS) {
 				fprintf(stderr, "failed to delete %s - %s\n",
 					ldb_dn_get_linearized(msgs1[i]->dn),
 					ldb_errstring(ldb));
diff --git a/lib/ldb/tools/ldbmodify.c b/lib/ldb/tools/ldbmodify.c
index 2ca7b62..0940303 100644
--- a/lib/ldb/tools/ldbmodify.c
+++ b/lib/ldb/tools/ldbmodify.c
@@ -49,7 +49,7 @@ static void usage(struct ldb_context *ldb)
 /*
   process modifies for one file
 */
-static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
+static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count, bool doautocomit)
 {
 	struct ldb_ldif *ldif;
 	int fun_ret = LDB_SUCCESS, ret;
@@ -69,13 +69,13 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
 		switch (ldif->changetype) {
 		case LDB_CHANGETYPE_NONE:
 		case LDB_CHANGETYPE_ADD:
-			ret = ldb_add_ctrl(ldb, ldif->msg,req_ctrls);
+			ret = ldb_add_ctrl(ldb, ldif->msg, req_ctrls, doautocomit);
 			break;
 		case LDB_CHANGETYPE_DELETE:
-			ret = ldb_delete_ctrl(ldb, ldif->msg->dn,req_ctrls);
+			ret = ldb_delete_ctrl(ldb, ldif->msg->dn, req_ctrls, doautocomit);
 			break;
 		case LDB_CHANGETYPE_MODIFY:
-			ret = ldb_modify_ctrl(ldb, ldif->msg,req_ctrls);
+			ret = ldb_modify_ctrl(ldb, ldif->msg, req_ctrls, doautocomit);
 			break;
 		case LDB_CHANGETYPE_MODRDN:
 			ret = ldb_ldif_parse_modrdn(ldb, ldif, ldif, &olddn,
@@ -133,7 +133,7 @@ int main(int argc, const char **argv)
 	options = ldb_cmdline_process(ldb, argc, argv, usage);
 
 	if (options->argc == 0) {
-		ret = process_file(ldb, stdin, &count);
+		ret = process_file(ldb, stdin, &count, !options->noautocommit);
 	} else {
 		for (i=0;i<options->argc;i++) {
 			const char *fname = options->argv[i];
@@ -143,7 +143,7 @@ int main(int argc, const char **argv)
 				perror(fname);
 				return LDB_ERR_OPERATIONS_ERROR;
 			}
-			ret = process_file(ldb, f, &count);
+			ret = process_file(ldb, f, &count, !options->noautocommit);
 			fclose(f);
 		}
 	}
diff --git a/lib/ldb/tools/ldbutil.c b/lib/ldb/tools/ldbutil.c
index 26f2527..882bc67 100644
--- a/lib/ldb/tools/ldbutil.c
+++ b/lib/ldb/tools/ldbutil.c
@@ -67,7 +67,7 @@ static int ldb_do_autotransaction(struct ldb_context *ldb,
 */
 int ldb_add_ctrl(struct ldb_context *ldb,
 		const struct ldb_message *message,
-		struct ldb_control **controls)
+		struct ldb_control **controls, bool do_transaction)
 {
 	struct ldb_request *req;
 	int ret;
@@ -87,7 +87,8 @@ int ldb_add_ctrl(struct ldb_context *ldb,
 	if (ret != LDB_SUCCESS) return ret;
 
 	/* do request and autostart a transaction */
-	ret = ldb_do_autotransaction(ldb, req);
+	if (do_transaction)
+		ret = ldb_do_autotransaction(ldb, req);
 
 	talloc_free(req);
 	return ret;
@@ -97,7 +98,7 @@ int ldb_add_ctrl(struct ldb_context *ldb,
   same as ldb_delete but accept control
 */
 int ldb_delete_ctrl(struct ldb_context *ldb, struct ldb_dn *dn,
-		struct ldb_control **controls)
+		struct ldb_control **controls, bool do_transaction)
 {
 	struct ldb_request *req;
 	int ret;
@@ -112,7 +113,8 @@ int ldb_delete_ctrl(struct ldb_context *ldb, struct ldb_dn *dn,
 	if (ret != LDB_SUCCESS) return ret;
 
 	/* do request and autostart a transaction */
-	ret = ldb_do_autotransaction(ldb, req);
+	if (do_transaction)
+		ret = ldb_do_autotransaction(ldb, req);
 
 	talloc_free(req);
 	return ret;
@@ -124,7 +126,7 @@ int ldb_delete_ctrl(struct ldb_context *ldb, struct ldb_dn *dn,
 */
 int ldb_modify_ctrl(struct ldb_context *ldb,
                     const struct ldb_message *message,
-                    struct ldb_control **controls)
+                    struct ldb_control **controls, bool do_transaction)
 {
         struct ldb_request *req;
         int ret;
@@ -144,7 +146,8 @@ int ldb_modify_ctrl(struct ldb_context *ldb,
         if (ret != LDB_SUCCESS) return ret;
 
         /* do request and autostart a transaction */
-        ret = ldb_do_autotransaction(ldb, req);
+        if (do_transaction)
+		ret = ldb_do_autotransaction(ldb, req);
 
         talloc_free(req);
         return ret;
diff --git a/lib/ldb/tools/ldbutil.h b/lib/ldb/tools/ldbutil.h
index f8d3f3a..28522b2 100644
--- a/lib/ldb/tools/ldbutil.h
+++ b/lib/ldb/tools/ldbutil.h
@@ -33,12 +33,12 @@
 
 int ldb_add_ctrl(struct ldb_context *ldb,
 		const struct ldb_message *message,
-		struct ldb_control **controls);
+		struct ldb_control **controls, bool do_transaction);
 int ldb_delete_ctrl(struct ldb_context *ldb, struct ldb_dn *dn,
-		struct ldb_control **controls);
+		struct ldb_control **controls, bool do_transaction);
 int ldb_modify_ctrl(struct ldb_context *ldb,
                 const struct ldb_message *message,
-                struct ldb_control **controls);
+                struct ldb_control **controls, bool do_transaction);
 int ldb_search_ctrl(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
 		    struct ldb_result **result, struct ldb_dn *base,
 		    enum ldb_scope scope, const char * const *attrs,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list