1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +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>
This commit is contained in:
Martin Schwenke 2018-08-31 09:35:14 +10:00 committed by Amitay Isaacs
parent 920ed66ba7
commit 4f1727fe0b
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);
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:

View File

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

View File

@ -30,6 +30,10 @@ EOF
required_result 22 <<EOF
volatile database directory "${dbdir_volatile}" does not exist
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
EOF
unit_test ctdb-config validate
@ -39,6 +43,8 @@ mkdir -p "$dbdir_volatile"
required_result 22 <<EOF
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
EOF
unit_test ctdb-config validate