[asterisk-commits] mjordan: branch 11 r382066 - in /branches/11: apps/confbridge/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 26 09:24:39 CST 2013


Author: mjordan
Date: Tue Feb 26 09:24:35 2013
New Revision: 382066

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382066
Log:
Ensure that the default bridge/user profiles are always available

ConfBridge and Page require that there always be a default bridge and user
profile available. While properties of the default profiles can be overriden
in the configuration file, removing them can create situations where neither
application can function properly.

This patch ensures that if an administrator removes the profiles from the
confbridge.conf configuration file, the profiles are added upon load.
Documentation clarifying this has been added to the confbridge.conf.sample file.

Review: https://reviewboard.asterisk.org/r/2356/

(closes issue AST-1115)
Reported by: John Bigelow
Tested by: John Bigelow

Modified:
    branches/11/apps/confbridge/conf_config_parser.c
    branches/11/configs/confbridge.conf.sample

Modified: branches/11/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/apps/confbridge/conf_config_parser.c?view=diff&rev=382066&r1=382065&r2=382066
==============================================================================
--- branches/11/apps/confbridge/conf_config_parser.c (original)
+++ branches/11/apps/confbridge/conf_config_parser.c Tue Feb 26 09:24:35 2013
@@ -46,6 +46,7 @@
 	struct ao2_container *menus;
 };
 
+static int verify_default_profiles(void);
 static void *bridge_profile_alloc(const char *category);
 static void *bridge_profile_find(struct ao2_container *container, const char *category);
 static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void);
@@ -179,6 +180,7 @@
 
 CONFIG_INFO_STANDARD(cfg_info, cfg_handle, confbridge_cfg_alloc,
 	.files = ACO_FILES(&confbridge_conf),
+	.pre_apply_config = verify_default_profiles,
 );
 
 /*! bridge profile container functions */
@@ -1283,6 +1285,41 @@
 	return 0;
 }
 
+static int verify_default_profiles(void)
+{
+	RAII_VAR(struct user_profile *, user_profile, NULL, ao2_cleanup);
+	RAII_VAR(struct bridge_profile *, bridge_profile, NULL, ao2_cleanup);
+	struct confbridge_cfg *cfg = aco_pending_config(&cfg_info);
+
+	if (!cfg) {
+		return 0;
+	}
+
+	bridge_profile = ao2_find(cfg->bridge_profiles, DEFAULT_BRIDGE_PROFILE, OBJ_KEY);
+	if (!bridge_profile) {
+		bridge_profile = bridge_profile_alloc(DEFAULT_BRIDGE_PROFILE);
+		if (!bridge_profile) {
+			return -1;
+		}
+		ast_log(AST_LOG_NOTICE, "Adding %s profile to app_confbridge\n", DEFAULT_BRIDGE_PROFILE);
+		aco_set_defaults(&bridge_type, DEFAULT_BRIDGE_PROFILE, bridge_profile);
+		ao2_link(cfg->bridge_profiles, bridge_profile);
+	}
+
+	user_profile = ao2_find(cfg->bridge_profiles, DEFAULT_USER_PROFILE, OBJ_KEY);
+	if (!user_profile) {
+		user_profile = user_profile_alloc(DEFAULT_USER_PROFILE);
+		if (!user_profile) {
+			return -1;
+		}
+		ast_log(AST_LOG_NOTICE, "Adding %s profile to app_confbridge\n", DEFAULT_USER_PROFILE);
+		aco_set_defaults(&user_type, DEFAULT_USER_PROFILE, user_profile);
+		ao2_link(cfg->user_profiles, user_profile);
+	}
+
+	return 0;
+}
+
 int conf_load_config(int reload)
 {
 	if (!reload) {

Modified: branches/11/configs/confbridge.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/11/configs/confbridge.conf.sample?view=diff&rev=382066&r1=382065&r2=382066
==============================================================================
--- branches/11/configs/confbridge.conf.sample (original)
+++ branches/11/configs/confbridge.conf.sample Tue Feb 26 09:24:35 2013
@@ -8,6 +8,10 @@
 ; The default_user and default_bridge sections are applied
 ; automatically to all ConfBridge instances invoked without
 ; a user, or bridge argument.  No menu is applied by default.
+;
+; Note that while properties of the default_user or default_bridge
+; profile can be overridden, if removed, they will be automatically
+; added and made available to the dialplan upon module load.
 ;
 
 ; --- ConfBridge User Profile Options ---




More information about the asterisk-commits mailing list