[asterisk-commits] bebuild: tag certified-11.6-cert1-rc2 r405537 - in /certified/tags/11.6-cert1...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 14 14:35:34 CST 2014


Author: bebuild
Date: Tue Jan 14 14:35:27 2014
New Revision: 405537

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405537
Log:
Merge items for 11.6-cert1-rc2

* Merge r403860 (app_sms Buffer Overflow)
* Merge r403956 (security permission escalation)
* Merge r404349 (astdb atexit crash)
* Merge r405233 (app_confbridge state crash)
* Merge r405488 (verbosity performance)
* Merge r405536 (chan_sip parking off nominal)

Modified:
    certified/tags/11.6-cert1-rc2/   (props changed)
    certified/tags/11.6-cert1-rc2/.version
    certified/tags/11.6-cert1-rc2/README-SERIOUSLY.bestpractices.txt
    certified/tags/11.6-cert1-rc2/UPGRADE.txt
    certified/tags/11.6-cert1-rc2/apps/app_confbridge.c
    certified/tags/11.6-cert1-rc2/apps/app_dumpchan.c
    certified/tags/11.6-cert1-rc2/apps/app_sms.c
    certified/tags/11.6-cert1-rc2/apps/app_verbose.c
    certified/tags/11.6-cert1-rc2/apps/confbridge/conf_state_multi_marked.c
    certified/tags/11.6-cert1-rc2/channels/chan_sip.c
    certified/tags/11.6-cert1-rc2/configs/asterisk.conf.sample
    certified/tags/11.6-cert1-rc2/configs/logger.conf.sample
    certified/tags/11.6-cert1-rc2/funcs/func_db.c
    certified/tags/11.6-cert1-rc2/funcs/func_env.c
    certified/tags/11.6-cert1-rc2/funcs/func_lock.c
    certified/tags/11.6-cert1-rc2/funcs/func_realtime.c
    certified/tags/11.6-cert1-rc2/funcs/func_shell.c
    certified/tags/11.6-cert1-rc2/funcs/func_timeout.c
    certified/tags/11.6-cert1-rc2/include/asterisk/logger.h
    certified/tags/11.6-cert1-rc2/include/asterisk/pbx.h
    certified/tags/11.6-cert1-rc2/main/asterisk.c
    certified/tags/11.6-cert1-rc2/main/cli.c
    certified/tags/11.6-cert1-rc2/main/db.c
    certified/tags/11.6-cert1-rc2/main/logger.c
    certified/tags/11.6-cert1-rc2/main/manager.c
    certified/tags/11.6-cert1-rc2/main/pbx.c
    certified/tags/11.6-cert1-rc2/main/tcptls.c

Propchange: certified/tags/11.6-cert1-rc2/
------------------------------------------------------------------------------
--- branch-11-merged (original)
+++ branch-11-merged Tue Jan 14 14:35:27 2014
@@ -1,1 +1,1 @@
-/branches/11:396884,399513,400075-400093,401446,401960,402450
+/branches/11:396884,399513,400075-400093,401446,401960,402450,403917,404344,405215,405380,405431

Propchange: certified/tags/11.6-cert1-rc2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 14 14:35:27 2014
@@ -1,2 +1,3 @@
 /branches/11:399513,401167,401179,401182
 /certified/branches/1.8.15:382389
+/certified/branches/11.6:403860,403956,404349,405233,405488,405536

Modified: certified/tags/11.6-cert1-rc2/.version
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/.version?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/.version (original)
+++ certified/tags/11.6-cert1-rc2/.version Tue Jan 14 14:35:27 2014
@@ -1,1 +1,1 @@
-11.6-cert1-rc1
+11.6-cert1-rc2

Modified: certified/tags/11.6-cert1-rc2/README-SERIOUSLY.bestpractices.txt
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/README-SERIOUSLY.bestpractices.txt?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/README-SERIOUSLY.bestpractices.txt (original)
+++ certified/tags/11.6-cert1-rc2/README-SERIOUSLY.bestpractices.txt Tue Jan 14 14:35:27 2014
@@ -25,6 +25,9 @@
 
 * Manager Class Authorizations:
         Recognizing potential issues with certain classes of authorization
+
+* Avoid Privilege Escalations:
+        Disable the ability to execute functions that may escalate privileges
 
 ----------------
 Additional Links
@@ -344,3 +347,24 @@
 not running Asterisk as root, can prevent serious problems from arising when
 allowing external connections to originate calls into Asterisk.
 
