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:
@ -460,8 +460,25 @@ void fix_section_name(char *section)
|
||||
*/
|
||||
static int ini_handler(void *userdata, const char *section, const char *name, const char *value)
|
||||
{
|
||||
CONFIG_CONTEXT *cntxt = (CONFIG_CONTEXT *)userdata;
|
||||
CONFIG_CONTEXT *ptr = cntxt;
|
||||
CONFIG_CONTEXT *cntxt = (CONFIG_CONTEXT *)userdata;
|
||||
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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user