]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Trigger an error when a LoadModule directive attempts to
authorGeoffrey Young <geoff@apache.org>
Wed, 8 Sep 2004 13:35:12 +0000 (13:35 +0000)
committerGeoffrey Young <geoff@apache.org>
Wed, 8 Sep 2004 13:35:12 +0000 (13:35 +0000)
load a module which is built-in.  This is a common error when
switching from a DSO build to a static build.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@105036 13f79535-47bb-0310-9956-ffa450edef68

src/CHANGES
src/modules/standard/mod_so.c

index 16bdde724bce4902c0b4860e19779ec67c0b5762..bf98def04768ac18e6685e238703b210c8b45201 100644 (file)
@@ -1,5 +1,10 @@
 Changes with Apache 1.3.32
 
+  *) Trigger an error when a LoadModule directive attempts to
+     load a module which is built-in.  This is a common error when
+     switching from a DSO build to a static build.
+     [Jeff Trawick, Geoffrey Young]
+
   *) Fix trivial bug in mod_log_forensic that caused the child
      to seg fault when certain invalid requests were fired at it with
      forensic logging is enabled.  PR 29313.
index 6f7756f21d444d8aacfe91da3a923e6032845797..eb143e3acc34d068470fa4bc45b659167edd6f4c 100644 (file)
@@ -182,6 +182,7 @@ static const char *load_module(cmd_parms *cmd, void *dummy,
     /* 
      * 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 @@ static const char *load_module(cmd_parms *cmd, void *dummy,
             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;