From 709f4b81e70191e21fa2bcaea1db0ef656fa2aff Mon Sep 17 00:00:00 2001 From: Corey Farrell <git@cfware.com> Date: Thu, 26 Jul 2018 13:52:46 -0400 Subject: [PATCH] loader: Process dependencies for built-in modules. With the new module loader it was missed that built-in modules never parsed dependencies from mod->info into vectors of mod. This caused manager to be initialized before acl (named_acl). If manager.conf used any named ACL's they would not be found and result in no ACL being applied to the AMI user. In addition to the manager ACL fix this adds "extconfig" to all builtin modules which support realtime configuration. This only matters if one of the builtin modules is configured with 'preload', depending on "extconfig" will cause config.c to automatically be initialize during the preload stage. Change-Id: I482ed6bca6c1064b05bb538d7861cd7a4f02d9fc --- main/cdr.c | 1 + main/cel.c | 1 + main/dnsmgr.c | 1 + main/dsp.c | 1 + main/enum.c | 1 + main/features.c | 1 + main/http.c | 1 + main/indications.c | 1 + main/loader.c | 23 ++++++++++++++++++----- main/logger.c | 1 + main/manager.c | 2 +- main/named_acl.c | 1 + main/plc.c | 1 + main/sounds.c | 1 + main/udptl.c | 1 + 15 files changed, 32 insertions(+), 6 deletions(-) diff --git a/main/cdr.c b/main/cdr.c index 62fcdf5dda..1c47e24173 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -4628,4 +4628,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/cel.c b/main/cel.c index 91c625a3c2..0ec728e558 100644 --- a/main/cel.c +++ b/main/cel.c @@ -1753,4 +1753,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/dnsmgr.c b/main/dnsmgr.c index c25b601b33..db13b1d23e 100644 --- a/main/dnsmgr.c +++ b/main/dnsmgr.c @@ -523,4 +523,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/dsp.c b/main/dsp.c index ea653d857b..433e61a4b8 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -2425,4 +2425,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/enum.c b/main/enum.c index 8b6d3fe759..344ae404d5 100644 --- a/main/enum.c +++ b/main/enum.c @@ -1023,4 +1023,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/features.c b/main/features.c index 3db6d397b4..8c2d9bc7dc 100644 --- a/main/features.c +++ b/main/features.c @@ -1174,4 +1174,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_features_config, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/http.c b/main/http.c index 55d10290ba..d7ec60a961 100644 --- a/main/http.c +++ b/main/http.c @@ -2314,4 +2314,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/indications.c b/main/indications.c index c9f02416f9..6a7414dcc4 100644 --- a/main/indications.c +++ b/main/indications.c @@ -1158,4 +1158,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/loader.c b/main/loader.c index d6837f8601..eb345b5eb5 100644 --- a/main/loader.c +++ b/main/loader.c @@ -569,6 +569,18 @@ void ast_module_register(const struct ast_module_info *info) *((struct ast_module **) &(info->self)) = mod; } +static int module_post_register(struct ast_module *mod) +{ + int res; + + /* Split lists from mod->info. */ + res = ast_vector_string_split(&mod->requires, mod->info->requires, ",", 0, strcasecmp); + res |= ast_vector_string_split(&mod->optional_modules, mod->info->optional_modules, ",", 0, strcasecmp); + res |= ast_vector_string_split(&mod->enhances, mod->info->enhances, ",", 0, strcasecmp); + + return res; +} + static void module_destroy(struct ast_module *mod) { AST_VECTOR_CALLBACK_VOID(&mod->requires, ast_free); @@ -1526,11 +1538,7 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; } - /* Split lists from mod->info. */ - res = ast_vector_string_split(&mod->requires, mod->info->requires, ",", 0, strcasecmp); - res |= ast_vector_string_split(&mod->optional_modules, mod->info->optional_modules, ",", 0, strcasecmp); - res |= ast_vector_string_split(&mod->enhances, mod->info->enhances, ",", 0, strcasecmp); - if (res) { + if (module_post_register(mod)) { goto prestart_error; } } @@ -1846,6 +1854,11 @@ static int loader_builtin_init(struct load_order *load_order) continue; } + /* Parse dependendencies from mod->info. */ + if (module_post_register(mod)) { + return -1; + } + /* Built-in modules are not preloaded, most have an early load priority. */ if (!add_to_load_order(mod->resource, load_order, 0, 0, 1)) { return -1; diff --git a/main/logger.c b/main/logger.c index 46d61ed336..8b4f678ca7 100644 --- a/main/logger.c +++ b/main/logger.c @@ -2381,6 +2381,7 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, + /* This reload does not support realtime so it does not require "extconfig". */ .reload = reload_module, .load_pri = 0, ); diff --git a/main/manager.c b/main/manager.c index ab42432446..a0dcf6c861 100644 --- a/main/manager.c +++ b/main/manager.c @@ -9600,5 +9600,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, - .requires = "http", + .requires = "extconfig,acl,http", ); diff --git a/main/named_acl.c b/main/named_acl.c index c4628216fd..8cf09c2a07 100644 --- a/main/named_acl.c +++ b/main/named_acl.c @@ -591,4 +591,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/plc.c b/main/plc.c index 369d285a58..20d5122203 100644 --- a/main/plc.c +++ b/main/plc.c @@ -296,4 +296,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); diff --git a/main/sounds.c b/main/sounds.c index 745b628051..e0cb33a53f 100644 --- a/main/sounds.c +++ b/main/sounds.c @@ -340,6 +340,7 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, + /* This reload doesn't use config so this module doesn't require "extconfig". */ .reload = reload_module, /* Load after the format modules to reduce processing during startup. */ .load_pri = AST_MODPRI_APP_DEPEND + 1, diff --git a/main/udptl.c b/main/udptl.c index f6cd3b90a1..7349d6aa4c 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -1420,4 +1420,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, + .requires = "extconfig", ); -- GitLab