From: Valentine Krasnobaeva Date: Mon, 28 Apr 2025 21:00:17 +0000 (+0200) Subject: MINOR: cfgparse-global: add explicit error messages in cfg_parse_global_env_opts X-Git-Tag: v3.2-dev14~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8a4b3216f94d0f18d37f0c4408edb1a141a643a2;p=thirdparty%2Fhaproxy.git MINOR: cfgparse-global: add explicit error messages in cfg_parse_global_env_opts When env variable name or value are not provided for setenv/presetenv it's not clear from the old error message shown at stderr, what exactly is missed. User needs to search in it's configuration. Let's add more explicit error messages about these inconsistencies. No need to be backported. --- diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index 370da3e94..2221ea2b9 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -1472,10 +1472,15 @@ static int cfg_parse_global_env_opts(char **args, int section_type, if (strcmp(args[0], "setenv") == 0 || strcmp(args[0], "presetenv") == 0) { if (too_many_args(2, args, err, NULL)) return -1; + if (*(args[1]) == 0) { + memprintf(err, "'%s' expects environment variable name.\n.", + args[0]); + return -1; + } if (*(args[2]) == 0) { - memprintf(err, "'%s' expects an env variable name and a value.\n.", - args[0]); + memprintf(err, "'%s' expects environment variable value for '%s'.\n.", + args[0], args[1]); return -1; }