summaryrefslogtreecommitdiff
path: root/lib/ldb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-04-04 12:51:00 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-04-10 16:40:05 +1000
commit57341c0f29911d09e511c840386a35290febb9f9 (patch)
treebf123480733183f26f4b5970c42e16dfd559339d /lib/ldb
parentd425a4cd3dded853aaefbca8873c95845933d383 (diff)
downloadsamba-57341c0f29911d09e511c840386a35290febb9f9.tar.gz
Revert "ldb: Permit desactivation of autocomit for every ldb_xxx_ctrl function"
This reverts commit 40a4aea8918c2637703af03383f440d068820e48. Autocommit is important, as otherwise an ldb module could error out during an operation, and leave an corrupt database. Andrew Bartlett
Diffstat (limited to 'lib/ldb')
-rw-r--r--lib/ldb/tools/cmdline.c1
-rw-r--r--lib/ldb/tools/cmdline.h1
-rw-r--r--lib/ldb/tools/ldbadd.c2
-rw-r--r--lib/ldb/tools/ldbdel.c8
-rw-r--r--lib/ldb/tools/ldbedit.c6
-rw-r--r--lib/ldb/tools/ldbmodify.c12
-rw-r--r--lib/ldb/tools/ldbutil.c15
-rw-r--r--lib/ldb/tools/ldbutil.h6
8 files changed, 23 insertions, 28 deletions
diff --git a/lib/ldb/tools/cmdline.c b/lib/ldb/tools/cmdline.c
index ff3c1cd41f..a06445fc0f 100644
--- a/lib/ldb/tools/cmdline.c
+++ b/lib/ldb/tools/cmdline.c
@@ -59,7 +59,6 @@ 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 672c9178f3..416bf51d22 100644
--- a/lib/ldb/tools/cmdline.h
+++ b/lib/ldb/tools/cmdline.h
@@ -44,7 +44,6 @@ 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 a073f519ed..47fd261841 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, true);
+ ret = ldb_add_ctrl(ldb, ldif->msg,req_ctrls);
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 ae042dae5f..8036d09a70 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, bool doautocommit)
+static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn,struct ldb_control **req_ctrls)
{
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, doautocommit) == LDB_SUCCESS) {
+ if (ldb_delete_ctrl(ldb, res->msgs[i]->dn,req_ctrls) == 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, !options->noautocommit);
+ ret = ldb_delete_recursive(ldb, dn,req_ctrls);
} else {
- ret = ldb_delete_ctrl(ldb, dn,req_ctrls, !options->noautocommit);
+ ret = ldb_delete_ctrl(ldb, dn,req_ctrls);
if (ret == LDB_SUCCESS) {
printf("Deleted 1 record\n");
}
diff --git a/lib/ldb/tools/ldbedit.c b/lib/ldb/tools/ldbedit.c
index 0a88efa766..cf4ab3f8ec 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, true) != LDB_SUCCESS) {
+ if (ldb_modify_ctrl(ldb, mod, req_ctrls) != 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, true) != LDB_SUCCESS) {
+ if (ldb_add_ctrl(ldb, msgs2[i], req_ctrls) != 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, true) != LDB_SUCCESS) {
+ if (ldb_delete_ctrl(ldb, msgs1[i]->dn, req_ctrls) != 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 0940303eab..2ca7b62b2c 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, bool doautocomit)
+static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
{
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, b
switch (ldif->changetype) {
case LDB_CHANGETYPE_NONE:
case LDB_CHANGETYPE_ADD:
- ret = ldb_add_ctrl(ldb, ldif->msg, req_ctrls, doautocomit);
+ ret = ldb_add_ctrl(ldb, ldif->msg,req_ctrls);
break;
case LDB_CHANGETYPE_DELETE:
- ret = ldb_delete_ctrl(ldb, ldif->msg->dn, req_ctrls, doautocomit);
+ ret = ldb_delete_ctrl(ldb, ldif->msg->dn,req_ctrls);
break;
case LDB_CHANGETYPE_MODIFY:
- ret = ldb_modify_ctrl(ldb, ldif->msg, req_ctrls, doautocomit);
+ ret = ldb_modify_ctrl(ldb, ldif->msg,req_ctrls);
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, !options->noautocommit);
+ ret = process_file(ldb, stdin, &count);
} 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, !options->noautocommit);
+ ret = process_file(ldb, f, &count);
fclose(f);
}
}
diff --git a/lib/ldb/tools/ldbutil.c b/lib/ldb/tools/ldbutil.c
index 882bc67be5..26f252704c 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, bool do_transaction)
+ struct ldb_control **controls)
{
struct ldb_request *req;
int ret;
@@ -87,8 +87,7 @@ int ldb_add_ctrl(struct ldb_context *ldb,
if (ret != LDB_SUCCESS) return ret;
/* do request and autostart a transaction */
- if (do_transaction)
- ret = ldb_do_autotransaction(ldb, req);
+ ret = ldb_do_autotransaction(ldb, req);
talloc_free(req);
return ret;
@@ -98,7 +97,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, bool do_transaction)
+ struct ldb_control **controls)
{
struct ldb_request *req;
int ret;
@@ -113,8 +112,7 @@ int ldb_delete_ctrl(struct ldb_context *ldb, struct ldb_dn *dn,
if (ret != LDB_SUCCESS) return ret;
/* do request and autostart a transaction */
- if (do_transaction)
- ret = ldb_do_autotransaction(ldb, req);
+ ret = ldb_do_autotransaction(ldb, req);
talloc_free(req);
return ret;
@@ -126,7 +124,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, bool do_transaction)
+ struct ldb_control **controls)
{
struct ldb_request *req;
int ret;
@@ -146,8 +144,7 @@ int ldb_modify_ctrl(struct ldb_context *ldb,
if (ret != LDB_SUCCESS) return ret;
/* do request and autostart a transaction */
- if (do_transaction)
- ret = ldb_do_autotransaction(ldb, req);
+ 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 28522b20ba..f8d3f3a210 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, bool do_transaction);
+ struct ldb_control **controls);
int ldb_delete_ctrl(struct ldb_context *ldb, struct ldb_dn *dn,
- struct ldb_control **controls, bool do_transaction);
+ struct ldb_control **controls);
int ldb_modify_ctrl(struct ldb_context *ldb,
const struct ldb_message *message,
- struct ldb_control **controls, bool do_transaction);
+ struct ldb_control **controls);
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,