MXS-1464 Substitute environment variables
If 'substitute_variables' has been set to true, then the value of a parameter like `some_param=$SOME_VAR' is replaced with the value of the environment variable 'SOME_VAR'. It is a fatal error to refer to a variable that does not exist.
This commit is contained in:
@ -463,6 +463,23 @@ static int ini_handler(void *userdata, const char *section, const char *name, co
|
|||||||
CONFIG_CONTEXT *cntxt = (CONFIG_CONTEXT *)userdata;
|
CONFIG_CONTEXT *cntxt = (CONFIG_CONTEXT *)userdata;
|
||||||
CONFIG_CONTEXT *ptr = cntxt;
|
CONFIG_CONTEXT *ptr = cntxt;
|
||||||
|
|
||||||
|
if (config_get_global_options()->substitute_variables)
|
||||||
|
{
|
||||||
|
if (*value == '$')
|
||||||
|
{
|
||||||
|
char* env_value = getenv(value + 1);
|
||||||
|
|
||||||
|
if (!env_value)
|
||||||
|
{
|
||||||
|
MXS_ERROR("The environment variable %s, used as value for parameter %s "
|
||||||
|
"in section %s, does not exist.", value, name, section);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = env_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(section, CN_GATEWAY) == 0 || strcasecmp(section, CN_MAXSCALE) == 0)
|
if (strcmp(section, CN_GATEWAY) == 0 || strcasecmp(section, CN_MAXSCALE) == 0)
|
||||||
{
|
{
|
||||||
return handle_global_item(name, value);
|
return handle_global_item(name, value);
|
||||||
|
Reference in New Issue
Block a user