ldb:ldbadd/modify tool - return error code when at least one operation has failed
[ira/wip.git] / source4 / lib / ldb / tools / ldbadd.c
index a5285121c7b821edf933cbe892ecb16b54800db5..47fd261841642cff3841b51d75349593ddff4144 100644 (file)
@@ -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;
 }