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
........

Merged revisions 382066 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@382067 65c4cc65-6c06-0410-ace0-fbb531ad65f3
changes/78/78/1
Matthew Jordan 12 years ago
parent 9ad3e219c4
commit 33e4c6115f

@ -504,6 +504,7 @@ struct confbridge_cfg {
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);
@ -641,6 +642,7 @@ static void *confbridge_cfg_alloc(void);
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 */
@ -1749,6 +1751,41 @@ static int menu_option_handler(const struct aco_option *opt, struct ast_variable
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) {

@ -9,6 +9,10 @@
; 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 ---
[default_user]

Loading…
Cancel
Save