Pass CONF_SECTION to setup_modules(), in preparation for
authoraland <aland>
Thu, 28 Jun 2007 10:34:27 +0000 (10:34 +0000)
committeraland <aland>
Thu, 28 Jun 2007 10:34:27 +0000 (10:34 +0000)
making HUP easier.

Load ALL virtual servers, whether or not they're referenced.
We can set Virtual-Server in an expanded string taken from
an SQL query, so there's no way of knowing from the config files
if a server is needed.

If a server isn't needed, don't list it in sites-enabled/

Load the default server last.

src/include/modules.h
src/main/mainconfig.c
src/main/modules.c

index e3c1e2a..46c7d53 100644 (file)
@@ -55,7 +55,7 @@ enum {
        RLM_MODULE_NUMCODES     /* How many return codes there are */
 };
 
-int setup_modules(int);
+int setup_modules(int, CONF_SECTION *);
 int detach_modules(void);
 int module_authorize(int type, REQUEST *request);
 int module_authenticate(int type, REQUEST *request);
index 95235ee..edbcbaa 100644 (file)
@@ -961,7 +961,7 @@ int read_mainconfig(int reload)
 
        /*  Reload the modules.  */
        DEBUG2("radiusd:  entering modules setup");
-       if (setup_modules(reload) < 0) {
+       if (setup_modules(reload, mainconfig.config) < 0) {
                radlog(L_ERR|L_CONS, "Errors setting up modules");
                return -1;
        }
index 6c3e4b5..b97f775 100644 (file)
@@ -736,7 +736,7 @@ static int load_byspace(CONF_SECTION *cs, const char *space,
  *     Libtool makes your life a LOT easier, especially with libltdl.
  *     see: http://www.gnu.org/software/libtool/
  */
-int setup_modules(int reload)
+int setup_modules(int reload, CONF_SECTION *config)
 {
        int             comp;
        CONF_SECTION    *cs, *modules;
@@ -846,7 +846,7 @@ int setup_modules(int reload)
        /*
         *      Remember where the modules were stored.
         */
-       modules = cf_section_find("modules");
+       modules = cf_section_sub_find(config, "modules");
        if (!modules) {
                radlog(L_ERR, "Cannot find a \"modules\" section in the configuration file!");
                return -1;
@@ -858,7 +858,7 @@ int setup_modules(int reload)
         *  us to load modules with no authorize/authenticate/etc.
         *  sections.
         */
-       cs = cf_section_find("instantiate");
+       cs = cf_section_sub_find(config, "instantiate");
        if (cs != NULL) {
                CONF_ITEM *ci;
                CONF_PAIR *cp;
@@ -893,54 +893,54 @@ int setup_modules(int reload)
                DEBUG2(" }");
        } /* if there's an 'instantiate' section. */
 
-       if (load_byspace(mainconfig.config, NULL, do_component) < 0) {
-               return -1;
-       }
-
        /*
-        *      Load by identities, and by vmps.
+        *      Load *all*.  If you don't want one loaded, don't list
+        *      it in sites-enabled/
         */
        for (listener = mainconfig.listen;
             listener != NULL;
             listener = listener->next) {
-               if (listener->type == RAD_LISTEN_VQP) {
-                       cs = cf_section_find("vmps");
-                       if (!cs) {
-                               radlog(L_ERR, "Listening on vmps socket, but no vmps section");
-                               return -1;
-                       }
-                       
-                       if (cf_item_find_next(cs, NULL) == NULL) {
-                               radlog(L_ERR, "Listening on vmps socket, vmps section is empty");
-                               return -1;
-                       }
-                       
-                       DEBUG2(" Module: Checking vmps {...} for more modules to load");
-                       
-                       if (load_component_section(NULL, cs, VMPS_SPACE,
-                                                  RLM_COMPONENT_POST_AUTH) < 0) {
-                               return -1;
-                       }
+               if (listener->type != RAD_LISTEN_VQP) continue;
+
+               cs = cf_section_sub_find(config, "vmps");
+               if (!cs) {
+                       radlog(L_ERR, "Listening on vmps socket, but no vmps section");
+                       return -1;
+               }
+               
+               if (cf_item_find_next(cs, NULL) == NULL) {
+                       radlog(L_ERR, "Listening on vmps socket, vmps section is empty");
+                       return -1;
+               }
                        
-                       continue;
+               DEBUG2(" Module: Checking vmps {...} for more modules to load");
+               
+               if (load_component_section(NULL, cs, VMPS_SPACE,
+                                          RLM_COMPONENT_POST_AUTH) < 0) {
+                       return -1;
                }
+       }
 
-               if (!listener->server) continue;
-
-               /*
-                *      Load by server
-                */
-               cs = cf_section_sub_find_name2(mainconfig.config,
-                                              "server", listener->server);
-               if (!cs) continue;
+       /*
+        *      Load all of the virtual servers.
+        */
+       for (cs = cf_subsection_find_next(config, NULL, "server");
+            cs != NULL;
+            cs = cf_subsection_find_next(config, cs, "server")) {
+               const char *name2 = cf_section_name2(cs);
 
-               DEBUG2("server %s {", listener->server);
-               if (load_byspace(cs, listener->server, do_component) < 0) {
+               DEBUG2("server %s {", name2);
+               if (load_byspace(cs, name2, do_component) < 0) {
                        DEBUG2("}");
                        return -1;
                }
                DEBUG2("}");
        }
+               
+       if (load_byspace(config, NULL, do_component) < 0) {
+               return -1;
+       }
+
 
        return 0;
 }