diff options
author | Matthew Jordan <mjordan@digium.com> | 2013-02-26 15:26:16 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2013-02-26 15:26:16 +0000 |
commit | 33e4c6115fe0ce4339d84d8701c89a8cb51d4583 (patch) | |
tree | fc3977af9de67b027b047adb304da19c4f1ecf9d /apps/confbridge/conf_config_parser.c | |
parent | 9ad3e219c4aed1d41e6d3af0f2b5d115664920c5 (diff) |
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
Diffstat (limited to 'apps/confbridge/conf_config_parser.c')
-rw-r--r-- | apps/confbridge/conf_config_parser.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c index ecb989f7b..560bee4e1 100644 --- a/apps/confbridge/conf_config_parser.c +++ b/apps/confbridge/conf_config_parser.c @@ -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) { |