summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2011-04-04 12:59:30 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2011-04-07 15:53:20 +0200
commit17f34136bf67aa5e739b63aa3ef51d247d6dc901 (patch)
treee5f2a0a0a797c544117eb1f93ca9f4c998a5758b
parentf14699287ca7a4f2349658bd2ae602eb30f95bf9 (diff)
downloadsamba-17f34136bf67aa5e739b63aa3ef51d247d6dc901.tar.gz
samba-17f34136bf67aa5e739b63aa3ef51d247d6dc901.tar.bz2
samba-17f34136bf67aa5e739b63aa3ef51d247d6dc901.zip
ldb:ldbadd/modify tool - return error code when at least one operation has failed
This is required to better detect failures and should raise the compatiblity to "ldapadd"/"ldapmodify". Reviewed-by: abartlet
-rw-r--r--source4/lib/ldb/tools/ldbadd.c6
-rw-r--r--source4/lib/ldb/tools/ldbmodify.c7
2 files changed, 8 insertions, 5 deletions
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index a5285121c7..47fd261841 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -53,7 +53,7 @@ static void usage(struct ldb_context *ldb)
static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
{
struct ldb_ldif *ldif;
- int ret = LDB_SUCCESS;
+ int fun_ret = LDB_SUCCESS, ret;
struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
if (options->controls != NULL && req_ctrls== NULL) {
printf("parsing controls failed: %s\n", ldb_errstring(ldb));
@@ -74,6 +74,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
"ERR: Message canonicalize failed - %s\n",
ldb_strerror(ret));
failures++;
+ fun_ret = ret;
ldb_ldif_read_free(ldb, ldif);
continue;
}
@@ -84,6 +85,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
ldb_strerror(ret), ldb_errstring(ldb),
ldb_dn_get_linearized(ldif->msg->dn));
failures++;
+ fun_ret = ret;
} else {
(*count)++;
if (options->verbose) {
@@ -93,7 +95,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
ldb_ldif_read_free(ldb, ldif);
}
- return ret;
+ return fun_ret;
}
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index 1374765f57..1e7aa80d83 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -52,7 +52,7 @@ static void usage(struct ldb_context *ldb)
static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
{
struct ldb_ldif *ldif;
- int ret = LDB_SUCCESS;
+ int fun_ret = LDB_SUCCESS, ret;
struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
if (options->controls != NULL && req_ctrls== NULL) {
@@ -78,6 +78,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
ldb_strerror(ret),
ldb_errstring(ldb), ldb_dn_get_linearized(ldif->msg->dn));
failures++;
+ fun_ret = ret;
} else {
(*count)++;
if (options->verbose) {
@@ -89,10 +90,10 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
if (!feof(f)) {
fprintf(stderr, "Failed to parse ldif\n");
- return -1;
+ fun_ret = LDB_ERR_OPERATIONS_ERROR;
}
- return ret;
+ return fun_ret;
}
int main(int argc, const char **argv)