[Asterisk-code-review] pbx config: Only the first [globals] section is seen. (asterisk[master])
George Joseph
asteriskteam at digium.com
Thu Nov 15 07:48:21 CST 2018
George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/10583 )
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 CHANGES
M pbx/pbx_config.c
2 files changed, 19 insertions(+), 3 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
diff --git a/CHANGES b/CHANGES
index 7fd478b..569717b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,12 @@
--- Functionality changes from Asterisk 16.0.0 to Asterisk 16.1.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 9bb2796..f6af7bf 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1714,10 +1714,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/10583
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaac810c0a7c4d9b1bf8989fcc041cdb910ef08a0
Gerrit-Change-Number: 10583
Gerrit-PatchSet: 2
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181115/cefd8969/attachment.html>
More information about the asterisk-code-review
mailing list