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.
This commit is contained in:
Valentine Krasnobaeva 2025-04-28 23:00:17 +02:00 committed by Willy Tarreau
parent 994cc58576
commit 8a4b3216f9

View File

@ -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;
}