config.c revision b6055b7832a0e4d0818416252fff5925aaebae4b
d5082de325fb6351c6bd34d28df0b43ec5a8ac90erikabele/* ====================================================================
d5082de325fb6351c6bd34d28df0b43ec5a8ac90erikabele * The Apache Software License, Version 1.1
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Copyright (c) 2000 The Apache Software Foundation. All rights
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * reserved.
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * Redistribution and use in source and binary forms, with or without
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * modification, are permitted provided that the following conditions
5a58787efeb02a1c3f06569d019ad81fd2efa06end * are met:
5a58787efeb02a1c3f06569d019ad81fd2efa06end * 1. Redistributions of source code must retain the above copyright
5a58787efeb02a1c3f06569d019ad81fd2efa06end * notice, this list of conditions and the following disclaimer.
2e545ce2450a9953665f701bb05350f0d3f26275nd * 2. Redistributions in binary form must reproduce the above copyright
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * notice, this list of conditions and the following disclaimer in
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * the documentation and/or other materials provided with the
5a58787efeb02a1c3f06569d019ad81fd2efa06end * distribution.
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * 3. The end-user documentation included with the redistribution,
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * if any, must include the following acknowledgment:
5a58787efeb02a1c3f06569d019ad81fd2efa06end * "This product includes software developed by the
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Apache Software Foundation (http://www.apache.org/)."
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Alternately, this acknowledgment may appear in the software itself,
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * if and wherever such third-party acknowledgments normally appear.
a0e183666b44ebb43fdfeffe78d36c6134a59d4dyoshiki * 4. The names "Apache" and "Apache Software Foundation" must
9124bd631acffcf0a44789785377735f172b4b7fgryzor * not be used to endorse or promote products derived from this
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd * software without prior written permission. For written
52ea316008e2581c8113441c9c341e5c65225f6anilgun * permission, please contact apache@apache.org.
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd * 5. Products derived from this software may not be called "Apache",
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd * nor may "Apache" appear in their name, without prior written
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * permission of the Apache Software Foundation.
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
d5082de325fb6351c6bd34d28df0b43ec5a8ac90erikabele * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1ef822109accf82b8861e22d92fea722f57ae537nd * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
1ef822109accf82b8861e22d92fea722f57ae537nd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1ef822109accf82b8861e22d92fea722f57ae537nd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
5ae30adbe59946de742ab0cd6be3b7457471a698takashi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
1ef822109accf82b8861e22d92fea722f57ae537nd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
d0d5f51413c1693ffbc910e54253a243889ee571lgentis * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1ef822109accf82b8861e22d92fea722f57ae537nd * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1ef822109accf82b8861e22d92fea722f57ae537nd * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5a58787efeb02a1c3f06569d019ad81fd2efa06end * SUCH DAMAGE.
5a58787efeb02a1c3f06569d019ad81fd2efa06end * ====================================================================
f61ec47ec494705bd2d02b5b6fe021e5c193f2c8noodl * This software consists of voluntary contributions made by many
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * individuals on behalf of the Apache Software Foundation. For more
5a58787efeb02a1c3f06569d019ad81fd2efa06end * information on the Apache Software Foundation, please see
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh * Portions of this software are based upon public domain software
5a58787efeb02a1c3f06569d019ad81fd2efa06end * originally written at the National Center for Supercomputing Applications,
5a58787efeb02a1c3f06569d019ad81fd2efa06end * University of Illinois, Urbana-Champaign.
5a58787efeb02a1c3f06569d019ad81fd2efa06end * http_config.c: once was auxillary functions for reading httpd's config
5a58787efeb02a1c3f06569d019ad81fd2efa06end * file and converting filenames into a namespace
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * Rob McCool
d5082de325fb6351c6bd34d28df0b43ec5a8ac90erikabele * Wall-to-wall rewrite for Apache... commands which are part of the
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * server core can now be found next door in "http_core.c". Now contains
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * general command loop, and functions which do bookkeeping for the new
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * Apache config stuff (modules and configuration vectors).
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen#include "http_log.h" /* for errors in parse_htaccess */
15292da5451dea4ad10c12d35d9addc88be302c5humbedooh#include "http_request.h" /* for default_handler (see invoke_handler) */
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowenAPI_VAR_EXPORT ap_array_header_t *ap_server_pre_read_config;
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowenAPI_VAR_EXPORT ap_array_header_t *ap_server_post_read_config;
f61ec47ec494705bd2d02b5b6fe021e5c193f2c8noodlAPI_VAR_EXPORT ap_array_header_t *ap_server_config_defines;
f61ec47ec494705bd2d02b5b6fe021e5c193f2c8noodl (ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp),
419d55842022e9e257941bfe226549661fb2c6c7humbedooh (ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp,
5a58787efeb02a1c3f06569d019ad81fd2efa06end/****************************************************************
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * We begin with the functions which deal with the linked list
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * of modules which control just about all of the server operation.
9fc1345bb54ea7f68c2e59ff3a618c1237a30918yoshiki/* total_modules is the number of modules that have been linked
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * into the server.
15292da5451dea4ad10c12d35d9addc88be302c5humbedoohstatic int total_modules = 0;
419d55842022e9e257941bfe226549661fb2c6c7humbedooh/* dynamic_modules is the number of modules that have been added
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * after the pre-loaded ones have been set up. It shouldn't be larger
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * than DYNAMIC_MODULE_LIMIT.
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowenstatic int dynamic_modules = 0;
419d55842022e9e257941bfe226549661fb2c6c7humbedoohtypedef void *(*dir_maker_func) (ap_pool_t *, char *);
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowentypedef void *(*merger_func) (ap_pool_t *, void *, void *);
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen/* Dealing with config vectors. These are associated with per-directory,
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * per-server, and per-request configuration, and have a void* pointer for
5a58787efeb02a1c3f06569d019ad81fd2efa06end * each modules. The nature of the structure pointed to is private to the
5a58787efeb02a1c3f06569d019ad81fd2efa06end * module in question... the core doesn't (and can't) know. However, there
5a58787efeb02a1c3f06569d019ad81fd2efa06end * are defined interfaces which allow it to create instances of its private
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * per-directory and per-server structures, and to merge the per-directory
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * structures of a directory and its subdirectory (producing a new one in
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen * which the defaults applying to the base directory have been properly
255ed74976dd24871155a672050d5c61ee2c3a92slive * overridden).
1f1b6bf13313fdd14a45e52e553d3ff28689b717coarAPI_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m)
570774ea3ec6ce8795d6db447049c9393266b660rbowenAPI_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val)
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) *
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen return (void *) conf_vector;
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowenstatic void *create_default_per_dir_config(ap_pool_t *p)
47bbfaa3a2ea0afb775a3aa3e7dbf8a71ea1b966rbowen void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
0d0ba3a410038e179b695446bb149cce6264e0abnd return (void *) conf_vector;
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh ap_merge_per_dir_configs(ap_pool_t *p, void *base, void *new)
0d0ba3a410038e179b695446bb149cce6264e0abnd void **conf_vector = (void **) ap_palloc(p, sizeof(void *) * total_modules);
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh conf_vector[i] = (*df) (p, base_vector[i], new_vector[i]);
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen 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;
const char *starp;
nwildhandlers ++;
nhandlers ++;
pw ++;
ph ++;
const char *handler;
if (r->handler) {
return result;
return result;
return HTTP_INTERNAL_SERVER_ERROR;
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
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:
#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) {
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)
return NULL;
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) {
const char *errmsg;
/* don't require conf/httpd.conf if we have a -C or -c switch */
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);
if (m->create_server_config)
(*m->create_server_config)(p, s));
if (m->create_dir_config)
module *m;
if (m->rewrite_args)
API_EXPORT(void) ap_post_config_hook(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp, server_rec *s)
for (n = 0; ap_loaded_modules[n]; ++n)
for (n = 0; ap_loaded_modules[n]; ++n)