config.c revision b31025f6f2c0392dc76eecca7f27faad0b902be0
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere/* ====================================================================
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * The Apache Software License, Version 1.1
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * Copyright (c) 2000 The Apache Software Foundation. All rights
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * reserved.
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * Redistribution and use in source and binary forms, with or without
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * modification, are permitted provided that the following conditions
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 1. Redistributions of source code must retain the above copyright
2e545ce2450a9953665f701bb05350f0d3f26275nd * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 2. Redistributions in binary form must reproduce the above copyright
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * notice, this list of conditions and the following disclaimer in
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * the documentation and/or other materials provided with the
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * distribution.
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * 3. The end-user documentation included with the redistribution,
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * if any, must include the following acknowledgment:
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * "This product includes software developed by the
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * Apache Software Foundation (http://www.apache.org/)."
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * Alternately, this acknowledgment may appear in the software itself,
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * if and wherever such third-party acknowledgments normally appear.
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * 4. The names "Apache" and "Apache Software Foundation" must
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * not be used to endorse or promote products derived from this
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * software without prior written permission. For written
fac8c35bfb158112226ab43ddf84d59daca5dc30nd * permission, please contact apache@apache.org.
d474d8ef01ec5c2a09341cd148851ed383c3287crbowen * 5. Products derived from this software may not be called "Apache",
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * nor may "Apache" appear in their name, without prior written
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * permission of the Apache Software Foundation.
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * SUCH DAMAGE.
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * ====================================================================
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * This software consists of voluntary contributions made by many
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * individuals on behalf of the Apache Software Foundation. For more
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * information on the Apache Software Foundation, please see
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * Portions of this software are based upon public domain software
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * originally written at the National Center for Supercomputing Applications,
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * University of Illinois, Urbana-Champaign.
fabd4bc0c499704e644a74f78cc3871436824ea0jim * http_config.c: once was auxillary functions for reading httpd's config
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * file and converting filenames into a namespace
bed3c2e56e8f3328e780200466b9d009093db468sf * Rob McCool
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * Wall-to-wall rewrite for Apache... commands which are part of the
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * server core can now be found next door in "http_core.c". Now contains
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * general command loop, and functions which do bookkeeping for the new
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * Apache config stuff (modules and configuration vectors).
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor#include "http_log.h" /* for errors in parse_htaccess */
fabd4bc0c499704e644a74f78cc3871436824ea0jim#include "http_request.h" /* for default_handler (see invoke_handler) */
999942e8e84bcae9b439ab30a040b1b997b343c9gryzorAP_DECLARE_DATA apr_array_header_t *ap_server_pre_read_config;
999942e8e84bcae9b439ab30a040b1b997b343c9gryzorAP_DECLARE_DATA apr_array_header_t *ap_server_post_read_config;
999942e8e84bcae9b439ab30a040b1b997b343c9gryzorAP_DECLARE_DATA apr_array_header_t *ap_server_config_defines;
173e5f4d5ec46b5febb74ce860d753bb1faaba0fsf (apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp),
999942e8e84bcae9b439ab30a040b1b997b343c9gryzorAP_IMPLEMENT_HOOK_RUN_FIRST(int,handler,(request_rec *r),
999942e8e84bcae9b439ab30a040b1b997b343c9gryzorAP_IMPLEMENT_HOOK_VOID(optional_fn_retrieve,(void),())
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor/****************************************************************
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * We begin with the functions which deal with the linked list
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * of modules which control just about all of the server operation.
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere/* total_modules is the number of modules that have been linked
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * into the server.
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclerestatic int total_modules = 0;
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere/* dynamic_modules is the number of modules that have been added
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * after the pre-loaded ones have been set up. It shouldn't be larger
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * than DYNAMIC_MODULE_LIMIT.
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclerestatic int dynamic_modules = 0;
999942e8e84bcae9b439ab30a040b1b997b343c9gryzortypedef void *(*dir_maker_func) (apr_pool_t *, char *);
999942e8e84bcae9b439ab30a040b1b997b343c9gryzortypedef void *(*merger_func) (apr_pool_t *, void *, void *);
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor/* Dealing with config vectors. These are associated with per-directory,
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * per-server, and per-request configuration, and have a void* pointer for
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * each modules. The nature of the structure pointed to is private to the
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere * module in question... the core doesn't (and can't) know. However, there
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * are defined interfaces which allow it to create instances of its private
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * per-directory and per-server structures, and to merge the per-directory
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * structures of a directory and its subdirectory (producing a new one in
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * which the defaults applying to the base directory have been properly
999942e8e84bcae9b439ab30a040b1b997b343c9gryzor * overridden).
999942e8e84bcae9b439ab30a040b1b997b343c9gryzorAP_DECLARE(void *) ap_get_module_config(void *conf_vector, module *m)
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclereAP_DECLARE(void) ap_set_module_config(void *conf_vector, module *m, void *val)
0d0ba3a410038e179b695446bb149cce6264e0abnd void **conf_vector = (void **) apr_pcalloc(p, sizeof(void *) *
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh return (void *) conf_vector;
727872d18412fc021f03969b8641810d8896820bhumbedoohstatic void *create_default_per_dir_config(apr_pool_t *p)
0d0ba3a410038e179b695446bb149cce6264e0abnd void **conf_vector = (void **) apr_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
07dc96d063d49299da433f84b5c5681da9bbdf68rbowen return (void *) conf_vector;
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd ap_merge_per_dir_configs(apr_pool_t *p, void *base, void *new)
e3659090e9bb9934465dbb6c6212ba4c512190b0jfclere void **conf_vector = (void **) apr_palloc(p, sizeof(void *) * total_modules);
return (void *) conf_vector;
void **conf_vector = (void **) apr_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);
const char *handler;
char *p2;
int result;
if (!r->handler) {
int methnum;
char **xmethod;
if(m->register_hooks)
m->register_hooks(p);
/* 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
ap_register_hooks(m, p);
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++;
return m->name;
return modp;
return NULL;
const char *errmsg;
case RAW_ARGS:
#ifdef RESOLVE_ENV_PER_TOKEN
case NO_ARGS:
if (*args != 0)
NULL);
case TAKE1:
case TAKE2:
case TAKE12:
case TAKE3:
case TAKE23:
case TAKE123:
case TAKE13:
case ITERATE:
return errmsg;
return NULL;
case ITERATE2:
return errmsg;
return NULL;
case FLAG:
NULL);
NULL);
return cmds;
++cmds;
return NULL;
return cmdp;
return NULL;
return mconfig;
const char *args;
char *cmd_name;
return NULL;
args = l;
return NULL;
const char *retval;
if (*current) {
if (*curr_parent) {
if (*current) {
if (*current) {
if (!*conftree) {
return retval;
return NULL;
char *orig_directive)
char l[MAX_STRING_LEN];
char *bracket;
const char *retval;
return retval;
return NULL;
NULL);
const char *retval;
return NULL;
return retval;
const char *errmsg;
return errmsg;
return NULL;
char l[MAX_STRING_LEN];
const char *errmsg;
return errmsg;
return errmsg;
return NULL;
void *struct_ptr,
const char *arg)
return NULL;
void *struct_ptr,
const char *arg_)
return NULL;
return NULL;
const char *arg)
#ifndef OS2
return NULL;
#ifndef OS2
return file;
char l[MAX_STRING_LEN];
const char *args;
char *cmd_name;
args = l;
return NULL;
NULL);
int curr_idx;
return NULL;
return buf;
const char *errmsg;
if (errmsg) {
errmsg);
char *fname;
} fnames;
const char *errmsg;
/* don't require conf/httpd.conf if we have a -C or -c switch */
int current;
const char *errmsg;
if (errmsg) {
const char *d, const char *access_name) {
return OK;
while (access_name[0]) {
const char *errmsg;
ap_cfg_closefile(f);
if (errmsg) {
return HTTP_INTERNAL_SERVER_ERROR;
filename);
return HTTP_FORBIDDEN;
return OK;
s->timeout = 0;
s->keep_alive_timeout = 0;
*ps = s;
s->port = 0;
const char *confname,
p, ptemp);
p, ptemp);
module *m)
if (m->create_server_config)
(*m->create_server_config)(p, s));
if (m->create_dir_config)
module *m;
if (m->rewrite_args)
AP_DECLARE(void) ap_post_config_hook(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
for (n = 0; ap_loaded_modules[n]; ++n)
for (n = 0; ap_loaded_modules[n]; ++n)