From 4f1727fe0bf2b0962a5d131d60a416b8f459ad94 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 31 Aug 2018 09:35:14 +1000 Subject: [PATCH] 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 Reviewed-by: Amitay Isaacs --- ctdb/common/conf.c | 16 ++++++++++------ ctdb/tests/cunit/conf_test_001.sh | 1 + ctdb/tests/cunit/config_test_005.sh | 6 ++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ctdb/common/conf.c b/ctdb/common/conf.c index 8bc375b166d..3d668de3122 100644 --- a/ctdb/common/conf.c +++ b/ctdb/common/conf.c @@ -1048,6 +1048,10 @@ static int conf_load_internal(struct conf_context *conf) } } + if (state.err != 0) { + goto fail; + } + conf_all_update(conf); 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); if (!ok) { state->err = EINVAL; - return false; + return true; } } @@ -1078,7 +1082,7 @@ static bool conf_load_section(const char *section, void *private_data) } else { D_ERR("conf: unknown section [%s]\n", section); 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", name); state->err = EINVAL; - return false; + return true; } } @@ -1122,7 +1126,7 @@ static bool conf_load_option(const char *name, state->s->name, name); state->err = EINVAL; - return false; + return true; } } @@ -1141,7 +1145,7 @@ static bool conf_load_option(const char *name, value_str); talloc_free(tmp_ctx); state->err = ret; - return false; + return true; } ok = conf_option_same_value(opt, &value); @@ -1153,7 +1157,7 @@ static bool conf_load_option(const char *name, if (ret != 0) { talloc_free(tmp_ctx); state->err = ret; - return false; + return true; } done: diff --git a/ctdb/tests/cunit/conf_test_001.sh b/ctdb/tests/cunit/conf_test_001.sh index caca9314953..d2ffa988745 100755 --- a/ctdb/tests/cunit/conf_test_001.sh +++ b/ctdb/tests/cunit/conf_test_001.sh @@ -106,6 +106,7 @@ EOF required_result 22 <