From 069783b1d37e6094694eb4676f776f0790a28974 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Fri, 19 Apr 2002 18:31:20 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94719 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ modules/mappers/mod_so.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/CHANGES b/CHANGES index 02728c26f2..570b88d158 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ Changes with Apache 2.0.36 + *) 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] + *) Change instdso.sh to use libtool --install everywhere and then clean up some stray files and symlinks that libtool leaves around on some platforms. This gets subversion building properly since diff --git a/modules/mappers/mod_so.c b/modules/mappers/mod_so.c index be2caf0cd0..1c32829203 100644 --- a/modules/mappers/mod_so.c +++ b/modules/mappers/mod_so.c @@ -220,6 +220,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); @@ -233,6 +234,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; + apr_size_t preload_len; + apr_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 apr_pstrcat(cmd->pool, "module ", modname, + " is built-in and can't be loaded", + NULL); + } + } + modi = apr_array_push(sconf->loaded_modules); modi->name = modname; -- 2.40.0