Be a little smarter about checking names in authenticate section
authoraland <aland>
Fri, 7 Apr 2006 17:49:59 +0000 (17:49 +0000)
committeraland <aland>
Fri, 7 Apr 2006 17:49:59 +0000 (17:49 +0000)
src/main/modules.c

index 4e1eca9..285844e 100644 (file)
@@ -508,6 +508,9 @@ static int load_component_section(CONF_SECTION *cs, int comp,
        for (modref = cf_item_find_next(cs, NULL);
             modref != NULL;
             modref = cf_item_find_next(cs, modref)) {
+               CONF_PAIR *cp = NULL;
+               CONF_SECTION *scs = NULL;
+
                /*
                 *      Look for Auth-Type foo {}, which are special
                 *      cases of named sections, and allowable ONLY
@@ -518,7 +521,6 @@ static int load_component_section(CONF_SECTION *cs, int comp,
                 */
                if (cf_item_is_section(modref)) {
                        const char *sec_name;
-                       CONF_SECTION *scs;
                        scs = cf_itemtosection(modref);
 
                        sec_name = cf_section_name1(scs);
@@ -543,8 +545,8 @@ static int load_component_section(CONF_SECTION *cs, int comp,
                                }
                                continue;
                        }
+                       cp = NULL;
                } else {
-                       CONF_PAIR *cp;
                        cp = cf_itemtopair(modref);
                }
 
@@ -562,16 +564,30 @@ static int load_component_section(CONF_SECTION *cs, int comp,
 
                if (comp == RLM_COMPONENT_AUTH) {
                        DICT_VALUE *dval;
+                       const char *modrefname = NULL;
+
+                       if (cp) {
+                               modrefname = cf_pair_attr(cp);
+                       } else {
+                               modrefname = cf_section_name2(scs);
+                               if (!modrefname) {
+                                       radlog(L_ERR|L_CONS,
+                                              "%s[%d] Failed to parse %s sub-section.\n",
+                                              filename, cf_section_lineno(scs),
+                                              cf_section_name1(scs));
+                                       return -1;
+                               }
+                       }
 
-                       dval = dict_valbyname(PW_AUTH_TYPE, modname);
+                       dval = dict_valbyname(PW_AUTH_TYPE, modrefname);
                        if (!dval) {
                                /*
                                 *      It's a section, but nothing we
                                 *      recognize.  Die!
                                 */
-                               radlog(L_ERR|L_CONS, "%s[%d] Unknown Auth-Type \"%s\" in %s section.",
-                                      filename, cf_section_lineno(cs),
-                                      modname, section_type_value[comp].section);
+                               radlog(L_ERR|L_CONS, "%s[%d] Unknown Auth-Type \"%s\" in %s sub-section.",
+                                      filename, cf_section_lineno(scs),
+                                      modrefname, section_type_value[comp].section);
                                return -1;
                        }
                        idx = dval->value;
@@ -650,9 +666,7 @@ int setup_modules(int reload)
                /*
                 *      Initialize the components.
                 */
-               for (comp = 0; comp < RLM_COMPONENT_COUNT; comp++) {
-                       components[comp] = NULL;
-               }
+               memset(components, 0, sizeof(components));
 
                /*
                 *      Set up the internal module struct.