[svn-commits] tilghman: trunk r266385 - in /trunk: ./ funcs/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 28 17:50:09 CDT 2010


Author: tilghman
Date: Fri May 28 17:50:06 2010
New Revision: 266385

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=266385
Log:
Setup environment variables for the benefit of child processes and disallow changing them.

(closes issue #14899)
 Reported by: jmls
 Patches: 
       20090916__issue14899.diff.txt uploaded by tilghman (license 14)
 Tested by: jmls

Modified:
    trunk/UPGRADE.txt
    trunk/funcs/func_env.c
    trunk/main/asterisk.c

Modified: trunk/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE.txt?view=diff&rev=266385&r1=266384&r2=266385
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Fri May 28 17:50:06 2010
@@ -81,6 +81,9 @@
 * VoiceMailMain and VMAuthenticate, if a '*' is entered in the first position
   of a Mailbox or Password, will, if it exists, jump to the 'a' extension in
   the current dialplan context.
+
+* Environment variables that start with "AST_" are reserved to the system and
+  may no longer be set from the dialplan.
 
 From 1.6.1 to 1.6.2:
 

Modified: trunk/funcs/func_env.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_env.c?view=diff&rev=266385&r1=266384&r2=266385
==============================================================================
--- trunk/funcs/func_env.c (original)
+++ trunk/funcs/func_env.c Fri May 28 17:50:06 2010
@@ -44,6 +44,7 @@
 			</parameter>
 		</syntax>
 		<description>
+			Variables starting with <literal>AST_</literal> are reserved to the system and may not be set.
 		</description>
 	</function>
 	<function name="STAT" language="en_US">
@@ -106,7 +107,7 @@
 static int env_write(struct ast_channel *chan, const char *cmd, char *data,
 		     const char *value)
 {
-	if (!ast_strlen_zero(data)) {
+	if (!ast_strlen_zero(data) && strncmp(data, "AST_", 4)) {
 		if (!ast_strlen_zero(value)) {
 			setenv(data, value, 1);
 		} else {

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=266385&r1=266384&r2=266385
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Fri May 28 17:50:06 2010
@@ -3128,6 +3128,18 @@
 	ast_config_destroy(cfg);
 }
 
+static void env_init(void)
+{
+	setenv("AST_SYSTEMNAME", ast_config_AST_SYSTEM_NAME, 1);
+	setenv("AST_BUILD_HOST", ast_build_hostname, 1);
+	setenv("AST_BUILD_DATE", ast_build_date, 1);
+	setenv("AST_BUILD_KERNEL", ast_build_kernel, 1);
+	setenv("AST_BUILD_MACHINE", ast_build_machine, 1);
+	setenv("AST_BUILD_OS", ast_build_os, 1);
+	setenv("AST_BUILD_USER", ast_build_user, 1);
+	setenv("AST_VERSION", ast_get_version(), 1);
+}
+
 int main(int argc, char *argv[])
 {
 	int c;
@@ -3314,6 +3326,7 @@
 	}
 
 	ast_readconfig();
+	env_init();
 
 	if (ast_opt_remote && remotesock != NULL)
 		ast_copy_string((char *) cfg_paths.socket_path, remotesock, sizeof(cfg_paths.socket_path));




More information about the svn-commits mailing list