<p>Kevin Harwell <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18540">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_agi: Evaluate dialplan functions and variables in agi exec if enabled<br><br>Agi commnad exec can now evaluate dialplan functions and<br>variables if variable AGIEXECFULL is set to yes. this can<br>be useful when executing Playback or Read from agi.<br><br>ASTERISK-30058 #close<br><br>Change-Id: I669991f540496e7bddd096fec82b52c083036832<br>---<br>A doc/CHANGES-staging/res_agi.txt<br>M res/res_agi.c<br>2 files changed, 25 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/res_agi.txt b/doc/CHANGES-staging/res_agi.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..eb6132d</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_agi.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_agi
</span><br><span style="color: hsl(120, 100%, 40%);">+
</span><br><span style="color: hsl(120, 100%, 40%);">+Agi command 'exec' can now be enabled
</span><br><span style="color: hsl(120, 100%, 40%);">+to evaluate dialplan functions and variables
</span><br><span style="color: hsl(120, 100%, 40%);">+by setting the variable AGIEXECFULL to yes.</span><br><span>\ No newline at end of file</span><br><span>diff --git a/res/res_agi.c b/res/res_agi.c</span><br><span>index af85445..9327905 100644</span><br><span>--- a/res/res_agi.c</span><br><span>+++ b/res/res_agi.c</span><br><span>@@ -296,6 +296,9 @@</span><br><span>                   <replaceable>options</replaceable>.</para></span><br><span>                         <para>Returns whatever the <replaceable>application</replaceable> returns, or</span><br><span>                      <literal>-2</literal> on failure to find <replaceable>application</replaceable>.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                 <note></span><br><span style="color: hsl(120, 100%, 40%);">+                          <para>exec does not evaluate dialplan functions and variables unless it is explicitly enabled by setting the <variable>AGIEXECFULL</variable> variable to <literal>yes</literal>.</para></span><br><span style="color: hsl(120, 100%, 40%);">+                  </note></span><br><span>                </description></span><br><span>                 <see-also></span><br><span>                     <ref type="application">AGI</ref></span><br><span>@@ -3121,6 +3124,9 @@</span><br><span> {</span><br><span>         int res, workaround;</span><br><span>         struct ast_app *app_to_exec;</span><br><span style="color: hsl(120, 100%, 40%);">+  const char *agi_exec_full_str;</span><br><span style="color: hsl(120, 100%, 40%);">+        int agi_exec_full;</span><br><span style="color: hsl(120, 100%, 40%);">+    struct ast_str *data_with_var = NULL;</span><br><span> </span><br><span>    if (argc < 2)</span><br><span>             return RESULT_SHOWUSAGE;</span><br><span>@@ -3132,8 +3138,21 @@</span><br><span>            if (!(workaround = ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS))) {</span><br><span>                  ast_set_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS);</span><br><span>                 }</span><br><span style="color: hsl(120, 100%, 40%);">+             agi_exec_full_str = pbx_builtin_getvar_helper(chan, "AGIEXECFULL");</span><br><span style="color: hsl(120, 100%, 40%);">+         agi_exec_full = ast_true(agi_exec_full_str);</span><br><span>                 ast_channel_unlock(chan);</span><br><span style="color: hsl(0, 100%, 40%);">-               res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : argv[2]);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+              if (agi_exec_full) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  if ((data_with_var = ast_str_create(16))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                           ast_str_substitute_variables(&data_with_var, 0, chan, argv[2]);</span><br><span style="color: hsl(120, 100%, 40%);">+                           res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : ast_str_buffer(data_with_var));</span><br><span style="color: hsl(120, 100%, 40%);">+                          ast_free(data_with_var);</span><br><span style="color: hsl(120, 100%, 40%);">+                      } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                              res = -2;</span><br><span style="color: hsl(120, 100%, 40%);">+                     }</span><br><span style="color: hsl(120, 100%, 40%);">+             } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : argv[2]);</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span>            if (!workaround) {</span><br><span>                   ast_channel_clear_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS);</span><br><span>          }</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18540">change 18540</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18540"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I669991f540496e7bddd096fec82b52c083036832 </div>
<div style="display:none"> Gerrit-Change-Number: 18540 </div>
<div style="display:none"> Gerrit-PatchSet: 8 </div>
<div style="display:none"> Gerrit-Owner: Shloime Rosenblum <shloimerosenblum@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>