s3:net registry check: fix a case where automatic and read only mode take the wrong...
authorGregor Beck <gbeck@sernet.de>
Thu, 20 Oct 2011 15:38:06 +0000 (17:38 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 26 Oct 2011 00:44:03 +0000 (02:44 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
source3/utils/net_registry_check.c

index 0ae2c962d34ddf558c658763f5f9ee419c5d4796..870a0edce2d7abb714a420d9e2d14f6644192456 100644 (file)
@@ -336,7 +336,7 @@ static struct check_ctx* check_ctx_create(TALLOC_CTX *mem_ctx, const char *db,
                }
        }
 
-       ctx->default_action = opt->automatic ? 'd' : 'r';
+       ctx->default_action = 'r';
        return ctx;
 fail:
        talloc_free(ctx);
@@ -728,6 +728,7 @@ static int check_tdb_action(struct db_record *rec, void *check_ctx)
        char *key;
        bool invalid_path = false;
        bool once_more;
+       bool first_iter = true;
 
        if (!tdb_data_is_cstr(rec_key)) {
                printf("Key is not zero terminated: \"%.*s\"\ntry to go on.\n",
@@ -791,9 +792,9 @@ static int check_tdb_action(struct db_record *rec, void *check_ctx)
                if (invalid_path) {
                        int action;
                        if (ctx->opt.output == NULL) {
-                               action = 's';
+                               action = first_iter ? 'r' : 's';
                        } else if (ctx->opt.automatic) {
-                               action = (ctx->default_action == 'r') ? 'd' : 'r';
+                               action = first_iter ? 'r' : 'd';
                        } else if (ctx->auto_action != '\0') {
                                action = ctx->auto_action;
                        } else {
@@ -828,6 +829,7 @@ static int check_tdb_action(struct db_record *rec, void *check_ctx)
                                break;
                        }
                }
+               first_iter = false;
        } while (once_more);
 
        if (invalid_path) {