diff options
Diffstat (limited to 'lib/ldb')
-rw-r--r-- | lib/ldb/tools/cmdline.c | 1 | ||||
-rw-r--r-- | lib/ldb/tools/cmdline.h | 1 | ||||
-rw-r--r-- | lib/ldb/tools/ldbadd.c | 2 | ||||
-rw-r--r-- | lib/ldb/tools/ldbdel.c | 8 | ||||
-rw-r--r-- | lib/ldb/tools/ldbedit.c | 6 | ||||
-rw-r--r-- | lib/ldb/tools/ldbmodify.c | 12 | ||||
-rw-r--r-- | lib/ldb/tools/ldbutil.c | 15 | ||||
-rw-r--r-- | lib/ldb/tools/ldbutil.h | 6 |
8 files changed, 28 insertions, 23 deletions
diff --git a/lib/ldb/tools/cmdline.c b/lib/ldb/tools/cmdline.c index a06445fc0f..ff3c1cd41f 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 416bf51d22..672c9178f3 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 47fd261841..a073f519ed 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 8036d09a70..ae042dae5f 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 cf4ab3f8ec..0a88efa766 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 2ca7b62b2c..0940303eab 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 26f252704c..882bc67be5 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 f8d3f3a210..28522b20ba 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, |