Commit 2280a6ee authored by Andrei Vagin's avatar Andrei Vagin Committed by Andrei Vagin

config: check that there are not unhandled parameters in a config

Return an error if we meet unexpected parameters in a config file

Cc: Veronika Kabatova <vkabatov@redhat.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent ba98bae9
......@@ -401,20 +401,38 @@ int main(int argc, char *argv[], char *envp[])
goto usage;
while (1) {
char **_argv = NULL;
int _argc = 0;
idx = -1;
switch (state) {
case PARSING_GLOBAL_CONF:
opt = getopt_long(global_cfg_argc, global_conf, short_opts, long_opts, &idx);
_argc = global_cfg_argc;
_argv = global_conf;
break;
case PARSING_USER_CONF:
opt = getopt_long(user_cfg_argc, user_conf, short_opts, long_opts, &idx);
_argc = user_cfg_argc;
_argv = user_conf;
break;
case PARSING_ARGV:
opt = getopt_long(argc, argv, short_opts, long_opts, &idx);
_argc = argc;
_argv = argv;
break;
default:
BUG();
}
opt = getopt_long(_argc, _argv, short_opts, long_opts, &idx);
if (opt == -1) {
switch (state) {
case PARSING_GLOBAL_CONF:
case PARSING_USER_CONF:
if (optind < _argc) {
pr_err("Unknown config parameter: %s\n", _argv[optind]);
return -1;
}
break;
}
if (state < PARSING_ARGV) {
state++;
optind = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment