From: Jeff Trawick Date: Fri, 19 Apr 2002 18:31:20 +0000 (+0000) Subject: Trigger an error when a LoadModule directive attempts to X-Git-Tag: 2.0.36~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e90e977d153177c4739f5b043afcf631f6deee16;p=thirdparty%2Fapache%2Fhttpd.git 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 --- diff --git a/CHANGES b/CHANGES index 02728c26f22..570b88d158d 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 be2caf0cd0c..1c328292036 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;