Ignore post-proxy type if proxy is disabled
[freeradius.git] / src / main / modules.c
index 32fffa1..accb8b9 100644 (file)
@@ -104,6 +104,17 @@ static const section_type_value_t section_type_value[RLM_COMPONENT_COUNT] = {
 #define RTLD_LOCAL (0)
 #endif
 
+#define fr_dlopenext lt_dlopenext
+#ifndef LT_SHREXT
+#ifdef __APPLE__
+#define LT_SHREXT ".so"
+#elif defined (WIN32)
+#define LT_SHREXT ".dll"
+#else
+#define LT_SHREXT ".dylib"
+#endif
+#endif
+
 lt_dlhandle lt_dlopenext(const char *name)
 {
        char buffer[256];
@@ -113,7 +124,7 @@ lt_dlhandle lt_dlopenext(const char *name)
        /*
         *      FIXME: Make this configurable...
         */
-       strlcat(buffer, ".so", sizeof(buffer));
+       strlcat(buffer, LT_SHREXT, sizeof(buffer));
 
        return dlopen(buffer, RTLD_NOW | RTLD_LOCAL);
 }
@@ -125,6 +136,8 @@ void *lt_dlsym(lt_dlhandle handle, UNUSED const char *symbol)
 
 int lt_dlclose(lt_dlhandle handle)
 {
+       if (!handle) return 0;
+
        return dlclose(handle);
 }
 
@@ -172,6 +185,7 @@ static const lt_dlmodule_t lt_dlmodules[] = {
        { NULL, NULL }
 };
 
+#define fr_dlopenext lt_dlopenext
 lt_dlhandle lt_dlopenext(const char *name)
 {
        int i;
@@ -424,7 +438,7 @@ static module_entry_t *linkto_module(const char *module_name,
 {
        module_entry_t myentry;
        module_entry_t *node;
-       lt_dlhandle handle;
+       lt_dlhandle handle = NULL;
        char module_struct[256];
        char *p;
        const module_t *module;
@@ -434,6 +448,21 @@ static module_entry_t *linkto_module(const char *module_name,
        if (node) return node;
 
        /*
+        *      Link to the module's rlm_FOO{} module structure.
+        *
+        *      The module_name variable has the version number
+        *      embedded in it, and we don't want that here.
+        */
+       strcpy(module_struct, module_name);
+       p = strrchr(module_struct, '-');
+       if (p) *p = '\0';
+
+#if defined(WITHOUT_LIBLTDL) && defined (WITH_DLOPEN) && defined(RTLD_SELF)
+       module = lt_dlsym(RTLD_SELF, module_struct);
+       if (module) goto open_self;
+#endif
+
+       /*
         *      Keep the handle around so we can dlclose() it.
         */
        handle = fr_dlopenext(module_name);
@@ -444,16 +473,6 @@ static module_entry_t *linkto_module(const char *module_name,
                return NULL;
        }
 
-       /*
-        *      Link to the module's rlm_FOO{} module structure.
-        *
-        *      The module_name variable has the version number
-        *      embedded in it, and we don't want that here.
-        */
-       strcpy(module_struct, module_name);
-       p = strrchr(module_struct, '-');
-       if (p) *p = '\0';
-
        DEBUG3("    (Loaded %s, checking if it's valid)", module_name);
 
        /*
@@ -468,6 +487,10 @@ static module_entry_t *linkto_module(const char *module_name,
                lt_dlclose(handle);
                return NULL;
        }
+
+#if defined(WITHOUT_LIBLTDL) && defined (WITH_DLOPEN) && defined(RTLD_SELF)
+ open_self:
+#endif
        /*
         *      Before doing anything else, check if it's sane.
         */
@@ -576,7 +599,8 @@ module_instance_t *find_module_instance(CONF_SECTION *modules,
        } else {
        print_inst:
                check_config_safe = TRUE;
-               cf_log_module(cs, "Instantiating %s", instname);
+               cf_log_module(cs, "Instantiating module \"%s\" from file %s",
+                             instname, cf_section_filename(cs));
        }
 
        /*
@@ -710,13 +734,23 @@ int indexed_modcall(int comp, int idx, REQUEST *request)
                                section_type_value[comp].typename);
                }
        }
-
+       
+       if (server->subcs[comp]) {
+               if (idx == 0) {
+                       RDEBUG("# Executing section %s from file %s",
+                              section_type_value[comp].section,
+                              cf_section_filename(server->subcs[comp]));
+               } else {
+                       RDEBUG("# Executing group from file %s",
+                              cf_section_filename(server->subcs[comp]));
+               }
+       }
        request->component = section_type_value[comp].section;
 
        rcode = modcall(comp, list, request);
 
        request->module = "";
-       request->component = "";
+       request->component = "<core>";
        return rcode;
 }
 
@@ -948,9 +982,11 @@ static int load_byserver(CONF_SECTION *cs)
        indexed_modcallable *c;
 
        if (name) {
-               cf_log_info(cs, "server %s {", name);
+               cf_log_info(cs, "server %s { # from file %s",
+                           name, cf_section_filename(cs));
        } else {
-               cf_log_info(cs, "server {");
+               cf_log_info(cs, "server { # from file %s",
+                           cf_section_filename(cs));
        }
 
        cf_log_info(cs, " modules {");
@@ -1063,8 +1099,8 @@ static int load_byserver(CONF_SECTION *cs)
                 *      proxying.
                 */
                if (!mainconfig.proxy_requests &&
-                   ((comp == PW_PRE_PROXY_TYPE) ||
-                    (comp == PW_PRE_PROXY_TYPE))) {
+                   ((comp == RLM_COMPONENT_PRE_PROXY) ||
+                    (comp == RLM_COMPONENT_POST_PROXY))) {
                        continue;
                }
 #endif