Geoffrey Young wrote:
>>>That sounds like a job for Apache to do. Apache knows what modules are
>>>compiled in, so it can check that list before trying to LoadModule.
>>>You may want to suggest that to the Apache developers. Most likely any
>>>Apache module suffers from this problem.

ok, as it turns out this logic is already part of 2.0, but it was never
backported to 1.3.

attached is a patch that I've submitted to httpd-dev, which is simply a pure
backport of the existing logic in 2.0.  feel free to give it a whirl.

--Geoff
Index: src/modules/standard/mod_so.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_so.c,v
retrieving revision 1.42
diff -u -r1.42 mod_so.c
--- src/modules/standard/mod_so.c	20 Feb 2004 20:38:27 -0000	1.42
+++ src/modules/standard/mod_so.c	7 Sep 2004 13:57:18 -0000
@@ -182,6 +182,7 @@
     /* 
      * check for already existing module
      * If it already exists, we have nothing to do 
+     * Check both dynamically-loaded modules and statically-linked modules.
      */
     sconf = (so_server_conf *)ap_get_module_config(cmd->server->module_config, 
 	                                        &so_module);
@@ -194,6 +195,45 @@
             return NULL;
         }
     }
+
+    for (i = 0; ap_preloaded_modules[i]; i++) {
+        const char *preload_name;
+        size_t preload_len;
+        size_t thismod_len;
+
+        modp = ap_preloaded_modules[i];
+
+        /* make sure we're comparing apples with apples
+         * make sure name of preloaded module is mod_FOO.c
+         * make sure name of structure being loaded is FOO_module
+         */
+
+        if (memcmp(modp->name, "mod_", 4)) {
+            continue;
+        }
+
+        preload_name = modp->name + strlen("mod_");
+        preload_len = strlen(preload_name) - 2;
+
+        if (strlen(modname) <= strlen("_module")) {
+            continue;
+        }
+        thismod_len = strlen(modname) - strlen("_module");
+        if (strcmp(modname + thismod_len, "_module")) {
+            continue;
+        }
+
+        if (thismod_len != preload_len) {
+            continue;
+        }
+
+        if (!memcmp(modname, preload_name, preload_len)) {
+            return ap_pstrcat(cmd->pool, "module ", modname,
+                              " is built-in and can't be loaded",
+                              NULL);
+        }
+    }
+
     modi = ap_push_array(sconf->loaded_modules);
     modi->name = modname;
 

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to