+===========================
+Avoid Privilege Escalations
+===========================
+
+External control protocols, such as Manager, often have the ability to get and
+set channel variables; which allows the execution of dialplan functions.
+
+Dialplan functions within Asterisk are incredibly powerful, which is wonderful
+for building applications using Asterisk. But during the read or write
+execution, certain diaplan functions do much more. For example, reading the
+SHELL() function can execute arbitrary commands on the system Asterisk is
+running on. Writing to the FILE() function can change any file that Asterisk has
+write access to.
+
+When these functions are executed from an external protocol, that execution
+could result in a privilege escalation. Asterisk can inhibit the execution of
+these functions, if live_dangerously in the [options] section of asterisk.conf
+is set to no.
+
+For backwards compatibility, live_dangerously defaults to yes, and must be
+explicitly set to no to enable this privilege escalation protection.

Modified: certified/tags/11.6-cert1-rc2/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/UPGRADE.txt?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/UPGRADE.txt (original)
+++ certified/tags/11.6-cert1-rc2/UPGRADE.txt Tue Jan 14 14:35:27 2014
@@ -19,6 +19,41 @@
 === UPGRADE-10.txt -- Upgrade info for 1.8 to 10
 ===
 ===========================================================
+
+From 11.6 to 11.6-cert1:
+* Certain dialplan functions have been marked as 'dangerous', and may only be
+  executed from the dialplan. Execution from extenal sources (AMI's GetVar and
+  SetVar actions; etc.) may be inhibited by setting live_dangerously in the
+  [options] section of asterisk.conf to no. SHELL(), channel locking, and direct
+  file read/write functions are marked as dangerous. DB_DELETE() and
+  REALTIME_DESTROY() are marked as dangerous for reads, but can now safely
+  accept writes (which ignore the provided value).
+
+* The per console verbose level feature as previously implemented caused a
+  large performance penalty.  The fix required some minor incompatibilities
+  if the new rasterisk is used to connect to an earlier version.  If the new
+  rasterisk connects to an older Asterisk version then the root console verbose
+  level is always affected by the "core set verbose" command of the remote
+  console even though it may appear to only affect the current console.  If
+  an older version of rasterisk connects to the new version then the
+  "core set verbose" command will have no effect.
+
+CLI commands:
+ - "core show settings" now lists the current console verbosity in addition
+   to the root console verbosity.
+
+ - "core set verbose" has not been able to support the by module verbose
+   logging levels since verbose logging levels were made per console.  That
+   syntax is now removed and a silence option added in its place.
+
+Configuration Files:
+ - The 'verbose' setting in logger.conf still takes an optional argument,
+   specifying the verbosity level for each logging destination.  However,
+   the default is now to once again follow the current root console level.
+   As a result, using the AMI Command action with "core set verbose" could
+   again set the root console verbose level and affect the verbose level
+   logged.
+
 From 11.5 to 11.6:
 * res_agi will now properly indicate if there was an error in streaming an
   audio file.  The result code will be -1 and the result returned from the

Modified: certified/tags/11.6-cert1-rc2/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/apps/app_confbridge.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/apps/app_confbridge.c (original)
+++ certified/tags/11.6-cert1-rc2/apps/app_confbridge.c Tue Jan 14 14:35:27 2014
@@ -1917,7 +1917,7 @@
 		ast_stream_and_wait(bridge_channel->chan,
 			conf_get_sound(CONF_SOUND_ERROR_MENU, conference_bridge_user->b_profile.sounds),
 			"");
