From d0e431ce3deb6072de7688fb42bd658160684427 Mon Sep 17 00:00:00 2001
From: Joshua Colp <jcolp@digium.com>
Date: Wed, 2 Dec 2009 20:10:07 +0000
Subject: [PATCH] Add an 'X' option to the asterisk application which enables
 #exec for configuration files.

This option can be used to enable #exec support in the asterisk.conf configuration file.

(closes issue #16260)
Reported by: atis
Patches:
      exec_includes.patch uploaded by atis (license 242)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@232510 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 CHANGES           |  4 +++-
 doc/asterisk.sgml | 10 ++++++++++
 main/asterisk.c   |  6 +++++-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/CHANGES b/CHANGES
index 5e3ff81bb2..279b88bc06 100644
--- a/CHANGES
+++ b/CHANGES
@@ -344,7 +344,9 @@ Miscellaneous
  * Modules.conf has a new option - "require" - that marks a module as critical for 
    the execution of Asterisk.
    If one of the required modules fail to load, Asterisk will exit with a return
-   code set to 2. 
+   code set to 2.
+ * An 'X' option has been added to the asterisk application which enables #exec support.
+   This allows #exec to be used in asterisk.conf.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.6.1 to Asterisk 1.6.2  -------------
diff --git a/doc/asterisk.sgml b/doc/asterisk.sgml
index 655d33e8e7..31d96dd737 100644
--- a/doc/asterisk.sgml
+++ b/doc/asterisk.sgml
@@ -310,6 +310,16 @@
 			</para>
 		</listitem>
 	</varlistentry>
+	<varlistentry>
+		<term>-X</term>
+		<listitem>
+			<para>
+			Enables executing of includes via <command>#exec</command> directive.
+			This can be useful if You want to do <command>#exec</command> inside
+			<filename>asterisk.conf</filename>
+			</para>
+		</listitem>
+	</varlistentry>
 	</variablelist>
 </refsect1>
 <refsect1>
diff --git a/main/asterisk.c b/main/asterisk.c
index 4dee9da531..f8f3fa4680 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2777,6 +2777,7 @@ static int show_cli_help(void) {
 	printf("                   of output to the CLI\n");
 	printf("   -v              Increase verbosity (multiple v's = more verbose)\n");
 	printf("   -x <cmd>        Execute command <cmd> (only valid with -r)\n");
+	printf("   -X              Execute includes by default (allows #exec in asterisk.conf)\n");
 	printf("   -W              Adjust terminal colors to compensate for a light background\n");
 	printf("\n");
 	return 0;
@@ -3141,7 +3142,7 @@ int main(int argc, char *argv[])
 	if (getenv("HOME")) 
 		snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
 	/* Check for options */
-	while ((c = getopt(argc, argv, "BC:cde:FfG:ghIiL:M:mnpqRrs:TtU:VvWx:")) != -1) {
+	while ((c = getopt(argc, argv, "BC:cde:FfG:ghIiL:M:mnpqRrs:TtU:VvWXx:")) != -1) {
 		/*!\note Please keep the ordering here to alphabetical, capital letters
 		 * first.  This will make it easier in the future to select unused
 		 * option flags for new features. */
@@ -3150,6 +3151,9 @@ int main(int argc, char *argv[])
 			ast_set_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
 			ast_clear_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
 			break;
+		case 'X':
+			ast_set_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES);
+			break;
 		case 'C':
 			ast_copy_string(cfg_paths.config_file, optarg, sizeof(cfg_paths.config_file));
 			ast_set_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG);
-- 
GitLab