1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-09 08:58:35 +03:00

ctdb-common: Process the whole config file even if an error occurs

At the moment multiple errors will be encountered one at a time, on
each load or validate.  Instead, allow all configuration errors to
printed in a single pass.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 4f1727fe0bf2b0962a5d131d60a416b8f459ad94)
This commit is contained in:
Martin Schwenke 2018-08-31 09:35:14 +10:00 committed by Karolin Seeger
parent 7db0f189d6
commit a242e10162
3 changed files with 17 additions and 6 deletions

View File

@ -1048,6 +1048,10 @@ static int conf_load_internal(struct conf_context *conf)
} }
} }
if (state.err != 0) {
goto fail;
}
conf_all_update(conf); conf_all_update(conf);
return 0; return 0;
@ -1066,7 +1070,7 @@ static bool conf_load_section(const char *section, void *private_data)
ok = conf_section_validate(state->conf, state->s, state->mode); ok = conf_section_validate(state->conf, state->s, state->mode);
if (!ok) { if (!ok) {
state->err = EINVAL; state->err = EINVAL;
return false; return true;
} }
} }
@ -1078,7 +1082,7 @@ static bool conf_load_section(const char *section, void *private_data)
} else { } else {
D_ERR("conf: unknown section [%s]\n", section); D_ERR("conf: unknown section [%s]\n", section);
state->err = EINVAL; state->err = EINVAL;
return false; return true;
} }
} }
@ -1106,7 +1110,7 @@ static bool conf_load_option(const char *name,
D_ERR("conf: unknown section for option \"%s\"\n", D_ERR("conf: unknown section for option \"%s\"\n",
name); name);
state->err = EINVAL; state->err = EINVAL;
return false; return true;
} }
} }
@ -1122,7 +1126,7 @@ static bool conf_load_option(const char *name,
state->s->name, state->s->name,
name); name);
state->err = EINVAL; state->err = EINVAL;
return false; return true;
} }
} }
@ -1141,7 +1145,7 @@ static bool conf_load_option(const char *name,
value_str); value_str);
talloc_free(tmp_ctx); talloc_free(tmp_ctx);
state->err = ret; state->err = ret;
return false; return true;
} }
ok = conf_option_same_value(opt, &value); ok = conf_option_same_value(opt, &value);
@ -1153,7 +1157,7 @@ static bool conf_load_option(const char *name,
if (ret != 0) { if (ret != 0) {
talloc_free(tmp_ctx); talloc_free(tmp_ctx);
state->err = ret; state->err = ret;
return false; return true;
} }
done: done:

View File

@ -106,6 +106,7 @@ EOF
required_result 22 <<EOF required_result 22 <<EOF
conf: unknown section [section2] conf: unknown section [section2]
conf: unknown section for option "foo"
[section1] [section1]
# key1 = value1 # key1 = value1
# key2 = 10 # key2 = 10

View File

@ -30,6 +30,10 @@ EOF
required_result 22 <<EOF required_result 22 <<EOF
volatile database directory "${dbdir_volatile}" does not exist volatile database directory "${dbdir_volatile}" does not exist
conf: validation for option "volatile database directory" failed conf: validation for option "volatile database directory" failed
persistent database directory "${dbdir_persistent}" does not exist
conf: validation for option "persistent database directory" failed
state database directory "${dbdir_state}" does not exist
conf: validation for option "state database directory" failed
Failed to load config file $conffile Failed to load config file $conffile
EOF EOF
unit_test ctdb-config validate unit_test ctdb-config validate
@ -39,6 +43,8 @@ mkdir -p "$dbdir_volatile"
required_result 22 <<EOF required_result 22 <<EOF
persistent database directory "${dbdir_persistent}" does not exist persistent database directory "${dbdir_persistent}" does not exist
conf: validation for option "persistent database directory" failed conf: validation for option "persistent database directory" failed
state database directory "${dbdir_state}" does not exist
conf: validation for option "state database directory" failed
Failed to load config file $conffile Failed to load config file $conffile
EOF EOF
unit_test ctdb-config validate unit_test ctdb-config validate