-	} else if (last_participant) {
+	} else if (last_participant && !last_participant->kicked) {
 		last_participant->kicked = 1;
 		ast_bridge_remove(conference_bridge->bridge, last_participant->chan);
 		ao2_unlock(conference_bridge);
@@ -2095,7 +2095,7 @@
 
 	ao2_lock(bridge);
 	AST_LIST_TRAVERSE(&bridge->active_list, participant, list) {
-		if (!strcasecmp(ast_channel_name(participant->chan), channel)) {
+		if (!strcasecmp(ast_channel_name(participant->chan), channel) && !participant->kicked) {
 			participant->kicked = 1;
 			ast_bridge_remove(bridge->bridge, participant->chan);
 			ao2_unlock(bridge);
@@ -2103,7 +2103,7 @@
 		}
 	}
 	AST_LIST_TRAVERSE(&bridge->waiting_list, participant, list) {
-		if (!strcasecmp(ast_channel_name(participant->chan), channel)) {
+		if (!strcasecmp(ast_channel_name(participant->chan), channel) && !participant->kicked) {
 			participant->kicked = 1;
 			ast_bridge_remove(bridge->bridge, participant->chan);
 			ao2_unlock(bridge);

Modified: certified/tags/11.6-cert1-rc2/apps/app_dumpchan.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/apps/app_dumpchan.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/apps/app_dumpchan.c (original)
+++ certified/tags/11.6-cert1-rc2/apps/app_dumpchan.c Tue Jan 14 14:35:27 2014
@@ -182,15 +182,17 @@
 	if (!ast_strlen_zero(data))
 		level = atoi(data);
 
-	serialize_showchan(chan, info, sizeof(info));
-	pbx_builtin_serialize_variables(chan, &vars);
-	ast_verb(level, "\n"
-		 "Dumping Info For Channel: %s:\n"
-		 "%s\n"
-		 "Info:\n"
-		 "%s\n"
-		 "Variables:\n"
-		 "%s%s\n", ast_channel_name(chan), line, info, ast_str_buffer(vars), line);
+	if (VERBOSITY_ATLEAST(level)) {
+		serialize_showchan(chan, info, sizeof(info));
+		pbx_builtin_serialize_variables(chan, &vars);
+		ast_verb(level, "\n"
+			"Dumping Info For Channel: %s:\n"
+			"%s\n"
+			"Info:\n"
+			"%s\n"
+			"Variables:\n"
+			"%s%s\n", ast_channel_name(chan), line, info, ast_str_buffer(vars), line);
+	}
 
 	return 0;
 }

Modified: certified/tags/11.6-cert1-rc2/apps/app_sms.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/apps/app_sms.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/apps/app_sms.c (original)
+++ certified/tags/11.6-cert1-rc2/apps/app_sms.c Tue Jan 14 14:35:27 2014
@@ -696,7 +696,7 @@
 	}
 	while (l--) {
 		int v = *i++;
-		if (l--) {
+		if (l && l--) {
 			v = (v << 8) + *i++;
 		}
 		*o++ = v;
@@ -714,6 +714,7 @@
 	} else if (is8bit(dcs)) {
 		unpacksms8(i, l, udh, udhl, ud, udl, udhi);
 	} else {
+		l += l % 2;
 		unpacksms16(i, l, udh, udhl, ud, udl, udhi);
 	}
 	return l + 1;

Modified: certified/tags/11.6-cert1-rc2/apps/app_verbose.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/apps/app_verbose.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/apps/app_verbose.c (original)
+++ certified/tags/11.6-cert1-rc2/apps/app_verbose.c Tue Jan 14 14:35:27 2014
@@ -96,9 +96,11 @@
 		args.level = "0";
 	}
 
-	if (sscanf(args.level, "%30d", &vsize) != 1) {
+	if (sscanf(args.level, "%30u", &vsize) != 1) {
 		vsize = 0;
 		ast_log(LOG_WARNING, "'%s' is not a verboser number\n", args.level);
+	} else if (4 < vsize) {
+		vsize = 4;
 	}
 
 	ast_verb(vsize, "%s\n", args.msg);

Modified: certified/tags/11.6-cert1-rc2/apps/confbridge/conf_state_multi_marked.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/apps/confbridge/conf_state_multi_marked.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/apps/confbridge/conf_state_multi_marked.c (original)
+++ certified/tags/11.6-cert1-rc2/apps/confbridge/conf_state_multi_marked.c Tue Jan 14 14:35:27 2014
@@ -78,23 +78,16 @@
 static void leave_marked(struct conference_bridge_user *cbu)
 {
 	struct conference_bridge_user *cbu_iter;
+	int need_prompt = 0;
 
 	conf_remove_user_marked(cbu->conference_bridge, cbu);
 
 	if (cbu->conference_bridge->markedusers == 0) {
-		/* Play back the audio prompt saying the leader has left the conference */
-		if (!ast_test_flag(&cbu->u_profile, USER_OPT_QUIET)) {
-			ao2_unlock(cbu->conference_bridge);
-			ast_autoservice_start(cbu->chan);
-			play_sound_file(cbu->conference_bridge,
-				conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, cbu->b_profile.sounds));
-			ast_autoservice_stop(cbu->chan);
-			ao2_lock(cbu->conference_bridge);
-		}
+		need_prompt = 1;
 
 		AST_LIST_TRAVERSE_SAFE_BEGIN(&cbu->conference_bridge->active_list, cbu_iter, list) {
 			/* Kick ENDMARKED cbu_iters */
-			if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_ENDMARKED)) {
+			if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_ENDMARKED) && !cbu_iter->kicked) {
 				if (ast_test_flag(&cbu_iter->u_profile, USER_OPT_WAITMARKED) &&
 						  !ast_test_flag(&cbu_iter->u_profile, USER_OPT_MARKEDUSER)) {
 					AST_LIST_REMOVE_CURRENT(list);
@@ -159,6 +152,18 @@
 			break; /* Stay in marked */
 		}
 	}
+
+	if (need_prompt) {
+		/* Play back the audio prompt saying the leader has left the conference */
+		if (!ast_test_flag(&cbu->u_profile, USER_OPT_QUIET)) {
+			ao2_unlock(cbu->conference_bridge);
+			ast_autoservice_start(cbu->chan);
+			play_sound_file(cbu->conference_bridge,
+				conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, cbu->b_profile.sounds));
+			ast_autoservice_stop(cbu->chan);
+			ao2_lock(cbu->conference_bridge);
+		}
+	}
 }
 
 static void transition_to_marked(struct conference_bridge_user *cbu)

Modified: certified/tags/11.6-cert1-rc2/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/channels/chan_sip.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/channels/chan_sip.c (original)
+++ certified/tags/11.6-cert1-rc2/channels/chan_sip.c Tue Jan 14 14:35:27 2014
@@ -24111,6 +24111,7 @@
 static void *sip_park_thread(void *stuff)
 {
 	struct ast_channel *transferee, *transferer;	/* Chan1: The transferee, Chan2: The transferer */
+	struct sip_pvt *transferer_pvt;
 	struct sip_dual *d;
 	int ext;
 	int res;
@@ -24118,43 +24119,46 @@
 	d = stuff;
 	transferee = d->chan1;
 	transferer = d->chan2;
+	transferer_pvt = ast_channel_tech_pvt(transferer);
 
 	ast_debug(4, "SIP Park: Transferer channel %s, Transferee %s\n", ast_channel_name(transferer), ast_channel_name(transferee));
 
 	res = ast_park_call_exten(transferee, transferer, d->park_exten, d->park_context, 0, &ext);
 
-	sip_pvt_lock(ast_channel_tech_pvt(transferer));
+	sip_pvt_lock(transferer_pvt);
 #ifdef WHEN_WE_KNOW_THAT_THE_CLIENT_SUPPORTS_MESSAGE
 	if (res) {
-		destroy_msg_headers(ast_channel_tech_pvt(transferer));
-		ast_string_field_set(ast_channel_tech_pvt(transferer), msg_body, "Unable to park call.");
-		transmit_message(ast_channel_tech_pvt(transferer), 0, 0);
+		destroy_msg_headers(transferer_pvt);
+		ast_string_field_set(transferer_pvt, msg_body, "Unable to park call.");
+		transmit_message(transferer_pvt, 0, 0);
 	} else {
 		/* Then tell the transferer what happened */
-		destroy_msg_headers(ast_channel_tech_pvt(transferer));
+		destroy_msg_headers(transferer_pvt);
 		sprintf(buf, "Call parked on extension '%d'.", ext);
-		ast_string_field_set(ast_channel_tech_pvt(transferer), msg_body, buf);
-		transmit_message(ast_channel_tech_pvt(transferer), 0, 0);
+		ast_string_field_set(transferer_pvt, msg_body, buf);
+		transmit_message(transferer_pvt, 0, 0);
 	}
 #endif
 
 	/* Any way back to the current call??? */
 	/* Transmit response to the REFER request */
+	ast_set_flag(&transferer_pvt->flags[0], SIP_DEFER_BYE_ON_TRANSFER);
 	if (!res)	{
 		/* Transfer succeeded */
-		append_history(ast_channel_tech_pvt(transferer), "SIPpark", "Parked call on %d", ext);
-		transmit_notify_with_sipfrag(ast_channel_tech_pvt(transferer), d->seqno, "200 OK", TRUE);
-		sip_pvt_unlock(ast_channel_tech_pvt(transferer));
+		append_history(transferer_pvt, "SIPpark", "Parked call on %d", ext);
+		transmit_notify_with_sipfrag(transferer_pvt, d->seqno, "200 OK", TRUE);
+		sip_pvt_unlock(transferer_pvt);
 		ast_channel_hangupcause_set(transferer, AST_CAUSE_NORMAL_CLEARING);
-		ast_hangup(transferer); /* This will cause a BYE */
 		ast_debug(1, "SIP Call parked on extension '%d'\n", ext);
 	} else {
-		transmit_notify_with_sipfrag(ast_channel_tech_pvt(transferer), d->seqno, "503 Service Unavailable", TRUE);
-		append_history(ast_channel_tech_pvt(transferer), "SIPpark", "Parking failed\n");
-		sip_pvt_unlock(ast_channel_tech_pvt(transferer));
-		ast_debug(1, "SIP Call parked failed \n");
-		/* Do not hangup call */
-	}
+		transmit_notify_with_sipfrag(transferer_pvt, d->seqno, "503 Service Unavailable", TRUE);
+		append_history(transferer_pvt, "SIPpark", "Parking failed\n");
+		sip_pvt_unlock(transferer_pvt);
+		ast_log(AST_LOG_NOTICE, "SIP Call parked failed for %s\n", ast_channel_name(transferee));
+		ast_hangup(transferee);
+	}
+	ast_hangup(transferer);
+
 	deinit_req(&d->req);
 	ast_free(d->park_exten);
 	ast_free(d->park_context);
@@ -24224,6 +24228,7 @@
 
 	/* Prepare for taking over the channel */
 	if (ast_channel_masquerade(transferer, chan2)) {
+		ast_hangup(transferee);
 		ast_hangup(transferer);
 		ast_free(d->park_exten);
 		ast_free(d->park_context);
@@ -24245,6 +24250,8 @@
 	d->seqno = seqno;
 	if (ast_pthread_create_detached_background(&th, NULL, sip_park_thread, d) < 0) {
 		/* Could not start thread */
+		ast_hangup(transferer);
+		ast_hangup(transferee);
 		deinit_req(&d->req);
 		ast_free(d->park_exten);
 		ast_free(d->park_context);

Modified: certified/tags/11.6-cert1-rc2/configs/asterisk.conf.sample
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/configs/asterisk.conf.sample?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/configs/asterisk.conf.sample (original)
+++ certified/tags/11.6-cert1-rc2/configs/asterisk.conf.sample Tue Jan 14 14:35:27 2014
@@ -83,6 +83,12 @@
 				; gosub - Invoke the stdexten using a gosub as
 				;         documented in extensions.conf.sample.
 				; Default gosub.
+;live_dangerously = no		; Enable the execution of 'dangerous' dialplan
+				; functions from external sources (AMI,
+				; etc.) These functions (such as SHELL) are
+				; considered dangerous because they can allow
+				; privilege escalation.
+				; Default yes, for backward compatability.
 
 ; Changing the following lines may compromise your security.
 ;[files]

Modified: certified/tags/11.6-cert1-rc2/configs/logger.conf.sample
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/configs/logger.conf.sample?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/configs/logger.conf.sample (original)
+++ certified/tags/11.6-cert1-rc2/configs/logger.conf.sample Tue Jan 14 14:35:27 2014
@@ -83,24 +83,25 @@
 ;    fax
 ;    security
 ;
-; Special filename "console" represents the system console
+; Special filename "console" represents the root console
 ;
 ; Filenames can either be relative to the standard Asterisk log directory
 ; (see 'astlogdir' in asterisk.conf), or absolute paths that begin with
 ; '/'.
 ;
+; Verbose takes an optional argument, in the form of an integer level.
+; Verbose messages with higher levels will not be logged to the file.  If
+; the verbose level is not specified, it will log verbose messages following
+; the current level of the root console.
+;
 ; Special level name "*" means all levels, even dynamic levels registered
 ; by modules after the logger has been initialized (this means that loading
 ; and unloading modules that create/remove dynamic logger levels will result
 ; in these levels being included on filenames that have a level name of "*",
-; without any need to perform a 'logger reload' or similar operation). Note
-; that there is no value in specifying both "*" and specific level names for
-; a filename; the "*" level means all levels, and the remaining level names
-; will be ignored.
-;
-; Verbose takes an additional argument, in the form of an integer level.
-; Messages with higher levels will be ignored.  If verbose is specified at
-; all, it will default to 3.
+; without any need to perform a 'logger reload' or similar operation).
+; Note that there is no value in specifying both "*" and specific level names
+; for a filename; the "*" level means all levels.  The only exception is if
+; you need to specify a specific verbose level. e.g, "verbose(3),*".
 ;
 ; We highly recommend that you DO NOT turn on debug mode if you are simply
 ; running a production system.  Debug mode turns on a LOT of extra messages,

Modified: certified/tags/11.6-cert1-rc2/funcs/func_db.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/funcs/func_db.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/funcs/func_db.c (original)
+++ certified/tags/11.6-cert1-rc2/funcs/func_db.c Tue Jan 14 14:35:27 2014
@@ -110,6 +110,12 @@
 			<para>This function will retrieve a value from the Asterisk database
 			and then remove that key from the database. <variable>DB_RESULT</variable>
 			will be set to the key's value if it exists.</para>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be read from the
+				dialplan, and not directly from external protocols. It can, however, be
+				executed as a write operation (<literal>DB_DELETE(family, key)=ignored</literal>)</para>
+			</note>
 		</description>
 		<see-also>
 			<ref type="application">DBdel</ref>
@@ -311,10 +317,22 @@
 	return 0;
 }
 
+/*!
+ * \brief Wrapper to execute DB_DELETE from a write operation. Allows execution
+ * even if live_dangerously is disabled.
+ */
+static int function_db_delete_write(struct ast_channel *chan, const char *cmd, char *parse,
+	const char *value)
+{
+	/* Throwaway to hold the result from the read */
+	char buf[128];
+	return function_db_delete(chan, cmd, parse, buf, sizeof(buf));
+}
 
 static struct ast_custom_function db_delete_function = {
 	.name = "DB_DELETE",
 	.read = function_db_delete,
+	.write = function_db_delete_write,
 };
 
 static int unload_module(void)
@@ -335,7 +353,7 @@
 
 	res |= ast_custom_function_register(&db_function);
 	res |= ast_custom_function_register(&db_exists_function);
-	res |= ast_custom_function_register(&db_delete_function);
+	res |= ast_custom_function_register_escalating(&db_delete_function, AST_CFE_READ);
 	res |= ast_custom_function_register(&db_keys_function);
 
 	return res;

Modified: certified/tags/11.6-cert1-rc2/funcs/func_env.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/funcs/func_env.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/funcs/func_env.c (original)
+++ certified/tags/11.6-cert1-rc2/funcs/func_env.c Tue Jan 14 14:35:27 2014
@@ -71,6 +71,11 @@
 			<parameter name="filename" required="true" />
 		</syntax>
 		<description>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be executed from the
+				dialplan, and not directly from external protocols.</para>
+			</note>
 		</description>
 	</function>
 	<function name="FILE" language="en_US">
@@ -167,6 +172,11 @@
 			<para>    Set(FILE(/tmp/foo.txt,-1,,l)=bar)</para>
 			<para>    ; Append "bar" to the file with a newline</para>
 			<para>    Set(FILE(/tmp/foo.txt,,,al)=bar)</para>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be executed from the
+				dialplan, and not directly from external protocols.</para>
+			</note>
 		</description>
 		<see-also>
 			<ref type="function">FILE_COUNT_LINE</ref>
@@ -197,6 +207,11 @@
 		</syntax>
 		<description>
 			<para>Returns the number of lines, or <literal>-1</literal> on error.</para>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be executed from the
+				dialplan, and not directly from external protocols.</para>
+			</note>
 		</description>
 		<see-also>
 			<ref type="function">FILE</ref>
@@ -216,6 +231,11 @@
 			<para>'d' - DOS "\r\n" format</para>
 			<para>'m' - Macintosh "\r" format</para>
 			<para>'x' - Cannot be determined</para>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be executed from the
+				dialplan, and not directly from external protocols.</para>
+			</note>
 		</description>
 		<see-also>
 			<ref type="function">FILE</ref>
@@ -1259,10 +1279,10 @@
 	int res = 0;
 
 	res |= ast_custom_function_register(&env_function);
-	res |= ast_custom_function_register(&stat_function);
-	res |= ast_custom_function_register(&file_function);
-	res |= ast_custom_function_register(&file_count_line_function);
-	res |= ast_custom_function_register(&file_format_function);
+	res |= ast_custom_function_register_escalating(&stat_function, AST_CFE_READ);
+	res |= ast_custom_function_register_escalating(&file_function, AST_CFE_BOTH);
+	res |= ast_custom_function_register_escalating(&file_count_line_function, AST_CFE_READ);
+	res |= ast_custom_function_register_escalating(&file_format_function, AST_CFE_READ);
 
 	return res;
 }

