config.c revision 2d71630471d1c23f0137309e3c3957c633ecbfd6
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin/* ====================================================================
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Redistribution and use in source and binary forms, with or without
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * modification, are permitted provided that the following conditions
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * 1. Redistributions of source code must retain the above copyright
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * notice, this list of conditions and the following disclaimer.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * 2. Redistributions in binary form must reproduce the above copyright
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * notice, this list of conditions and the following disclaimer in
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * the documentation and/or other materials provided with the
2e545ce2450a9953665f701bb05350f0d3f26275nd * distribution.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 3. All advertising materials mentioning features or use of this
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * software must display the following acknowledgment:
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * "This product includes software developed by the Apache Group
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * for use in the Apache HTTP server project (http://www.apache.org/)."
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * 4. The names "Apache Server" and "Apache Group" must not be used to
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * endorse or promote products derived from this software without
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * prior written permission. For written permission, please contact
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * apache@apache.org.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * 5. Products derived from this software may not be called "Apache"
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * nor may "Apache" appear in their names without prior written
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * permission of the Apache Group.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * 6. Redistributions of any form whatsoever must retain the following
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * acknowledgment:
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * "This product includes software developed by the Apache Group
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * for use in the Apache HTTP server project (http://www.apache.org/)."
46f74e65e6051e6e9391c8e17c5116317210facetakashi * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * OF THE POSSIBILITY OF SUCH DAMAGE.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * ====================================================================
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * This software consists of voluntary contributions made by many
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * individuals on behalf of the Apache Group and was originally based
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * on public domain software written at the National Center for
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * Supercomputing Applications, University of Illinois, Urbana-Champaign.
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * For more information on the Apache Group and the Apache HTTP server
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * project, please see <http://www.apache.org/>.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * http_config.c: once was auxillary functions for reading httpd's config
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * file and converting filenames into a namespace
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri * Rob McCool
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri * Wall-to-wall rewrite for Apache... commands which are part of the
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri * server core can now be found next door in "http_core.c". Now contains
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * general command loop, and functions which do bookkeeping for the new
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * Apache config stuff (modules and configuration vectors).
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar#include "http_log.h" /* for errors in parse_htaccess */
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar#include "http_request.h" /* for default_handler (see invoke_handler) */
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarIMPLEMENT_HOOK_RUN_ALL(int,header_parser,(request_rec *r),(r),OK,DECLINED)
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarIMPLEMENT_HOOK_VOID(pre_config,(ap_context_t *pconf,ap_context_t *plog,ap_context_t *ptemp),
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin (ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s),
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin (ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s),
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrinIMPLEMENT_HOOK_VOID(child_init,(ap_context_t *pchild, server_rec *s),(pchild,s))
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin/****************************************************************
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * We begin with the functions which deal with the linked list
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * of modules which control just about all of the server operation.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin/* total_modules is the number of modules that have been linked
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * into the server.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrinstatic int total_modules = 0;
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf/* dynamic_modules is the number of modules that have been added
4aa603e6448b99f9371397d439795c91a93637eand * after the pre-loaded ones have been set up. It shouldn't be larger
4aa603e6448b99f9371397d439795c91a93637eand * than DYNAMIC_MODULE_LIMIT.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrinstatic int dynamic_modules = 0;
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrintypedef void *(*dir_maker_func) (ap_context_t *, char *);
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrintypedef void *(*merger_func) (ap_context_t *, void *, void *);
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin/* Dealing with config vectors. These are associated with per-directory,
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl * per-server, and per-request configuration, and have a void* pointer for
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * each modules. The nature of the structure pointed to is private to the
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * module in question... the core doesn't (and can't) know. However, there
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * are defined interfaces which allow it to create instances of its private
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * per-directory and per-server structures, and to merge the per-directory
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * structures of a directory and its subdirectory (producing a new one in
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * which the defaults applying to the base directory have been properly
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin * overridden).
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrinAPI_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m)
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrinAPI_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val)
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) *
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin return (void *) conf_vector;
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrinstatic void *create_default_per_dir_config(ap_context_t *p)
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
727872d18412fc021f03969b8641810d8896820bhumbedooh return (void *) conf_vector;
727872d18412fc021f03969b8641810d8896820bhumbedooh ap_merge_per_dir_configs(ap_context_t *p, void *base, void *new)
0d0ba3a410038e179b695446bb149cce6264e0abnd void **conf_vector = (void **) ap_palloc(p, sizeof(void *) * total_modules);
205f749042ed530040a4f0080dbcb47ceae8a374rjung conf_vector[i] = (*df) (p, base_vector[i], new_vector[i]);
0d0ba3a410038e179b695446bb149cce6264e0abnd conf_vector[i] = new_vector[i] ? new_vector[i] : base_vector[i];
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd return (void *) conf_vector;
void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
return (void *) conf_vector;
if (!virt_vector[i])
else if (df)
return create_empty_config(p);
return create_empty_config(p);
return create_empty_config(p);
* For speed/efficiency we generate a compact list of all the handlers
int nhandlers = 0;
int nwildhandlers = 0;
char *starp;
nwildhandlers ++;
nhandlers ++;
pw ++;
ph ++;
const char *handler;
if (r->handler) {
return result;
return result;
return HTTP_INTERNAL_SERVER_ERROR;
int g_bDebugHooks;
const char *g_szCurrentHookName;
if(m->register_hooks)
m->register_hooks();
/* This could be called from an AddModule httpd.conf command,
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Please contact the vendor for the correct version.");
top_module = m;
* only the filename (e.g. mod_includes.c). So check for path
register_hooks(m);
if (modp == m) {
if (!modp) {
m->name);
module **m;
*m++ = mod;
*m = NULL;
module **m;
int done;
*m++ = *m2;
*m = NULL;
module **m;
total_modules = 0;
*m2++ = *m++;
ap_add_module(*m);
return m->name;
return modp;
return NULL;
*m = NULL;
m = next_m;
const char *errmsg;
case RAW_ARGS:
return ((const char *(*)(cmd_parms *, void *, const char *))
case NO_ARGS:
if (*args != 0)
NULL);
return ((const char *(*)(cmd_parms *, void *))
case TAKE1:
return ((const char *(*)(cmd_parms *, void *, const char *))
case TAKE2:
return ((const char *(*)(cmd_parms *, void *, const char *,
case TAKE12:
return ((const char *(*)(cmd_parms *, void *, const char *,
case TAKE3:
return ((const char *(*)(cmd_parms *, void *, const char *,
case TAKE23:
return ((const char *(*)(cmd_parms *, void *, const char *,
case TAKE123:
return ((const char *(*)(cmd_parms *, void *, const char *,
case TAKE13:
return ((const char *(*)(cmd_parms *, void *, const char *,
case ITERATE:
return errmsg;
return NULL;
case ITERATE2:
return errmsg;
return NULL;
case FLAG:
NULL);
return ((const char *(*)(cmd_parms *, void *, int))
NULL);
return cmds;
++cmds;
return NULL;
return cmdp;
return NULL;
return mconfig;
void *oldconfig;
return NULL;
args = l;
return NULL;
return retval;
char l[MAX_STRING_LEN];
if (errmsg) {
return errmsg;
return NULL;
return NULL;
return NULL;
return NULL;
p = arg;
return NULL;
return file;
int curr_idx;
return NULL;
return buf;
const char *errmsg;
if (errmsg) {
void ap_process_resource_config(server_rec *s, const char *fname, ap_context_t *p, ap_context_t *ptemp)
const char *errmsg;
/* don't require conf/httpd.conf if we have a -C or -c switch */
if (errmsg) {
const char *d, const char *access_name)
const char *errmsg;
return OK;
while (access_name[0]) {
ap_cfg_closefile(f);
if (errmsg) {
return HTTP_INTERNAL_SERVER_ERROR;
filename);
return HTTP_FORBIDDEN;
return OK;
#ifdef RLIMIT_NOFILE
s->timeout = 0;
s->keep_alive_timeout = 0;
*ps = s;
s->port = 0;
fixup_virtual_hosts(p, s);
ap_fini_vhost_config(p, s);
if (m->create_server_config)
(*m->create_server_config)(p, s));
if (m->create_dir_config)
void ap_post_config_hook(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s)
void ap_show_directives()
for (n = 0; ap_loaded_modules[n]; ++n)
void ap_show_modules()
for (n = 0; ap_loaded_modules[n]; ++n)