[Asterisk-code-review] pbx config: Only the first [globals] section is seen. (asterisk[13])

Corey Farrell asteriskteam at digium.com
Fri Nov 2 07:49:48 CDT 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/10581


Change subject: pbx_config: Only the first [globals] section is seen.
......................................................................

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
---
M pbx/pbx_config.c
1 file changed, 13 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/81/10581/1

diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 441a996..6c3b934 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1688,10 +1688,20 @@
 
 	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)) {

-- 
To view, visit https://gerrit.asterisk.org/10581
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaac810c0a7c4d9b1bf8989fcc041cdb910ef08a0
Gerrit-Change-Number: 10581
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181102/c3d4fc92/attachment-0001.html>


More information about the asterisk-code-review mailing list