Modified: certified/tags/11.6-cert1-rc2/funcs/func_lock.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/funcs/func_lock.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/funcs/func_lock.c (original)
+++ certified/tags/11.6-cert1-rc2/funcs/func_lock.c Tue Jan 14 14:35:27 2014
@@ -59,6 +59,11 @@
 			Returns <literal>1</literal> if the lock was obtained or <literal>0</literal> on error.</para>
 			<note><para>To avoid the possibility of a deadlock, LOCK will only attempt to
 			obtain the lock for 3 seconds if the channel already has another lock.</para></note>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be executed from the
+				dialplan, and not directly from external protocols.</para>
+			</note>
 		</description>
 	</function>
 	<function name="TRYLOCK" language="en_US">
@@ -72,6 +77,11 @@
 			<para>Attempts to grab a named lock exclusively, and prevents other channels
 			from obtaining the same lock.  Returns <literal>1</literal> if the lock was 
 			available or <literal>0</literal> otherwise.</para>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be executed from the
+				dialplan, and not directly from external protocols.</para>
+			</note>
 		</description>
 	</function>
 	<function name="UNLOCK" language="en_US">
@@ -86,6 +96,11 @@
 			had a lock or <literal>0</literal> otherwise.</para>
 			<note><para>It is generally unnecessary to unlock in a hangup routine, as any locks 
 			held are automatically freed when the channel is destroyed.</para></note>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be executed from the
