From: Corey Farrell Date: Fri, 2 Nov 2018 11:38:19 +0000 (-0400) Subject: pbx_config: Only the first [globals] section is seen. X-Git-Tag: 13.24.0-rc1~27^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1709f6be7792bb8ca9d5b601ac41739cb8bae982;p=thirdparty%2Fasterisk.git pbx_config: Only the first [globals] section is seen. If multiple [globals] sections are used (for example via separate included files), only the first one is processed. This can result in lost global variables when using a modular extensions.conf. ASTERISK-28146 #close Change-Id: Iaac810c0a7c4d9b1bf8989fcc041cdb910ef08a0 --- diff --git a/CHANGES b/CHANGES index b191f40dae..5c254a8791 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,12 @@ --- Functionality changes from Asterisk 13.23.0 to Asterisk 13.24.0 ---------- ------------------------------------------------------------------------------ +pbx_config +------------------ + * pbx_config will now find and process multiple 'globals' sections from + extensions.conf. Variables are processed in the order they are found + and duplicate variables overwrite the previous value. + res_pjsip ------------------ * New options 'trust_connected_line' and 'send_connected_line' have been diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 441a996040..6c3b934356 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1688,10 +1688,20 @@ static int pbx_load_config(const char *config_file) ast_copy_string(userscontext, ast_variable_retrieve(cfg, "general", "userscontext") ?: "default", sizeof(userscontext)); - for (v = ast_variable_browse(cfg, "globals"); v; v = v->next) { - pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1); - pbx_builtin_setvar_helper(NULL, v->name, realvalue); + /* ast_variable_browse does not merge multiple [globals] sections */ + for (cxt = ast_category_browse(cfg, NULL); + cxt; + cxt = ast_category_browse(cfg, cxt)) { + if (strcasecmp(cxt, "globals")) { + continue; + } + + for (v = ast_variable_browse(cfg, cxt); v; v = v->next) { + pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1); + pbx_builtin_setvar_helper(NULL, v->name, realvalue); + } } + for (cxt = ast_category_browse(cfg, NULL); cxt; cxt = ast_category_browse(cfg, cxt)) {