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
This commit is contained in:
Corey Farrell 2018-07-26 13:52:46 -04:00
parent 7e0e6fd123
commit 709f4b81e7
15 changed files with 32 additions and 6 deletions

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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;

View File

@ -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,
);

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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",
);

View File

@ -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,

View File

@ -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",
);