+				dialplan, and not directly from external protocols.</para>
+			</note>
 		</description>
 	</function>
  ***/
@@ -502,9 +517,9 @@
 
 static int load_module(void)
 {
-	int res = ast_custom_function_register(&lock_function);
-	res |= ast_custom_function_register(&trylock_function);
-	res |= ast_custom_function_register(&unlock_function);
+	int res = ast_custom_function_register_escalating(&lock_function, AST_CFE_READ);
+	res |= ast_custom_function_register_escalating(&trylock_function, AST_CFE_READ);
+	res |= ast_custom_function_register_escalating(&unlock_function, AST_CFE_READ);
 
 	if (ast_pthread_create_background(&broker_tid, NULL, lock_broker, NULL)) {
 		ast_log(LOG_ERROR, "Failed to start lock broker thread. Unloading func_lock module.\n");

Modified: certified/tags/11.6-cert1-rc2/funcs/func_realtime.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/funcs/func_realtime.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/funcs/func_realtime.c (original)
+++ certified/tags/11.6-cert1-rc2/funcs/func_realtime.c Tue Jan 14 14:35:27 2014
@@ -115,6 +115,12 @@
 		<description>
 			<para>This function acts in the same way as REALTIME(....) does, except that
 			it destroys the matched record in the RT engine.</para>
+			<note>
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be read from the
+				dialplan, and not directly from external protocols. It can, however, be
+				executed as a write operation (<literal>REALTIME_DESTROY(family, fieldmatch)=ignored</literal>)</para>
+			</note>
 		</description>
 		<see-also>
 			<ref type="function">REALTIME</ref>
@@ -439,28 +445,32 @@
 		return -1;
 	}
 
-	resultslen = 0;
-	n = 0;
-	for (var = head; var; n++, var = var->next)
-		resultslen += strlen(var->name) + strlen(var->value);
-	/* add space for delimiters and final '\0' */
-	resultslen += n * (strlen(args.delim1) + strlen(args.delim2)) + 1;
-
-	if (resultslen > len) {
-		/* Unfortunately this does mean that we cannot destroy the row
-		 * anymore. But OTOH, we're not destroying someones data without
-		 * giving him the chance to look at it. */
-		ast_log(LOG_WARNING, "Failed to fetch/destroy. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
-		return -1;
-	}
-
-	/* len is going to be sensible, so we don't need to check for stack
-	 * overflows here. */
-	out = ast_str_alloca(resultslen);
-	for (var = head; var; var = var->next) {
-		ast_str_append(&out, 0, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1);
-	}
-	ast_copy_string(buf, ast_str_buffer(out), len);
+	if (len > 0) {
+		resultslen = 0;
+		n = 0;
+		for (var = head; var; n++, var = var->next) {
+			resultslen += strlen(var->name) + strlen(var->value);
+		}
+		/* add space for delimiters and final '\0' */
+		resultslen += n * (strlen(args.delim1) + strlen(args.delim2)) + 1;
+
+		if (resultslen > len) {
+			/* Unfortunately this does mean that we cannot destroy
+			 * the row anymore. But OTOH, we're not destroying
+			 * someones data without giving him the chance to look
+			 * at it. */
+			ast_log(LOG_WARNING, "Failed to fetch/destroy. Realtime data is too large: need %zu, have %zu.\n", resultslen, len);
+			return -1;
+		}
+
+		/* len is going to be sensible, so we don't need to check for
+		 * stack overflows here. */
+		out = ast_str_alloca(resultslen);
+		for (var = head; var; var = var->next) {
+			ast_str_append(&out, 0, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1);
+		}
+		ast_copy_string(buf, ast_str_buffer(out), len);
+	}
 
 	ast_destroy_realtime(args.family, args.fieldmatch, args.value, SENTINEL);
 	ast_variables_destroy(head);
@@ -469,6 +479,15 @@
 		ast_autoservice_stop(chan);
 
 	return 0;
+}
+
+/*!
+ * \brief Wrapper to execute REALTIME_DESTROY from a write operation. Allows
+ * execution even if live_dangerously is disabled.
+ */
+static int function_realtime_writedestroy(struct ast_channel *chan, const char *cmd, char *data, const char *value)
+{
+	return function_realtime_readdestroy(chan, cmd, data, NULL, 0);
 }
 
 static struct ast_custom_function realtime_function = {
@@ -496,6 +515,7 @@
 static struct ast_custom_function realtime_destroy_function = {
 	.name = "REALTIME_DESTROY",
 	.read = function_realtime_readdestroy,
+	.write = function_realtime_writedestroy,
 };
 
 static int unload_module(void)
@@ -514,7 +534,7 @@
 	int res = 0;
 	res |= ast_custom_function_register(&realtime_function);
 	res |= ast_custom_function_register(&realtime_store_function);
-	res |= ast_custom_function_register(&realtime_destroy_function);
+	res |= ast_custom_function_register_escalating(&realtime_destroy_function, AST_CFE_READ);
 	res |= ast_custom_function_register(&realtimefield_function);
 	res |= ast_custom_function_register(&realtimehash_function);
 	return res;

Modified: certified/tags/11.6-cert1-rc2/funcs/func_shell.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/funcs/func_shell.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/funcs/func_shell.c (original)
+++ certified/tags/11.6-cert1-rc2/funcs/func_shell.c Tue Jan 14 14:35:27 2014
@@ -88,11 +88,17 @@
 		</syntax>
 		<description>
 			<para>Collects the output generated by a command executed by the system shell</para>
-			<para>Example:  <literal>Set(foo=${SHELL(echo \bar\)})</literal></para>
-			<note><para>The command supplied to this function will be executed by the
-			system's shell, typically specified in the SHELL environment variable. There
-			are many different system shells available with somewhat different behaviors,
-			so the output generated by this function may vary between platforms.</para></note>
+			<para>Example:  <literal>Set(foo=${SHELL(echo bar)})</literal></para>
+			<note>
+				<para>The command supplied to this function will be executed by the
+				system's shell, typically specified in the SHELL environment variable. There
+				are many different system shells available with somewhat different behaviors,
+				so the output generated by this function may vary between platforms.</para>
+
+				<para>If <literal>live_dangerously</literal> in <literal>asterisk.conf</literal>
+				is set to <literal>no</literal>, this function can only be executed from the
+				dialplan, and not directly from external protocols.</para>
+			</note>
 		</description>
 
 	</function>
@@ -109,7 +115,7 @@
 
 static int load_module(void)
 {
-	return ast_custom_function_register(&shell_function);
+	return ast_custom_function_register_escalating(&shell_function, AST_CFE_READ);
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Collects the output generated by a command executed by the system shell");

Modified: certified/tags/11.6-cert1-rc2/funcs/func_timeout.c
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/funcs/func_timeout.c?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/funcs/func_timeout.c (original)
+++ certified/tags/11.6-cert1-rc2/funcs/func_timeout.c Tue Jan 14 14:35:27 2014
@@ -156,13 +156,15 @@
 	case 'a':
 	case 'A':
 		ast_channel_setwhentohangup_tv(chan, when);
-		if (!ast_tvzero(*ast_channel_whentohangup(chan))) {
-			when = ast_tvadd(when, ast_tvnow());
-			ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S.%3q %Z",
-				ast_localtime(&when, &myt, NULL));
-			ast_verb(3, "Channel will hangup at %s.\n", timestr);
-		} else {
-			ast_verb(3, "Channel hangup cancelled.\n");
+		if (VERBOSITY_ATLEAST(3)) {
+			if (!ast_tvzero(*ast_channel_whentohangup(chan))) {
+				when = ast_tvadd(when, ast_tvnow());
+				ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S.%3q %Z",
+					ast_localtime(&when, &myt, NULL));
+				ast_verb(3, "Channel will hangup at %s.\n", timestr);
+			} else {
+				ast_verb(3, "Channel hangup cancelled.\n");
+			}
 		}
 		break;
 

Modified: certified/tags/11.6-cert1-rc2/include/asterisk/logger.h
URL: http://svnview.digium.com/svn/asterisk/certified/tags/11.6-cert1-rc2/include/asterisk/logger.h?view=diff&rev=405537&r1=405536&r2=405537
==============================================================================
--- certified/tags/11.6-cert1-rc2/include/asterisk/logger.h (original)
+++ certified/tags/11.6-cert1-rc2/include/asterisk/logger.h Tue Jan 14 14:35:27 2014
@@ -87,21 +87,29 @@
 
 void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...);
 
-/*! Send a verbose message (based on verbose level)
- *	\brief This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
- *	ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
- *	This will print the message to the console if the verbose level is set to a level >= 3
- *	Note the absence of a comma after the VERBOSE_PREFIX_3.  This is important.
- *	VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.
- *  \version 11 added level parameter
+/*!
+ * \brief Send a verbose message (based on verbose level)
+ *
+ * \details This works like ast_log, but prints verbose messages to the console depending on verbosity level set.
+ *
+ * ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");
+ *
+ * This will print the message to the console if the verbose level is set to a level >= 3
+ *
+ * Note the absence of a comma after the VERBOSE_PREFIX_3.  This is important.
+ * VERBOSE_PREFIX_1 through VERBOSE_PREFIX_4 are defined.
+ *
+ * \version 11 added level parameter
  */
 void __attribute__((format(printf, 5, 6))) __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt, ...);
 
