} module_instance_t;
module_instance_t *module_instantiate(CONF_SECTION *modules, char const *askedname);
+module_instance_t *module_instantiate_method(CONF_SECTION *modules, char const *askedname, rlm_components_t *method);
module_instance_t *module_find(CONF_SECTION *modules, char const *askedname);
int find_module_sibling_section(CONF_SECTION **out, CONF_SECTION *module, char const *name);
int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when);
* modules belongs in raddb/mods-available/,
* which isn't loaded into the "modules" section.
*/
- if (cf_section_sub_find_name2(modules, NULL, realname)) {
- this = module_instantiate(modules, realname);
- if (this) goto allocate_csingle;
-
- /*
- *
- */
- if (realname != modrefname) {
- return NULL;
- }
-
- } else {
- /*
- * We were asked to MAYBE load it and it
- * doesn't exist. Return a soft error.
- */
- if (realname != modrefname) {
- *modname = modrefname;
- return NULL;
- }
- }
- }
-
- /*
- * No module found by that name. Maybe we're calling
- * module.method
- */
- p = strrchr(modrefname, '.');
- if (p) {
- rlm_components_t i;
- p++;
+ this = module_instantiate_method(modules, realname, &method);
+ if (this) goto allocate_csingle;
/*
- * Find the component.
+ * We were asked to MAYBE load it and it
+ * doesn't exist. Return a soft error.
*/
- for (i = MOD_AUTHENTICATE;
- i < MOD_COUNT;
- i++) {
- if (strcmp(p, comp2str[i]) == 0) {
- char buffer[256];
-
- strlcpy(buffer, modrefname, sizeof(buffer));
- buffer[p - modrefname - 1] = '\0';
- component = i;
-
- this = module_instantiate(modules, buffer);
- if (this) {
- method = i;
- goto allocate_csingle;
- }
- }
+ if (realname != modrefname) {
+ *modname = modrefname;
+ return NULL;
}
-
- /*
- * FIXME: check for "module", and give error "no
- * such component" when we don't find the method.
- */
}
/*
*
*/
module_instance_t *module_instantiate(CONF_SECTION *modules, char const *askedname)
-
{
module_instance_t *node;
return node;
}
+
+module_instance_t *module_instantiate_method(CONF_SECTION *modules, char const *name, rlm_components_t *method)
+{
+ char *p;
+ rlm_components_t i;
+ module_instance_t *mi;
+
+ /*
+ * Don't change "method" if it's just "module" name.
+ */
+ mi = module_instantiate(modules, name);
+ if (mi) return mi;
+
+ /*
+ * Find out which method is being used.
+ */
+ p = strrchr(name, ".");
+ if (!p) return NULL;
+
+ p++;
+
+ /*
+ * Find the component.
+ */
+ for (i = MOD_AUTHENTICATE; i < MOD_COUNT; i++) {
+ if (strcmp(p, section_type_value[i].section) == 0) {
+ char buffer[256];
+
+ strlcpy(buffer, name, sizeof(buffer));
+ buffer[p - name - 1] = '\0';
+
+ mi = module_instantiate(modules, buffer);
+ if (mi) {
+ if (method) *method = i;
+ return mi;
+ }
+ }
+ }
+
+ /*
+ * Not found.
+ */
+ return NULL;
+}
+
+
/** Resolve polymorphic item's from a module's CONF_SECTION to a subsection in another module
*
* This allows certain module sections to reference module sections in other instances
for (ci=cf_item_find_next(cs, NULL);
ci != NULL;
ci=cf_item_find_next(cs, ci)) {
-
/*
* Skip sections and "other" stuff.
* Sections will be handled later, if
return -1;
}
- module = module_instantiate(modules, cf_pair_attr(cp));
+ /*
+ * Allow "foo.authorize" in subsections.
+ */
+ module = module_instantiate_method(modules, cf_pair_attr(cp), NULL);
if (!module) {
return -1;
}