config.c revision 23923c878b8e2ade4ca9cb67d240fc744661a7a3
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein/* ====================================================================
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Copyright (c) 1995-2000 The Apache Software Foundation. All rights reserved.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Redistribution and use in source and binary forms, with or without
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * modification, are permitted provided that the following conditions
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * are met:
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 1. Redistributions of source code must retain the above copyright
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * notice, this list of conditions and the following disclaimer.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 2. Redistributions in binary form must reproduce the above copyright
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * notice, this list of conditions and the following disclaimer in
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * the documentation and/or other materials provided with the
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * distribution.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 3. All advertising materials mentioning features or use of this
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * software must display the following acknowledgment:
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * "This product includes software developed by the Apache Software Foundation
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * for use in the Apache HTTP server project (http://www.apache.org/)."
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 4. The names "Apache Server" and "Apache Software Foundation" must not be used to
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * endorse or promote products derived from this software without
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * prior written permission. For written permission, please contact
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * apache@apache.org.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 5. Products derived from this software may not be called "Apache"
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * nor may "Apache" appear in their names without prior written
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * permission of the Apache Software Foundation.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * 6. Redistributions of any form whatsoever must retain the following
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * acknowledgment:
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * "This product includes software developed by the Apache Software Foundation
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * for use in the Apache HTTP server project (http://www.apache.org/)."
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * THIS SOFTWARE IS PROVIDED BY THE Apache Software Foundation ``AS IS'' AND ANY
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE Apache Software Foundation OR
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * OF THE POSSIBILITY OF SUCH DAMAGE.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * ====================================================================
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * This software consists of voluntary contributions made by many
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * individuals on behalf of the Apache Software Foundation and was originally based
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * on public domain software written at the National Center for
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * Supercomputing Applications, University of Illinois, Urbana-Champaign.
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein * For more information on the Apache Software Foundation and the Apache HTTP server
f4c310fd2555c6faca1f980f00b161eadb089023gstein * project, please see <http://www.apache.org/>.
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein */
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/*
f4c310fd2555c6faca1f980f00b161eadb089023gstein * http_config.c: once was auxillary functions for reading httpd's config
f4c310fd2555c6faca1f980f00b161eadb089023gstein * file and converting filenames into a namespace
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Rob McCool
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Wall-to-wall rewrite for Apache... commands which are part of the
f4c310fd2555c6faca1f980f00b161eadb089023gstein * server core can now be found next door in "http_core.c". Now contains
f4c310fd2555c6faca1f980f00b161eadb089023gstein * general command loop, and functions which do bookkeeping for the new
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Apache config stuff (modules and configuration vectors).
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein * rst
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein#define CORE_PRIVATE
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "ap_config.h"
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "apr_portable.h"
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "apr_file_io.h"
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "httpd.h"
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "http_config.h"
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "http_core.h"
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "http_log.h" /* for errors in parse_htaccess */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "http_request.h" /* for default_handler (see invoke_handler) */
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "http_main.h"
f4c310fd2555c6faca1f980f00b161eadb089023gstein#include "http_vhost.h"
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinHOOK_STRUCT(
f4c310fd2555c6faca1f980f00b161eadb089023gstein HOOK_LINK(header_parser)
f4c310fd2555c6faca1f980f00b161eadb089023gstein HOOK_LINK(pre_config)
f4c310fd2555c6faca1f980f00b161eadb089023gstein HOOK_LINK(post_config)
f4c310fd2555c6faca1f980f00b161eadb089023gstein HOOK_LINK(open_logs)
8a46775d163c06a8c51d1b0a3f2edfde945cb1d8stoddard HOOK_LINK(child_init)
f4c310fd2555c6faca1f980f00b161eadb089023gstein)
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinIMPLEMENT_HOOK_RUN_ALL(int,header_parser,(request_rec *r),(r),OK,DECLINED)
f4c310fd2555c6faca1f980f00b161eadb089023gsteinIMPLEMENT_HOOK_VOID(pre_config,(ap_context_t *pconf,ap_context_t *plog,ap_context_t *ptemp),
000397350b42c6266351bd618fa07df929fa7c79gstein (pconf,plog,ptemp))
000397350b42c6266351bd618fa07df929fa7c79gsteinIMPLEMENT_HOOK_VOID(post_config,
000397350b42c6266351bd618fa07df929fa7c79gstein (ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s),
f4c310fd2555c6faca1f980f00b161eadb089023gstein (pconf,plog,ptemp,s))
f4c310fd2555c6faca1f980f00b161eadb089023gsteinIMPLEMENT_HOOK_VOID(open_logs,
f4c310fd2555c6faca1f980f00b161eadb089023gstein (ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s),
f4c310fd2555c6faca1f980f00b161eadb089023gstein (pconf,plog,ptemp,s))
f4c310fd2555c6faca1f980f00b161eadb089023gsteinIMPLEMENT_HOOK_VOID(child_init,(ap_context_t *pchild, server_rec *s),(pchild,s))
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/****************************************************************
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
9f18c80269be35c0b5653e84b0db0a24044722c4gstein * We begin with the functions which deal with the linked list
9f18c80269be35c0b5653e84b0db0a24044722c4gstein * of modules which control just about all of the server operation.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* total_modules is the number of modules that have been linked
f4c310fd2555c6faca1f980f00b161eadb089023gstein * into the server.
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int total_modules = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* dynamic_modules is the number of modules that have been added
f4c310fd2555c6faca1f980f00b161eadb089023gstein * after the pre-loaded ones have been set up. It shouldn't be larger
f4c310fd2555c6faca1f980f00b161eadb089023gstein * than DYNAMIC_MODULE_LIMIT.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
b47464a901075041e800be2de098a603923fa4f9gsteinstatic int dynamic_modules = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_VAR_EXPORT module *top_module = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_VAR_EXPORT module **ap_loaded_modules=NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteintypedef int (*handler_func) (request_rec *);
f4c310fd2555c6faca1f980f00b161eadb089023gsteintypedef void *(*dir_maker_func) (ap_context_t *, char *);
f4c310fd2555c6faca1f980f00b161eadb089023gsteintypedef void *(*merger_func) (ap_context_t *, void *, void *);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Dealing with config vectors. These are associated with per-directory,
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe * per-server, and per-request configuration, and have a void* pointer for
f4c310fd2555c6faca1f980f00b161eadb089023gstein * each modules. The nature of the structure pointed to is private to the
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * module in question... the core doesn't (and can't) know. However, there
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein * are defined interfaces which allow it to create instances of its private
f4c310fd2555c6faca1f980f00b161eadb089023gstein * per-directory and per-server structures, and to merge the per-directory
f4c310fd2555c6faca1f980f00b161eadb089023gstein * structures of a directory and its subdirectory (producing a new one in
f4c310fd2555c6faca1f980f00b161eadb089023gstein * which the defaults applying to the base directory have been properly
9f18c80269be35c0b5653e84b0db0a24044722c4gstein * overridden).
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm#ifndef ap_get_module_config
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein void **confv = (void **) conf_vector;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm return confv[m->module_index];
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
b47464a901075041e800be2de098a603923fa4f9gstein#endif
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein#ifndef ap_set_module_config
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm void **confv = (void **) conf_vector;
f4c310fd2555c6faca1f980f00b161eadb089023gstein confv[m->module_index] = val;
b47464a901075041e800be2de098a603923fa4f9gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif
b47464a901075041e800be2de098a603923fa4f9gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void *create_empty_config(ap_context_t *p)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) *
f4c310fd2555c6faca1f980f00b161eadb089023gstein (total_modules + DYNAMIC_MODULE_LIMIT));
b47464a901075041e800be2de098a603923fa4f9gstein return (void *) conf_vector;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void *create_default_per_dir_config(ap_context_t *p)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
f4c310fd2555c6faca1f980f00b161eadb089023gstein module *modp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (modp = top_module; modp; modp = modp->next) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein dir_maker_func df = modp->create_dir_config;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if (df)
de18a9e85398b9c79c422f578633ed56c2747bbbgstein conf_vector[modp->module_index] = (*df) (p, NULL);
de18a9e85398b9c79c422f578633ed56c2747bbbgstein }
de18a9e85398b9c79c422f578633ed56c2747bbbgstein
de18a9e85398b9c79c422f578633ed56c2747bbbgstein return (void *) conf_vector;
de18a9e85398b9c79c422f578633ed56c2747bbbgstein}
de18a9e85398b9c79c422f578633ed56c2747bbbgstein
de18a9e85398b9c79c422f578633ed56c2747bbbgsteinvoid *
de18a9e85398b9c79c422f578633ed56c2747bbbgstein ap_merge_per_dir_configs(ap_context_t *p, void *base, void *new)
de18a9e85398b9c79c422f578633ed56c2747bbbgstein{
de18a9e85398b9c79c422f578633ed56c2747bbbgstein void **conf_vector = (void **) ap_palloc(p, sizeof(void *) * total_modules);
de18a9e85398b9c79c422f578633ed56c2747bbbgstein void **base_vector = (void **) base;
de18a9e85398b9c79c422f578633ed56c2747bbbgstein void **new_vector = (void **) new;
de18a9e85398b9c79c422f578633ed56c2747bbbgstein module *modp;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (modp = top_module; modp; modp = modp->next) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein merger_func df = modp->merge_dir_config;
f4c310fd2555c6faca1f980f00b161eadb089023gstein int i = modp->module_index;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if (df && new_vector[i])
f4c310fd2555c6faca1f980f00b161eadb089023gstein conf_vector[i] = (*df) (p, base_vector[i], new_vector[i]);
f4c310fd2555c6faca1f980f00b161eadb089023gstein else
f4c310fd2555c6faca1f980f00b161eadb089023gstein conf_vector[i] = new_vector[i] ? new_vector[i] : base_vector[i];
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return (void *) conf_vector;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
de18a9e85398b9c79c422f578633ed56c2747bbbgsteinstatic void *create_server_config(ap_context_t *p, server_rec *s)
de18a9e85398b9c79c422f578633ed56c2747bbbgstein{
9f18c80269be35c0b5653e84b0db0a24044722c4gstein void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
9f18c80269be35c0b5653e84b0db0a24044722c4gstein module *modp;
000397350b42c6266351bd618fa07df929fa7c79gstein
000397350b42c6266351bd618fa07df929fa7c79gstein for (modp = top_module; modp; modp = modp->next) {
000397350b42c6266351bd618fa07df929fa7c79gstein if (modp->create_server_config)
000397350b42c6266351bd618fa07df929fa7c79gstein conf_vector[modp->module_index] = (*modp->create_server_config) (p, s);
9f18c80269be35c0b5653e84b0db0a24044722c4gstein }
9f18c80269be35c0b5653e84b0db0a24044722c4gstein
000397350b42c6266351bd618fa07df929fa7c79gstein return (void *) conf_vector;
000397350b42c6266351bd618fa07df929fa7c79gstein}
000397350b42c6266351bd618fa07df929fa7c79gstein
000397350b42c6266351bd618fa07df929fa7c79gsteinstatic void merge_server_configs(ap_context_t *p, void *base, void *virt)
000397350b42c6266351bd618fa07df929fa7c79gstein{
000397350b42c6266351bd618fa07df929fa7c79gstein /* Can reuse the 'virt' vector for the spine of it, since we don't
f4c310fd2555c6faca1f980f00b161eadb089023gstein * have to deal with the moral equivalent of .htaccess files here...
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein void **base_vector = (void **) base;
f4c310fd2555c6faca1f980f00b161eadb089023gstein void **virt_vector = (void **) virt;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm module *modp;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
10a4cdd68ef1ca0e54af296fe1d08ac00150c90bwrowe for (modp = top_module; modp; modp = modp->next) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein merger_func df = modp->merge_server_config;
f4c310fd2555c6faca1f980f00b161eadb089023gstein int i = modp->module_index;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (!virt_vector[i])
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm virt_vector[i] = base_vector[i];
f4c310fd2555c6faca1f980f00b161eadb089023gstein else if (df)
f4c310fd2555c6faca1f980f00b161eadb089023gstein virt_vector[i] = (*df) (p, base_vector[i], virt_vector[i]);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid *ap_create_request_config(ap_context_t *p)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein return create_empty_config(p);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid *ap_create_conn_config(ap_context_t *p)
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein{
9f18c80269be35c0b5653e84b0db0a24044722c4gstein return create_empty_config(p);
9f18c80269be35c0b5653e84b0db0a24044722c4gstein}
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein
9f18c80269be35c0b5653e84b0db0a24044722c4gsteinCORE_EXPORT(void *) ap_create_per_dir_config(ap_context_t *p)
9f18c80269be35c0b5653e84b0db0a24044722c4gstein{
9f18c80269be35c0b5653e84b0db0a24044722c4gstein return create_empty_config(p);
709df1e1c2e1710570f8cb4209497e88662829c3gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein/*
709df1e1c2e1710570f8cb4209497e88662829c3gstein * For speed/efficiency we generate a compact list of all the handlers
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein * and wildcard handlers. This means we won't have to scan the entire
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein * module list looking for handlers... where we'll find a whole whack
f4c310fd2555c6faca1f980f00b161eadb089023gstein * of NULLs.
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein */
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gsteintypedef struct {
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein handler_rec hr;
709df1e1c2e1710570f8cb4209497e88662829c3gstein size_t len;
f4c310fd2555c6faca1f980f00b161eadb089023gstein} fast_handler_rec;
709df1e1c2e1710570f8cb4209497e88662829c3gstein
709df1e1c2e1710570f8cb4209497e88662829c3gsteinstatic fast_handler_rec *handlers;
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gsteinstatic fast_handler_rec *wildhandlers;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void init_handlers(ap_context_t *p)
7281ea331999debdc337b02ce37a3169e0e033a2gstein{
7281ea331999debdc337b02ce37a3169e0e033a2gstein module *modp;
7281ea331999debdc337b02ce37a3169e0e033a2gstein int nhandlers = 0;
7281ea331999debdc337b02ce37a3169e0e033a2gstein int nwildhandlers = 0;
7281ea331999debdc337b02ce37a3169e0e033a2gstein const handler_rec *handp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein fast_handler_rec *ph, *pw;
000397350b42c6266351bd618fa07df929fa7c79gstein char *starp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
000397350b42c6266351bd618fa07df929fa7c79gstein for (modp = top_module; modp; modp = modp->next) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (!modp->handlers)
f4c310fd2555c6faca1f980f00b161eadb089023gstein continue;
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (handp = modp->handlers; handp->content_type; ++handp) {
000397350b42c6266351bd618fa07df929fa7c79gstein if (strchr(handp->content_type, '*')) {
9f18c80269be35c0b5653e84b0db0a24044722c4gstein nwildhandlers ++;
000397350b42c6266351bd618fa07df929fa7c79gstein } else {
000397350b42c6266351bd618fa07df929fa7c79gstein nhandlers ++;
9f18c80269be35c0b5653e84b0db0a24044722c4gstein }
9f18c80269be35c0b5653e84b0db0a24044722c4gstein }
000397350b42c6266351bd618fa07df929fa7c79gstein }
000397350b42c6266351bd618fa07df929fa7c79gstein ph = handlers = ap_palloc(p, sizeof(*ph)*(nhandlers + 1));
9f18c80269be35c0b5653e84b0db0a24044722c4gstein pw = wildhandlers = ap_palloc(p, sizeof(*pw)*(nwildhandlers + 1));
000397350b42c6266351bd618fa07df929fa7c79gstein for (modp = top_module; modp; modp = modp->next) {
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein if (!modp->handlers)
9f18c80269be35c0b5653e84b0db0a24044722c4gstein continue;
9f18c80269be35c0b5653e84b0db0a24044722c4gstein for (handp = modp->handlers; handp->content_type; ++handp) {
9f18c80269be35c0b5653e84b0db0a24044722c4gstein if ((starp = strchr(handp->content_type, '*'))) {
9f18c80269be35c0b5653e84b0db0a24044722c4gstein pw->hr.content_type = handp->content_type;
9f18c80269be35c0b5653e84b0db0a24044722c4gstein pw->hr.handler = handp->handler;
9f18c80269be35c0b5653e84b0db0a24044722c4gstein pw->len = starp - handp->content_type;
9f18c80269be35c0b5653e84b0db0a24044722c4gstein pw ++;
9f18c80269be35c0b5653e84b0db0a24044722c4gstein } else {
9f18c80269be35c0b5653e84b0db0a24044722c4gstein ph->hr.content_type = handp->content_type;
9f18c80269be35c0b5653e84b0db0a24044722c4gstein ph->hr.handler = handp->handler;
9f18c80269be35c0b5653e84b0db0a24044722c4gstein ph->len = strlen(handp->content_type);
eb2abb2d3f87f28e99bcb282b91e432822b4d9b4gstein ph ++;
000397350b42c6266351bd618fa07df929fa7c79gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein pw->hr.content_type = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein pw->hr.handler = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein ph->hr.content_type = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein ph->hr.handler = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinint ap_invoke_handler(request_rec *r)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein fast_handler_rec *handp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *handler;
f4c310fd2555c6faca1f980f00b161eadb089023gstein char *p;
f4c310fd2555c6faca1f980f00b161eadb089023gstein size_t handler_len;
f4c310fd2555c6faca1f980f00b161eadb089023gstein int result = HTTP_INTERNAL_SERVER_ERROR;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (r->handler) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein handler = r->handler;
f4c310fd2555c6faca1f980f00b161eadb089023gstein handler_len = strlen(handler);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein else {
f4c310fd2555c6faca1f980f00b161eadb089023gstein handler = r->content_type ? r->content_type : ap_default_type(r);
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein if ((p = strchr(handler, ';')) != NULL) { /* MIME type arguments */
f4c310fd2555c6faca1f980f00b161eadb089023gstein while (p > handler && p[-1] == ' ')
f4c310fd2555c6faca1f980f00b161eadb089023gstein --p; /* strip trailing spaces */
f4c310fd2555c6faca1f980f00b161eadb089023gstein handler_len = p - handler;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein else {
f4c310fd2555c6faca1f980f00b161eadb089023gstein handler_len = strlen(handler);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Pass one --- direct matches */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (handp = handlers; handp->hr.content_type; ++handp) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (handler_len == handp->len
f4c310fd2555c6faca1f980f00b161eadb089023gstein && !strncmp(handler, handp->hr.content_type, handler_len)) {
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein result = (*handp->hr.handler) (r);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (result != DECLINED)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return result;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Pass two --- wildcard matches */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (handp = wildhandlers; handp->hr.content_type; ++handp) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (handler_len >= handp->len
f4c310fd2555c6faca1f980f00b161eadb089023gstein && !strncmp(handler, handp->hr.content_type, handp->len)) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein result = (*handp->hr.handler) (r);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (result != DECLINED)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return result;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (result == HTTP_INTERNAL_SERVER_ERROR && r->handler && r->filename) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "handler \"%s\" not found for: %s", r->handler, r->filename);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein return HTTP_INTERNAL_SERVER_ERROR;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinint g_bDebugHooks;
f4c310fd2555c6faca1f980f00b161eadb089023gsteinconst char *g_szCurrentHookName;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void register_hooks(module *m)
f4c310fd2555c6faca1f980f00b161eadb089023gstein {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if(m->register_hooks)
f4c310fd2555c6faca1f980f00b161eadb089023gstein {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if(getenv("SHOW_HOOKS"))
f4c310fd2555c6faca1f980f00b161eadb089023gstein {
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("Registering hooks for %s\n",m->name);
f4c310fd2555c6faca1f980f00b161eadb089023gstein g_bDebugHooks=1;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein g_szCurrentHookName=m->name;
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->register_hooks();
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* One-time setup for precompiled modules --- NOT to be done on restart */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void) ap_add_module(module *m)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* This could be called from an AddModule httpd.conf command,
f4c310fd2555c6faca1f980f00b161eadb089023gstein * after the file has been linked and the module structure within it
f4c310fd2555c6faca1f980f00b161eadb089023gstein * teased out...
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if (m->version != MODULE_MAGIC_NUMBER_MAJOR) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "%s: module \"%s\" is not compatible with this "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "version of Apache.", ap_server_argv0, m->name);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Please contact the vendor for the correct version.");
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein exit(1);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (m->next == NULL) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->next = top_module;
f4c310fd2555c6faca1f980f00b161eadb089023gstein top_module = m;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (m->module_index == -1) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->module_index = total_modules++;
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein dynamic_modules++;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (dynamic_modules > DYNAMIC_MODULE_LIMIT) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "%s: module \"%s\" could not be loaded, because"
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm " the dynamic", ap_server_argv0, m->name);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "module limit was reached. Please increase "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "DYNAMIC_MODULE_LIMIT and recompile.");
f4c310fd2555c6faca1f980f00b161eadb089023gstein exit(1);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Some C compilers put a complete path into __FILE__, but we want
f4c310fd2555c6faca1f980f00b161eadb089023gstein * only the filename (e.g. mod_includes.c). So check for path
f4c310fd2555c6faca1f980f00b161eadb089023gstein * components (Unix and DOS), and remove them.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (strrchr(m->name, '/'))
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->name = 1 + strrchr(m->name, '/');
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (strrchr(m->name, '\\'))
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->name = 1 + strrchr(m->name, '\\');
f4c310fd2555c6faca1f980f00b161eadb089023gstein
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein#ifdef _OSD_POSIX /* __FILE__="*POSIX(/home/martin/apache/src/modules/standard/mod_info.c)" */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* We cannot fix the string in-place, because it's const */
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (m->name[strlen(m->name)-1]==')') {
f4c310fd2555c6faca1f980f00b161eadb089023gstein char *tmp = strdup(m->name); /* FIXME:memory leak, albeit a small one */
f4c310fd2555c6faca1f980f00b161eadb089023gstein tmp[strlen(tmp)-1] = '\0';
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->name = tmp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif /*_OSD_POSIX*/
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* FIXME: is this the right place to call this? */
f4c310fd2555c6faca1f980f00b161eadb089023gstein register_hooks(m);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/*
f4c310fd2555c6faca1f980f00b161eadb089023gstein * remove_module undoes what add_module did. There are some caveats:
f4c310fd2555c6faca1f980f00b161eadb089023gstein * when the module is removed, its slot is lost so all the current
f4c310fd2555c6faca1f980f00b161eadb089023gstein * per-dir and per-server configurations are invalid. So we should
f4c310fd2555c6faca1f980f00b161eadb089023gstein * only ever call this function when you are invalidating almost
f4c310fd2555c6faca1f980f00b161eadb089023gstein * all our current data. I.e. when doing a restart.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void) ap_remove_module(module *m)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein module *modp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein modp = top_module;
d839a9822ee53ce00da24c15f2d9fe054233d342gstein if (modp == m) {
d839a9822ee53ce00da24c15f2d9fe054233d342gstein /* We are the top module, special case */
d839a9822ee53ce00da24c15f2d9fe054233d342gstein top_module = modp->next;
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->next = NULL;
d839a9822ee53ce00da24c15f2d9fe054233d342gstein }
d839a9822ee53ce00da24c15f2d9fe054233d342gstein else {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Not the top module, find use. When found modp will
f4c310fd2555c6faca1f980f00b161eadb089023gstein * point to the module _before_ us in the list
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein while (modp && modp->next != m) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein modp = modp->next;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (!modp) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Uh-oh, this module doesn't exist */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Cannot remove module %s: not found in module list",
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->name);
f4c310fd2555c6faca1f980f00b161eadb089023gstein return;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Eliminate us from the module list */
f4c310fd2555c6faca1f980f00b161eadb089023gstein modp->next = modp->next->next;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein m->module_index = -1; /* simulate being unloaded, should
f4c310fd2555c6faca1f980f00b161eadb089023gstein * be unnecessary */
f4c310fd2555c6faca1f980f00b161eadb089023gstein dynamic_modules--;
f4c310fd2555c6faca1f980f00b161eadb089023gstein total_modules--;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void) ap_add_loaded_module(module *mod)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein module **m;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Add module pointer to top of chained module list
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_add_module(mod);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*
f4c310fd2555c6faca1f980f00b161eadb089023gstein * And module pointer to list of loaded modules
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Notes: 1. ap_add_module() would already complain if no more space
f4c310fd2555c6faca1f980f00b161eadb089023gstein * exists for adding a dynamically loaded module
f4c310fd2555c6faca1f980f00b161eadb089023gstein * 2. ap_add_module() accepts double inclusion, so we have
f4c310fd2555c6faca1f980f00b161eadb089023gstein * to accept this, too.
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (m = ap_loaded_modules; *m != NULL; m++)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ;
f4c310fd2555c6faca1f980f00b161eadb089023gstein *m++ = mod;
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein *m = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void) ap_remove_loaded_module(module *mod)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein module **m;
f4c310fd2555c6faca1f980f00b161eadb089023gstein module **m2;
f4c310fd2555c6faca1f980f00b161eadb089023gstein int done;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Remove module pointer from chained module list
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_remove_module(mod);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Remove module pointer from list of loaded modules
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Note: 1. We cannot determine if the module was successfully
f4c310fd2555c6faca1f980f00b161eadb089023gstein * removed by ap_remove_module().
f4c310fd2555c6faca1f980f00b161eadb089023gstein * 2. We have not to complain explicity when the module
f4c310fd2555c6faca1f980f00b161eadb089023gstein * is not found because ap_remove_module() did it
f4c310fd2555c6faca1f980f00b161eadb089023gstein * for us already.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (m = m2 = ap_loaded_modules, done = 0; *m2 != NULL; m2++) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (*m2 == mod && done == 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein done = 1;
f4c310fd2555c6faca1f980f00b161eadb089023gstein else
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm *m++ = *m2;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein *m = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid ap_setup_prelinked_modules(process_rec *process)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein module **m;
f4c310fd2555c6faca1f980f00b161eadb089023gstein module **m2;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Initialise total_modules variable and module indices
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
50bd75672ef114fb839dd9643c192b432fdf344cgstein total_modules = 0;
50bd75672ef114fb839dd9643c192b432fdf344cgstein for (m = ap_preloaded_modules; *m != NULL; m++)
f4c310fd2555c6faca1f980f00b161eadb089023gstein (*m)->module_index = total_modules++;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*
50bd75672ef114fb839dd9643c192b432fdf344cgstein * Initialise list of loaded modules
50bd75672ef114fb839dd9643c192b432fdf344cgstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_loaded_modules = (module **)ap_palloc(process->pool,
f4c310fd2555c6faca1f980f00b161eadb089023gstein sizeof(module *)*(total_modules+DYNAMIC_MODULE_LIMIT+1));
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (ap_loaded_modules == NULL) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Ouch! Out of memory in ap_setup_prelinked_modules()!");
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (m = ap_preloaded_modules, m2 = ap_loaded_modules; *m != NULL; )
f4c310fd2555c6faca1f980f00b161eadb089023gstein *m2++ = *m++;
f4c310fd2555c6faca1f980f00b161eadb089023gstein *m2 = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein * Initialize chain of linked (=activate) modules
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (m = ap_prelinked_modules; *m != NULL; m++)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_add_module(*m);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_sort_hooks();
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
50bd75672ef114fb839dd9643c192b432fdf344cgsteinAPI_EXPORT(const char *) ap_find_module_name(module *m)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein return m->name;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(module *) ap_find_linked_module(const char *name)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm module *modp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (modp = top_module; modp; modp = modp->next) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (strcmp(modp->name, name) == 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return modp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Add a named module. Returns 1 if module found, 0 otherwise. */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(int) ap_add_named_module(const char *name)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein module *modp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein int i = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (modp = ap_loaded_modules[i]; modp; modp = ap_loaded_modules[++i]) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (strcmp(modp->name, name) == 0) {
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein /* Only add modules that are not already enabled. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (modp->next == NULL) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_add_module(modp);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein return 1;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
f4c310fd2555c6faca1f980f00b161eadb089023gstein return 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Clear the internal list of modules, in preparation for starting over. */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(void) ap_clear_module_list()
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein module **m = &top_module;
f4c310fd2555c6faca1f980f00b161eadb089023gstein module **next_m;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein while (*m) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein next_m = &((*m)->next);
f4c310fd2555c6faca1f980f00b161eadb089023gstein *m = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein m = next_m;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* This is required; so we add it always. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_add_named_module("http_core.c");
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein/*****************************************************************
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein *
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein * Resource, access, and .htaccess config files now parsed by a common
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein * command loop.
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein *
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein * Let's begin with the basics; parsing the line and
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein * invoking the function...
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
ba8574a7fe6f1c3405982bb856591b5f13fe205agstein
5a47cad1aef57039cd47eb34ebbc2959c610f326gsteinstatic const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein void *mconfig, const char *args)
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein{
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein char *w, *w2, *w3;
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *errmsg;
ba8574a7fe6f1c3405982bb856591b5f13fe205agstein
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if ((parms->override & cmd->req_override) == 0)
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein return ap_pstrcat(parms->pool, cmd->name, " not allowed here", NULL);
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein parms->info = cmd->cmd_data;
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein parms->cmd = cmd;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein switch (cmd->args_how) {
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein case RAW_ARGS:
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein#ifdef RESOLVE_ENV_PER_TOKEN
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein args = ap_resolve_env(parms->pool,args);
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein#endif
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein return ((const char *(*)(cmd_parms *, void *, const char *))
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein (cmd->func)) (parms, mconfig, args);
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein
9f18c80269be35c0b5653e84b0db0a24044722c4gstein case NO_ARGS:
9f18c80269be35c0b5653e84b0db0a24044722c4gstein if (*args != 0)
9f18c80269be35c0b5653e84b0db0a24044722c4gstein return ap_pstrcat(parms->pool, cmd->name, " takes no arguments",
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein NULL);
7281ea331999debdc337b02ce37a3169e0e033a2gstein
9f18c80269be35c0b5653e84b0db0a24044722c4gstein return ((const char *(*)(cmd_parms *, void *))
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein (cmd->func)) (parms, mconfig);
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein case TAKE1:
f4c310fd2555c6faca1f980f00b161eadb089023gstein w = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein if (*w == '\0' || *args != 0)
5a47cad1aef57039cd47eb34ebbc2959c610f326gstein return ap_pstrcat(parms->pool, cmd->name, " takes one argument",
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein return ((const char *(*)(cmd_parms *, void *, const char *))
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein (cmd->func)) (parms, mconfig, w);
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein case TAKE2:
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein w = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein w2 = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (*w == '\0' || *w2 == '\0' || *args != 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, cmd->name, " takes two arguments",
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ((const char *(*)(cmd_parms *, void *, const char *,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *)) (cmd->func)) (parms, mconfig, w, w2);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein case TAKE12:
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein w = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein w2 = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (*w == '\0' || *args != 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, cmd->name, " takes 1-2 arguments",
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein return ((const char *(*)(cmd_parms *, void *, const char *,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *)) (cmd->func)) (parms, mconfig, w,
f4c310fd2555c6faca1f980f00b161eadb089023gstein *w2 ? w2 : NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm case TAKE3:
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein w = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein w2 = ap_getword_conf(parms->pool, &args);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm w3 = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein if (*w == '\0' || *w2 == '\0' || *w3 == '\0' || *args != 0)
26250b0077972bf21b6d8a8d23772a4cf53f9477gstein return ap_pstrcat(parms->pool, cmd->name, " takes three arguments",
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ((const char *(*)(cmd_parms *, void *, const char *,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *, const char *)) (cmd->func)) (parms,
f4c310fd2555c6faca1f980f00b161eadb089023gstein mconfig, w, w2, w3);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein case TAKE23:
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein w = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein w2 = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (*w == '\0' || *w2 == '\0' || *args != 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, cmd->name,
f4c310fd2555c6faca1f980f00b161eadb089023gstein " takes two or three arguments",
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ((const char *(*)(cmd_parms *, void *, const char *,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *, const char *)) (cmd->func)) (parms,
f4c310fd2555c6faca1f980f00b161eadb089023gstein mconfig, w, w2, w3);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein case TAKE123:
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein w = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein if (*w == '\0' || *args != 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, cmd->name,
f4c310fd2555c6faca1f980f00b161eadb089023gstein " takes one, two or three arguments",
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ((const char *(*)(cmd_parms *, void *, const char *,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *, const char *)) (cmd->func)) (parms,
f4c310fd2555c6faca1f980f00b161eadb089023gstein mconfig, w, w2, w3);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein case TAKE13:
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein w = ap_getword_conf(parms->pool, &args);
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (*w == '\0' || (*w2 && !w3) || *args != 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, cmd->name,
f4c310fd2555c6faca1f980f00b161eadb089023gstein " takes one or three arguments",
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ((const char *(*)(cmd_parms *, void *, const char *,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *, const char *)) (cmd->func)) (parms,
f4c310fd2555c6faca1f980f00b161eadb089023gstein mconfig, w, w2, w3);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein case ITERATE:
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein while (*(w = ap_getword_conf(parms->pool, &args)) != '\0')
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((errmsg = ((const char *(*)(cmd_parms *, void *,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *)) (cmd->func)) (parms, mconfig, w)))
f4c310fd2555c6faca1f980f00b161eadb089023gstein return errmsg;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein case ITERATE2:
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein w = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (*w == '\0' || *args == 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, cmd->name,
f4c310fd2555c6faca1f980f00b161eadb089023gstein " requires at least two arguments",
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein while (*(w2 = ap_getword_conf(parms->pool, &args)) != '\0')
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((errmsg = ((const char *(*)(cmd_parms *, void *,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *, const char *)) (cmd->func)) (parms,
f4c310fd2555c6faca1f980f00b161eadb089023gstein mconfig, w, w2)))
f4c310fd2555c6faca1f980f00b161eadb089023gstein return errmsg;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein case FLAG:
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein w = ap_getword_conf(parms->pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (*w == '\0' || (strcasecmp(w, "on") && strcasecmp(w, "off")))
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, cmd->name, " must be On or Off",
f4c310fd2555c6faca1f980f00b161eadb089023gstein NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ((const char *(*)(cmd_parms *, void *, int))
f4c310fd2555c6faca1f980f00b161eadb089023gstein (cmd->func)) (parms, mconfig, strcasecmp(w, "off") != 0);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein default:
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, cmd->name,
f4c310fd2555c6faca1f980f00b161eadb089023gstein " is improperly configured internally (server bug)",
f4c310fd2555c6faca1f980f00b161eadb089023gstein NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinCORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein while (cmds->name)
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (!strcasecmp(name, cmds->name))
f4c310fd2555c6faca1f980f00b161eadb089023gstein return cmds;
f4c310fd2555c6faca1f980f00b161eadb089023gstein else
f4c310fd2555c6faca1f980f00b161eadb089023gstein ++cmds;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinCORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein const command_rec *cmdp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein module *modp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (modp = *mod; modp; modp = modp->next)
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (modp->cmds && (cmdp = ap_find_command(cmd_name, modp->cmds))) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein *mod = modp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return cmdp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinCORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein void *mconfig = ap_get_module_config(config, mod);
f4c310fd2555c6faca1f980f00b161eadb089023gstein void *sconfig = ap_get_module_config(parms->server->module_config, mod);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (!mconfig && mod->create_dir_config) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_set_module_config(config, mod, mconfig);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if (!sconfig && mod->create_server_config) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein sconfig = (*mod->create_server_config) (parms->pool, parms->server);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_set_module_config(parms->server->module_config, mod, sconfig);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein return mconfig;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinCORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein void *oldconfig;
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *args, *cmd_name, *retval;
f4c310fd2555c6faca1f980f00b161eadb089023gstein const command_rec *cmd;
f4c310fd2555c6faca1f980f00b161eadb089023gstein module *mod = top_module;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((l[0] == '#') || (!l[0]))
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein#if RESOLVE_ENV_PER_TOKEN
f4c310fd2555c6faca1f980f00b161eadb089023gstein args = l;
f4c310fd2555c6faca1f980f00b161eadb089023gstein#else
f4c310fd2555c6faca1f980f00b161eadb089023gstein args = ap_resolve_env(parms->temp_pool,l);
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd_name = ap_getword_conf(parms->temp_pool, &args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (*cmd_name == '\0')
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein oldconfig = parms->context;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms->context = config;
f4c310fd2555c6faca1f980f00b161eadb089023gstein do {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (!(cmd = ap_find_command_in_modules(cmd_name, &mod))) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein errno = EINVAL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_pstrcat(parms->pool, "Invalid command '", cmd_name,
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm "', perhaps mis-spelled or defined by a module "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "not included in the server configuration", NULL);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein else {
f4c310fd2555c6faca1f980f00b161eadb089023gstein void *mconfig = ap_set_config_vectors(parms,config, mod);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein retval = invoke_cmd(cmd, parms, mconfig, args);
f4c310fd2555c6faca1f980f00b161eadb089023gstein mod = mod->next; /* Next time around, skip this one */
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein } while (retval && !strcmp(retval, DECLINE_CMD));
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms->context = oldconfig;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return retval;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein char l[MAX_STRING_LEN];
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *errmsg = ap_handle_command(parms, config, l);
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (errmsg) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein return errmsg;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/*
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Generic command functions...
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
f4c310fd2555c6faca1f980f00b161eadb089023gstein char *struct_ptr, char *arg)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* This one's pretty generic... */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein int offset = (int) (long) cmd->info;
f4c310fd2555c6faca1f980f00b161eadb089023gstein *(char **) (struct_ptr + offset) = arg;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
f4c310fd2555c6faca1f980f00b161eadb089023gstein char *struct_ptr, char *arg)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* This one's pretty generic... */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein int offset = (int) (long) cmd->info;
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_str_tolower(arg);
f4c310fd2555c6faca1f980f00b161eadb089023gstein *(char **) (struct_ptr + offset) = arg;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
f4c310fd2555c6faca1f980f00b161eadb089023gstein char *struct_ptr, int arg)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein /* This one's pretty generic too... */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein int offset = (int) (long) cmd->info;
f4c310fd2555c6faca1f980f00b161eadb089023gstein *(int *) (struct_ptr + offset) = arg ? 1 : 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, char *struct_ptr, char *arg)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Prepend server_root to relative arg.
f4c310fd2555c6faca1f980f00b161eadb089023gstein This allows .htaccess to be independent of server_root,
f4c310fd2555c6faca1f980f00b161eadb089023gstein so the server can be moved or mirrored with less pain. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein char *p;
f4c310fd2555c6faca1f980f00b161eadb089023gstein int offset = (int) (long) cmd->info;
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (ap_os_is_path_absolute(arg))
f4c310fd2555c6faca1f980f00b161eadb089023gstein p = arg;
f4c310fd2555c6faca1f980f00b161eadb089023gstein else
f4c310fd2555c6faca1f980f00b161eadb089023gstein p = ap_make_full_path(cmd->pool, ap_server_root, arg);
f4c310fd2555c6faca1f980f00b161eadb089023gstein *(char **) (struct_ptr + offset) = p;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/*****************************************************************
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Reading whole config files...
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic cmd_parms default_parms =
f4c310fd2555c6faca1f980f00b161eadb089023gstein{NULL, 0, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinAPI_EXPORT(const char *) ap_server_root_relative(ap_context_t *p, const char *file)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein if(ap_os_is_path_absolute(file))
f4c310fd2555c6faca1f980f00b161eadb089023gstein return file;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_make_full_path(p, ap_server_root, file);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein/* This structure and the following functions are needed for the
f4c310fd2555c6faca1f980f00b161eadb089023gstein * table-based config file reading. They are passed to the
f4c310fd2555c6faca1f980f00b161eadb089023gstein * cfg_open_custom() routine.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Structure to be passed to cfg_open_custom(): it contains an
f4c310fd2555c6faca1f980f00b161eadb089023gstein * index which is incremented from 0 to nelts on each call to
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * cfg_getline() (which in turn calls arr_elts_getstr())
f4c310fd2555c6faca1f980f00b161eadb089023gstein * and an ap_array_header_t pointer for the string array.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gsteintypedef struct {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_array_header_t *array;
f4c310fd2555c6faca1f980f00b161eadb089023gstein int curr_idx;
f4c310fd2555c6faca1f980f00b161eadb089023gstein} arr_elts_param_t;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* arr_elts_getstr() returns the next line from the string array. */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void *arr_elts_getstr(void *buf, size_t bufsiz, void *param)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein arr_elts_param_t *arr_param = (arr_elts_param_t *) param;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* End of array reached? */
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (++arr_param->curr_idx > arr_param->array->nelts)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* return the line */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_cpystrn(buf, ((char **) arr_param->array->elts)[arr_param->curr_idx - 1], bufsiz);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return buf;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* arr_elts_close(): dummy close routine (makes sure no more lines can be read) */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int arr_elts_close(void *param)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein arr_elts_param_t *arr_param = (arr_elts_param_t *) param;
f4c310fd2555c6faca1f980f00b161eadb089023gstein arr_param->curr_idx = arr_param->array->nelts;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void process_command_config(server_rec *s, ap_array_header_t *arr, ap_context_t *p,
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_context_t *ptemp)
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *errmsg;
f4c310fd2555c6faca1f980f00b161eadb089023gstein cmd_parms parms;
f4c310fd2555c6faca1f980f00b161eadb089023gstein arr_elts_param_t arr_parms;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein arr_parms.curr_idx = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein arr_parms.array = arr;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms = default_parms;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.pool = p;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.temp_pool = ptemp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.server = s;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.config_file = ap_pcfg_open_custom(p, "-c/-C directives",
f4c310fd2555c6faca1f980f00b161eadb089023gstein &arr_parms, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein arr_elts_getstr, arr_elts_close);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein errmsg = ap_srm_command_loop(&parms, s->lookup_defaults);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (errmsg) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Syntax error in -C/-c directive:\n%s", errmsg);
f4c310fd2555c6faca1f980f00b161eadb089023gstein exit(1);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_cfg_closefile(parms.config_file);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid ap_process_resource_config(server_rec *s, const char *fname, ap_context_t *p, ap_context_t *ptemp)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *errmsg;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm cmd_parms parms;
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_finfo_t finfo;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein fname = ap_server_root_relative(p, fname);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
f4c310fd2555c6faca1f980f00b161eadb089023gstein !(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (ap_stat(&finfo, fname, p) != APR_SUCCESS)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* don't require conf/httpd.conf if we have a -C or -c switch */
f4c310fd2555c6faca1f980f00b161eadb089023gstein if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
f4c310fd2555c6faca1f980f00b161eadb089023gstein !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (ap_stat(&finfo, fname, p) != APR_SUCCESS)
f4c310fd2555c6faca1f980f00b161eadb089023gstein return;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* GCC's initialization extensions are soooo nice here... */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms = default_parms;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.pool = p;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.temp_pool = ptemp;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.server = s;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (ap_pcfg_openfile(&parms.config_file, p, fname) != APR_SUCCESS) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "%s: could not open document config file %s",
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_server_argv0, fname);
f4c310fd2555c6faca1f980f00b161eadb089023gstein exit(1);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein errmsg = ap_srm_command_loop(&parms, s->lookup_defaults);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (errmsg) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Syntax error on line %d of %s:",
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.config_file->line_number, parms.config_file->name);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "%s", errmsg);
f4c310fd2555c6faca1f980f00b161eadb089023gstein exit(1);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_cfg_closefile(parms.config_file);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinint ap_parse_htaccess(void **result, request_rec *r, int override,
f4c310fd2555c6faca1f980f00b161eadb089023gstein const char *d, const char *access_name)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein configfile_t *f = NULL;
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein cmd_parms parms;
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein const char *errmsg;
f4c310fd2555c6faca1f980f00b161eadb089023gstein char *filename = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein const struct htaccess_result *cache;
f4c310fd2555c6faca1f980f00b161eadb089023gstein struct htaccess_result *new;
f4c310fd2555c6faca1f980f00b161eadb089023gstein void *dc = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_status_t status;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* firstly, search cache */
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (cache = r->htaccess; cache != NULL; cache = cache->next)
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (cache->override == override && strcmp(cache->dir, d) == 0) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (cache->htaccess != NULL)
f4c310fd2555c6faca1f980f00b161eadb089023gstein *result = cache->htaccess;
f4c310fd2555c6faca1f980f00b161eadb089023gstein return OK;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms = default_parms;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.override = override;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.pool = r->pool;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.temp_pool = r->pool;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.server = r->server;
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.path = ap_pstrdup(r->pool, d);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* loop through the access names and find the first one */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein while (access_name[0]) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein filename = ap_make_full_path(r->pool, d,
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_getword_conf(r->pool, &access_name));
f4c310fd2555c6faca1f980f00b161eadb089023gstein status = ap_pcfg_openfile(&f, r->pool, filename);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (status == APR_SUCCESS) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein dc = ap_create_per_dir_config(r->pool);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein parms.config_file = f;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein errmsg = ap_srm_command_loop(&parms, dc);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_cfg_closefile(f);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (errmsg) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_rerror(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, r,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "%s: %s", filename, errmsg);
f4c310fd2555c6faca1f980f00b161eadb089023gstein return HTTP_INTERNAL_SERVER_ERROR;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein *result = dc;
f4c310fd2555c6faca1f980f00b161eadb089023gstein break;
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein else if (status != APR_ENOENT && status != APR_ENOTDIR) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "%s pcfg_openfile: unable to check htaccess file, "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "ensure it is readable",
7281ea331999debdc337b02ce37a3169e0e033a2gstein filename);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_table_setn(r->notes, "error-notes",
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Server unable to read htaccess file, denying "
f4c310fd2555c6faca1f980f00b161eadb089023gstein "access to be safe");
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein return HTTP_FORBIDDEN;
98e9c4a310bb623ff788680f88b6bd200ff36a24wrowe }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* cache it */
f4c310fd2555c6faca1f980f00b161eadb089023gstein new = ap_palloc(r->pool, sizeof(struct htaccess_result));
f4c310fd2555c6faca1f980f00b161eadb089023gstein new->dir = parms.path;
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein new->override = override;
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein new->htaccess = dc;
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* add to head of list */
f4c310fd2555c6faca1f980f00b161eadb089023gstein new->next = r->htaccess;
f4c310fd2555c6faca1f980f00b161eadb089023gstein r->htaccess = new;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return OK;
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein}
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinCORE_EXPORT(const char *) ap_init_virtual_host(ap_context_t *p, const char *hostname,
f4c310fd2555c6faca1f980f00b161eadb089023gstein server_rec *main_server, server_rec **ps)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec));
f4c310fd2555c6faca1f980f00b161eadb089023gstein
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein#ifdef RLIMIT_NOFILE
f4c310fd2555c6faca1f980f00b161eadb089023gstein struct rlimit limits;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein getrlimit(RLIMIT_NOFILE, &limits);
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (limits.rlim_cur < limits.rlim_max) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein limits.rlim_cur += 2;
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (setrlimit(RLIMIT_NOFILE, &limits) < 0) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein perror("setrlimit(RLIMIT_NOFILE)");
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
f4c310fd2555c6faca1f980f00b161eadb089023gstein "Cannot exceed hard limit for open files");
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* TODO: this crap belongs in http_core */
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->process = main_server->process;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->server_admin = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->server_hostname = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->error_fname = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->srm_confname = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->access_confname = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->timeout = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->keep_alive_timeout = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->keep_alive = -1;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->keep_alive_max = -1;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->error_log = main_server->error_log;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->loglevel = main_server->loglevel;
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* useful default, otherwise we get a port of 0 on redirects */
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein s->port = main_server->port;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->next = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->is_virtual = 1;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->names = ap_make_array(p, 4, sizeof(char **));
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->wild_names = ap_make_array(p, 4, sizeof(char **));
f5ec9b038bb9db933072ba2c0a8e7bb2a3cedbdagstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->module_config = create_empty_config(p);
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->lookup_defaults = ap_create_per_dir_config(p);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein#if 0
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->server_uid = ap_user_id;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->server_gid = ap_group_id;
f4c310fd2555c6faca1f980f00b161eadb089023gstein#endif
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->limit_req_line = main_server->limit_req_line;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->limit_req_fieldsize = main_server->limit_req_fieldsize;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->limit_req_fields = main_server->limit_req_fields;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein *ps = s;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return ap_parse_vhost_addrs(p, hostname, s);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void fixup_virtual_hosts(ap_context_t *p, server_rec *main_server)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein server_rec *virt;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (virt = main_server->next; virt; virt = virt->next) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein merge_server_configs(p, main_server->module_config,
f4c310fd2555c6faca1f980f00b161eadb089023gstein virt->module_config);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein virt->lookup_defaults =
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_merge_per_dir_configs(p, main_server->lookup_defaults,
f4c310fd2555c6faca1f980f00b161eadb089023gstein virt->lookup_defaults);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (virt->server_admin == NULL)
f4c310fd2555c6faca1f980f00b161eadb089023gstein virt->server_admin = main_server->server_admin;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (virt->srm_confname == NULL)
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein virt->srm_confname = main_server->srm_confname;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (virt->access_confname == NULL)
f4c310fd2555c6faca1f980f00b161eadb089023gstein virt->access_confname = main_server->access_confname;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (virt->timeout == 0)
f4c310fd2555c6faca1f980f00b161eadb089023gstein virt->timeout = main_server->timeout;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (virt->keep_alive_timeout == 0)
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein virt->keep_alive_timeout = main_server->keep_alive_timeout;
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (virt->keep_alive == -1)
f4c310fd2555c6faca1f980f00b161eadb089023gstein virt->keep_alive = main_server->keep_alive;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (virt->keep_alive_max == -1)
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm virt->keep_alive_max = main_server->keep_alive_max;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* XXX: this is really something that should be dealt with by a
f4c310fd2555c6faca1f980f00b161eadb089023gstein * post-config api phase */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_core_reorder_directories(p, virt);
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_core_reorder_directories(p, main_server);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/*****************************************************************
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Getting *everything* configured...
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void init_config_globals(ap_context_t *p)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* Global virtual host hash bucket pointers. Init to null. */
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_init_vhost_config(p);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic server_rec *init_server_config(process_rec *process, ap_context_t *p)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec));
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_open_stderr(&s->error_log, p);
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->process = process;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->port = 0;
7281ea331999debdc337b02ce37a3169e0e033a2gstein s->server_admin = DEFAULT_ADMIN;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->server_hostname = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->error_fname = DEFAULT_ERRORLOG;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->loglevel = DEFAULT_LOGLEVEL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->srm_confname = RESOURCE_CONFIG_FILE;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->access_confname = ACCESS_CONFIG_FILE;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
6b745319b1099edacf401e8911efa480440f999agstein s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->timeout = DEFAULT_TIMEOUT;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->keep_alive_max = DEFAULT_KEEPALIVE;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->keep_alive = 1;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->next = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->addrs = ap_pcalloc(p, sizeof(server_addr_rec));
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* NOT virtual host; don't match any real network interface */
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->addrs->host_addr.s_addr = htonl(INADDR_ANY);
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->addrs->host_port = 0; /* matches any port */
83719c22db4a6d0575bb4f7f34382d7b185a6f74gstein s->addrs->virthost = ""; /* must be non-NULL */
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->names = s->wild_names = NULL;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->module_config = create_server_config(p, s);
f4c310fd2555c6faca1f980f00b161eadb089023gstein s->lookup_defaults = create_default_per_dir_config(p);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return s;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinserver_rec *ap_read_config(process_rec *process, ap_context_t *ptemp, const char *confname)
7281ea331999debdc337b02ce37a3169e0e033a2gstein{
7281ea331999debdc337b02ce37a3169e0e033a2gstein ap_context_t *p = process->pconf;
7281ea331999debdc337b02ce37a3169e0e033a2gstein server_rec *s = init_server_config(process, p);
7281ea331999debdc337b02ce37a3169e0e033a2gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein init_config_globals(p);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
6b745319b1099edacf401e8911efa480440f999agstein /* All server-wide config files now have the SAME syntax... */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
6b745319b1099edacf401e8911efa480440f999agstein process_command_config(s, ap_server_pre_read_config, p, ptemp);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
6b745319b1099edacf401e8911efa480440f999agstein ap_process_resource_config(s, confname, p, ptemp);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm ap_process_resource_config(s, s->srm_confname, p, ptemp);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_process_resource_config(s, s->access_confname, p, ptemp);
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein process_command_config(s, ap_server_post_read_config, p, ptemp);
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
f4c310fd2555c6faca1f980f00b161eadb089023gstein fixup_virtual_hosts(p, s);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_fini_vhost_config(p, s);
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_sort_hooks();
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein return s;
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid ap_single_module_configure(ap_context_t *p, server_rec *s, module *m)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (m->create_server_config)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_set_module_config(s->module_config, m,
f4c310fd2555c6faca1f980f00b161eadb089023gstein (*m->create_server_config)(p, s));
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (m->create_dir_config)
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_set_module_config(s->lookup_defaults, m,
f4c310fd2555c6faca1f980f00b161eadb089023gstein (*m->create_dir_config)(p, NULL));
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid ap_post_config_hook(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_run_post_config(pconf,plog,ptemp,s);
f4c310fd2555c6faca1f980f00b161eadb089023gstein init_handlers(pconf);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid ap_child_init_hook(ap_context_t *pchild, server_rec *s)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm /* TODO: uh this seems ugly, is there a better way? */
f4c310fd2555c6faca1f980f00b161eadb089023gstein /*ap_child_init_alloc(); PUT THIS BACK IN XXXXX */
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein ap_run_child_init(pchild,s);
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/********************************************************************
f4c310fd2555c6faca1f980f00b161eadb089023gstein * Configuration directives are restricted in terms of where they may
f4c310fd2555c6faca1f980f00b161eadb089023gstein * appear in the main configuration files and/or .htaccess files according
f4c310fd2555c6faca1f980f00b161eadb089023gstein * to the bitmask req_override in the command_rec structure.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * If any of the overrides set in req_override are also allowed in the
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * context in which the command is read, then the command is allowed.
f4c310fd2555c6faca1f980f00b161eadb089023gstein * The context is determined as follows:
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
f4c310fd2555c6faca1f980f00b161eadb089023gstein * inside *.conf --> override = (RSRC_CONF|OR_ALL)&~(OR_AUTHCFG|OR_LIMIT);
f4c310fd2555c6faca1f980f00b161eadb089023gstein * within <Directory> or <Location> --> override = OR_ALL|ACCESS_CONF;
f4c310fd2555c6faca1f980f00b161eadb089023gstein * within .htaccess --> override = AllowOverride for current directory;
f4c310fd2555c6faca1f980f00b161eadb089023gstein *
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * the result is, well, a rather confusing set of possibilities for when
f4c310fd2555c6faca1f980f00b161eadb089023gstein * a particular directive is allowed to be used. This procedure prints
f4c310fd2555c6faca1f980f00b161eadb089023gstein * in English where the given (pc) directive can be used.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic void show_overrides(const command_rec *pc, module *pm)
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
f4c310fd2555c6faca1f980f00b161eadb089023gstein int n = 0;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("\tAllowed in *.conf ");
f4c310fd2555c6faca1f980f00b161eadb089023gstein if ((pc->req_override & (OR_OPTIONS | OR_FILEINFO | OR_INDEXES)) ||
f4c310fd2555c6faca1f980f00b161eadb089023gstein ((pc->req_override & RSRC_CONF) &&
f4c310fd2555c6faca1f980f00b161eadb089023gstein ((pc->req_override & (ACCESS_CONF | OR_AUTHCFG | OR_LIMIT)))))
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("anywhere");
f4c310fd2555c6faca1f980f00b161eadb089023gstein else if (pc->req_override & RSRC_CONF)
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("only outside <Directory>, <Files> or <Location>");
f4c310fd2555c6faca1f980f00b161eadb089023gstein else
7281ea331999debdc337b02ce37a3169e0e033a2gstein printf("only inside <Directory>, <Files> or <Location>");
7281ea331999debdc337b02ce37a3169e0e033a2gstein
7281ea331999debdc337b02ce37a3169e0e033a2gstein /* Warn if the directive is allowed inside <Directory> or .htaccess
7281ea331999debdc337b02ce37a3169e0e033a2gstein * but module doesn't support per-dir configuration */
7281ea331999debdc337b02ce37a3169e0e033a2gstein
7281ea331999debdc337b02ce37a3169e0e033a2gstein if ((pc->req_override & (OR_ALL | ACCESS_CONF)) && !pm->create_dir_config)
7281ea331999debdc337b02ce37a3169e0e033a2gstein printf(" [no per-dir config]");
7281ea331999debdc337b02ce37a3169e0e033a2gstein
7281ea331999debdc337b02ce37a3169e0e033a2gstein if (pc->req_override & OR_ALL) {
7281ea331999debdc337b02ce37a3169e0e033a2gstein printf(" and in .htaccess\n\twhen AllowOverride");
7281ea331999debdc337b02ce37a3169e0e033a2gstein
7281ea331999debdc337b02ce37a3169e0e033a2gstein if ((pc->req_override & OR_ALL) == OR_ALL)
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf(" isn't None");
f4c310fd2555c6faca1f980f00b161eadb089023gstein else {
7281ea331999debdc337b02ce37a3169e0e033a2gstein printf(" includes ");
7281ea331999debdc337b02ce37a3169e0e033a2gstein
7281ea331999debdc337b02ce37a3169e0e033a2gstein if (pc->req_override & OR_AUTHCFG) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (n++)
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf(" or ");
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("AuthConfig");
7281ea331999debdc337b02ce37a3169e0e033a2gstein }
7281ea331999debdc337b02ce37a3169e0e033a2gstein if (pc->req_override & OR_LIMIT) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (n++)
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf(" or ");
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("Limit");
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if (pc->req_override & OR_OPTIONS) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (n++)
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf(" or ");
7281ea331999debdc337b02ce37a3169e0e033a2gstein printf("Options");
7281ea331999debdc337b02ce37a3169e0e033a2gstein }
7281ea331999debdc337b02ce37a3169e0e033a2gstein if (pc->req_override & OR_FILEINFO) {
7281ea331999debdc337b02ce37a3169e0e033a2gstein if (n++)
7281ea331999debdc337b02ce37a3169e0e033a2gstein printf(" or ");
7281ea331999debdc337b02ce37a3169e0e033a2gstein printf("FileInfo");
7281ea331999debdc337b02ce37a3169e0e033a2gstein }
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if (pc->req_override & OR_INDEXES) {
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm if (n++)
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf(" or ");
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("Indexes");
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein }
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("\n");
f4c310fd2555c6faca1f980f00b161eadb089023gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Show the preloaded configuration directives, the help string explaining
f4c310fd2555c6faca1f980f00b161eadb089023gstein * the directive arguments, in what module they are handled, and in
f4c310fd2555c6faca1f980f00b161eadb089023gstein * what parts of the configuration they are allowed. Used for httpd -h.
f4c310fd2555c6faca1f980f00b161eadb089023gstein */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid ap_show_directives()
f4c310fd2555c6faca1f980f00b161eadb089023gstein{
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein const command_rec *pc;
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein int n;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (n = 0; ap_loaded_modules[n]; ++n)
f4c310fd2555c6faca1f980f00b161eadb089023gstein for (pc = ap_loaded_modules[n]->cmds; pc && pc->name; ++pc) {
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("%s (%s)\n", pc->name, ap_loaded_modules[n]->name);
f4c310fd2555c6faca1f980f00b161eadb089023gstein if (pc->errmsg)
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("\t%s\n", pc->errmsg);
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein show_overrides(pc, ap_loaded_modules[n]);
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein }
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein}
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein/* Show the preloaded module names. Used for httpd -l. */
f4c310fd2555c6faca1f980f00b161eadb089023gsteinvoid ap_show_modules()
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein{
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein int n;
f4c310fd2555c6faca1f980f00b161eadb089023gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein printf("Compiled in modules:\n");
52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5gstein for (n = 0; ap_loaded_modules[n]; ++n)
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein printf(" %s\n", ap_loaded_modules[n]->name);
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein}
252e2478cb56afb5ca8585b50bc2ffb780d2efb6gstein
f4c310fd2555c6faca1f980f00b161eadb089023gstein