-/*! Send a verbose message (based on verbose level) with deliberately specified callid
- *  \brief just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used
- *  for the log without needing to bind it to a thread. NULL is a valid argument for this function and will
- *  allow you to specify that a log will never display a call id even when there is a call id bound to the
- *  thread.
+/*!
+ * \brief Send a verbose message (based on verbose level) with deliberately specified callid
+ *
+ * \details just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used
+ * for the log without needing to bind it to a thread. NULL is a valid argument for this function and will
+ * allow you to specify that a log will never display a call id even when there is a call id bound to the
+ * thread.
  */
 void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, struct ast_callid *callid, const char *fmt, ...);
 
@@ -114,6 +122,14 @@
 
 int ast_register_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
 int ast_unregister_verbose(void (*verboser)(const char *string)) attribute_warn_unused_result;
+
+/*
+ * These gymnastics are due to platforms which designate char as unsigned by
+ * default.  Level is the negative character -- offset by 1, because \0 is
+ * the string terminator.
+ */
+#define VERBOSE_MAGIC2LEVEL(x) (((char) -*(signed char *) (x)) - 1)
+#define VERBOSE_HASMAGIC(x)	(*(signed char *) (x) < 0)
 
 void ast_console_puts(const char *string);
 
@@ -222,8 +238,9 @@

[... 1790 lines stripped ...]



More information about the asterisk-commits mailing list