core.c revision 79c754eb51681c3389cd966753e902c429f78939
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* Licensed to the Apache Software Foundation (ASF) under one or more
530eba85dbd41b8a0fa5255d3648d1440199a661slive * contributor license agreements. See the NOTICE file distributed with
e942c741056732f50da2074b36fe59805d370650slive * this work for additional information regarding copyright ownership.
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd * The ASF licenses this file to You under the Apache License, Version 2.0
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * (the "License"); you may not use this file except in compliance with
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * the License. You may obtain a copy of the License at
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding *
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * http://www.apache.org/licenses/LICENSE-2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding *
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * Unless required by applicable law or agreed to in writing, software
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * distributed under the License is distributed on an "AS IS" BASIS,
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * See the License for the specific language governing permissions and
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd * limitations under the License.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd */
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd#include "apr.h"
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd#include "apr_strings.h"
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd#include "apr_lib.h"
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd#include "apr_fnmatch.h"
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd#include "apr_hash.h"
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd#include "apr_thread_proc.h" /* for RLIMIT stuff */
7db9f691a00ead175b03335457ca296a33ddf31bnd#include "apr_hooks.h"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define APR_WANT_IOVEC
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define APR_WANT_STRFUNC
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define APR_WANT_MEMFUNC
530eba85dbd41b8a0fa5255d3648d1440199a661slive#include "apr_want.h"
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "ap_config.h"
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "httpd.h"
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "http_config.h"
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "http_core.h"
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "http_protocol.h" /* For index_of_response(). Grump. */
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen#include "http_request.h"
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen#include "http_vhost.h"
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "http_main.h" /* For the default_handler below... */
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "http_log.h"
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic#include "util_md5.h"
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic#include "http_connection.h"
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic#include "apr_buckets.h"
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic#include "util_filter.h"
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic#include "util_ebcdic.h"
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor#include "util_mutex.h"
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe#include "util_time.h"
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe#include "mpm_common.h"
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe#include "scoreboard.h"
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor#include "mod_core.h"
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe#include "mod_proxy.h"
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe#include "ap_listen.h"
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "mod_so.h" /* for ap_find_loaded_module_symbol */
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier#if defined(RLIMIT_CPU) || defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) || defined (RLIMIT_NPROC)
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier#include "unixd.h"
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier#endif
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier#if APR_HAVE_UNISTD_H
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier#include <unistd.h>
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#endif
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna/* LimitRequestBody handling */
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#define AP_LIMIT_REQ_BODY_UNSET ((apr_off_t) -1)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#define AP_DEFAULT_LIMIT_REQ_BODY ((apr_off_t) 0)
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna/* LimitXMLRequestBody handling */
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor#define AP_LIMIT_UNSET ((long) -1)
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor#define AP_DEFAULT_LIMIT_XML_BODY ((size_t)1000000)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor#define AP_MIN_SENDFILE_BYTES (256)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna/* maximum include nesting level */
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#ifndef AP_MAX_INCLUDE_DEPTH
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#define AP_MAX_INCLUDE_DEPTH (128)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#endif
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquernaAPR_HOOK_STRUCT(
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna APR_HOOK_LINK(get_mgmt_items)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorAP_IMPLEMENT_HOOK_RUN_ALL(int, get_mgmt_items,
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna (apr_pool_t *p, const char *val, apr_hash_t *ht),
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor (p, val, ht), OK, DECLINED)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna/* Server core module... This module provides support for really basic
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna * server operations, including options and commands which control the
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe * operation of other modules. Consider this the bureaucracy module.
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe *
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe * The core module also defines handlers, etc., to handle just enough
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe * to allow a server with the core module ONLY to actually serve documents.
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe *
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe * This file could almost be mod_core.c, except for the stuff which affects
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe * the http_conf_globals.
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe */
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe/* Handles for core filters */
5ae609a8a09239d20f48a4a95c4f21b713995babwroweAP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
5ae609a8a09239d20f48a4a95c4f21b713995babwroweAP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
5ae609a8a09239d20f48a4a95c4f21b713995babwroweAP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
5ae609a8a09239d20f48a4a95c4f21b713995babwroweAP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe/* Provide ap_document_root_check storage and default value = true */
5ae609a8a09239d20f48a4a95c4f21b713995babwroweAP_DECLARE_DATA int ap_document_root_check = 1;
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe/* magic pointer for ErrorDocument xxx "default" */
5ae609a8a09239d20f48a4a95c4f21b713995babwrowestatic char errordocument_default;
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorstatic void *create_core_dir_config(apr_pool_t *a, char *dir)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna{
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna core_dir_config *conf;
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna conf = (core_dir_config *)apr_pcalloc(a, sizeof(core_dir_config));
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* conf->r and conf->d[_*] are initialized by dirsection() or left NULL */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess conf->opts = dir ? OPT_UNSET : OPT_UNSET|OPT_ALL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts_add = conf->opts_remove = OPT_NONE;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->override = OR_UNSET|OR_NONE;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->override_opts = OPT_UNSET | OPT_ALL | OPT_SYM_OWNER | OPT_MULTI;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->content_md5 = 2;
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele conf->accept_path_info = 3;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->use_canonical_name = USE_CANONICAL_NAME_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->use_canonical_phys_port = USE_CANONICAL_PHYS_PORT_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->hostname_lookups = HOSTNAME_LOOKUP_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#ifdef RLIMIT_CPU
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->limit_cpu = NULL;
fb77c505254b6e9c925e23e734463e87574f8f40kess#endif
fb77c505254b6e9c925e23e734463e87574f8f40kess#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->limit_mem = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#ifdef RLIMIT_NPROC
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->limit_nproc = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess conf->limit_req_body = AP_LIMIT_REQ_BODY_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->limit_xml_body = AP_LIMIT_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->sec_file = apr_array_make(a, 2, sizeof(ap_conf_vector_t *));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->server_signature = srv_sig_unset;
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->add_default_charset = ADD_DEFAULT_CHARSET_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* Overriding all negotiation
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
fb77c505254b6e9c925e23e734463e87574f8f40kess conf->mime_type = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->handler = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->output_filters = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->input_filters = NULL;
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess /*
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Flag for use of inodes in ETags.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
fb77c505254b6e9c925e23e734463e87574f8f40kess conf->etag_bits = ETAG_UNSET;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess conf->etag_add = ETAG_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->etag_remove = ETAG_UNSET;
bc4b55ec8f31569d606d5680d50189a355bcd7a6rbowen
fb77c505254b6e9c925e23e734463e87574f8f40kess conf->enable_mmap = ENABLE_MMAP_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->enable_sendfile = ENABLE_SENDFILE_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->allow_encoded_slashes = 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return (void *)conf;
fb77c505254b6e9c925e23e734463e87574f8f40kess}
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
fb77c505254b6e9c925e23e734463e87574f8f40kess{
fb77c505254b6e9c925e23e734463e87574f8f40kess core_dir_config *base = (core_dir_config *)basev;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *new = (core_dir_config *)newv;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd core_dir_config *conf;
130d299c4b2b15be45532a176604c71fdc7bea5bnd int i;
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* Create this conf by duplicating the base, replacing elements
130d299c4b2b15be45532a176604c71fdc7bea5bnd * (or creating copies for merging) where new-> values exist.
130d299c4b2b15be45532a176604c71fdc7bea5bnd */
ef8e89e090461194ecadd31e8796a2c51e0531a2kess conf = (core_dir_config *)apr_pmemdup(a, base, sizeof(core_dir_config));
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd conf->d = new->d;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->d_is_fnmatch = new->d_is_fnmatch;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->d_components = new->d_components;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->r = new->r;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->condition = new->condition;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (new->opts & OPT_UNSET) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* there was no explicit setting of new->opts, so we merge
003f0c9fda6664daf5092a0e42f65ede20098153slive * preserve the invariant (opts_add & opts_remove) == 0
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts_add = (conf->opts_add & ~new->opts_remove) | new->opts_add;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts_remove = (conf->opts_remove & ~new->opts_add)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive | new->opts_remove;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts = (conf->opts & ~conf->opts_remove) | conf->opts_add;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess /* If Includes was enabled with exec in the base config, but
003f0c9fda6664daf5092a0e42f65ede20098153slive * was enabled without exec in the new config, then disable
003f0c9fda6664daf5092a0e42f65ede20098153slive * exec in the merged set. */
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess if (((base->opts & (OPT_INCLUDES|OPT_INC_WITH_EXEC))
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess == (OPT_INCLUDES|OPT_INC_WITH_EXEC))
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && ((new->opts & (OPT_INCLUDES|OPT_INC_WITH_EXEC))
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd == OPT_INCLUDES)) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->opts &= ~OPT_INC_WITH_EXEC;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* otherwise we just copy, because an explicit opts setting
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * overrides all earlier +/- modifiers
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts = new->opts;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts_add = new->opts_add;
130d299c4b2b15be45532a176604c71fdc7bea5bnd conf->opts_remove = new->opts_remove;
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (!(new->override & OR_UNSET)) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd conf->override = new->override;
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!(new->override_opts & OPT_UNSET)) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->override_opts = new->override_opts;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
1a3f62ca37273a15a06bb94a61d3c6fcf4bf38c9rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (conf->response_code_strings == NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->response_code_strings = new->response_code_strings;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (new->response_code_strings != NULL) {
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding /* If we merge, the merge-result must have it's own array
684f2a9a422185adda0692a1203c5ad6687fc5c5nd */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->response_code_strings = apr_pmemdup(a,
530eba85dbd41b8a0fa5255d3648d1440199a661slive base->response_code_strings,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sizeof(*conf->response_code_strings) * RESPONSE_CODES);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive for (i = 0; i < RESPONSE_CODES; ++i) {
003f0c9fda6664daf5092a0e42f65ede20098153slive if (new->response_code_strings[i] != NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->response_code_strings[i] = new->response_code_strings[i];
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding }
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding }
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding /* Otherwise we simply use the base->response_code_strings array
684f2a9a422185adda0692a1203c5ad6687fc5c5nd */
a8ce9095d102e43fecb81093a132b90b9a227f78kess
684f2a9a422185adda0692a1203c5ad6687fc5c5nd if (new->hostname_lookups != HOSTNAME_LOOKUP_UNSET) {
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding conf->hostname_lookups = new->hostname_lookups;
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding }
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding if ((new->content_md5 & 2) == 0) {
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding conf->content_md5 = new->content_md5;
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding }
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (new->accept_path_info != 3) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->accept_path_info = new->accept_path_info;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding if (new->use_canonical_name != USE_CANONICAL_NAME_UNSET) {
684f2a9a422185adda0692a1203c5ad6687fc5c5nd conf->use_canonical_name = new->use_canonical_name;
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding }
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding if (new->use_canonical_phys_port != USE_CANONICAL_PHYS_PORT_UNSET) {
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding conf->use_canonical_phys_port = new->use_canonical_phys_port;
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding }
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding#ifdef RLIMIT_CPU
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding if (new->limit_cpu) {
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding conf->limit_cpu = new->limit_cpu;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding#endif
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
77ead9e0262e4f08ec336d1a65b2edef7705c839nd if (new->limit_mem) {
77ead9e0262e4f08ec336d1a65b2edef7705c839nd conf->limit_mem = new->limit_mem;
9583adab6bc4b3758e41963c905d9dad9f067131nd }
77ead9e0262e4f08ec336d1a65b2edef7705c839nd#endif
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier
77ead9e0262e4f08ec336d1a65b2edef7705c839nd#ifdef RLIMIT_NPROC
77ead9e0262e4f08ec336d1a65b2edef7705c839nd if (new->limit_nproc) {
77ead9e0262e4f08ec336d1a65b2edef7705c839nd conf->limit_nproc = new->limit_nproc;
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier }
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier#endif
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd if (new->limit_req_body != AP_LIMIT_REQ_BODY_UNSET) {
77ead9e0262e4f08ec336d1a65b2edef7705c839nd conf->limit_req_body = new->limit_req_body;
77ead9e0262e4f08ec336d1a65b2edef7705c839nd }
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier if (new->limit_xml_body != AP_LIMIT_UNSET)
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier conf->limit_xml_body = new->limit_xml_body;
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier else
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier conf->limit_xml_body = base->limit_xml_body;
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier if (!conf->sec_file) {
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier conf->sec_file = new->sec_file;
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier }
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier else if (new->sec_file) {
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier /* If we merge, the merge-result must have it's own array
77ead9e0262e4f08ec336d1a65b2edef7705c839nd */
77ead9e0262e4f08ec336d1a65b2edef7705c839nd conf->sec_file = apr_array_append(a, base->sec_file, new->sec_file);
77ead9e0262e4f08ec336d1a65b2edef7705c839nd }
77ead9e0262e4f08ec336d1a65b2edef7705c839nd /* Otherwise we simply use the base->sec_file array
77ead9e0262e4f08ec336d1a65b2edef7705c839nd */
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier if (new->server_signature != srv_sig_unset) {
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier conf->server_signature = new->server_signature;
77ead9e0262e4f08ec336d1a65b2edef7705c839nd }
77ead9e0262e4f08ec336d1a65b2edef7705c839nd
77ead9e0262e4f08ec336d1a65b2edef7705c839nd if (new->add_default_charset != ADD_DEFAULT_CHARSET_UNSET) {
77ead9e0262e4f08ec336d1a65b2edef7705c839nd conf->add_default_charset = new->add_default_charset;
77ead9e0262e4f08ec336d1a65b2edef7705c839nd conf->add_default_charset_name = new->add_default_charset_name;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
003f0c9fda6664daf5092a0e42f65ede20098153slive /* Overriding all negotiation
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess */
fb77c505254b6e9c925e23e734463e87574f8f40kess if (new->mime_type) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->mime_type = new->mime_type;
4ea161d94782fa56f4b36d496f35ff8577c43065covener }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (new->handler) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->handler = new->handler;
fb77c505254b6e9c925e23e734463e87574f8f40kess }
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess if (new->output_filters) {
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess conf->output_filters = new->output_filters;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
10673857794a4b3d9568ca2d983722a87ed352f1rbowen if (new->input_filters) {
fb77c505254b6e9c925e23e734463e87574f8f40kess conf->input_filters = new->input_filters;
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd }
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd /*
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd * Now merge the setting of the FileETag directive.
10673857794a4b3d9568ca2d983722a87ed352f1rbowen */
10673857794a4b3d9568ca2d983722a87ed352f1rbowen if (new->etag_bits == ETAG_UNSET) {
113961f0559eb026ea0d379cb7350f82bc09d710druggeri conf->etag_add =
113961f0559eb026ea0d379cb7350f82bc09d710druggeri (conf->etag_add & (~ new->etag_remove)) | new->etag_add;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri conf->etag_remove =
113961f0559eb026ea0d379cb7350f82bc09d710druggeri (conf->etag_remove & (~ new->etag_add)) | new->etag_remove;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri conf->etag_bits =
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (conf->etag_bits & (~ conf->etag_remove)) | conf->etag_add;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->etag_bits = new->etag_bits;
fb77c505254b6e9c925e23e734463e87574f8f40kess conf->etag_add = new->etag_add;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->etag_remove = new->etag_remove;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (conf->etag_bits != ETAG_NONE) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->etag_bits &= (~ ETAG_NONE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (new->enable_mmap != ENABLE_MMAP_UNSET) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->enable_mmap = new->enable_mmap;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz if (new->enable_sendfile != ENABLE_SENDFILE_UNSET) {
9ed9eaf871c58d281af02e76125ceadb5060afa5nd conf->enable_sendfile = new->enable_sendfile;
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl }
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz conf->allow_encoded_slashes = new->allow_encoded_slashes;
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (new->log) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!conf->log) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->log = new->log;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding else {
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding conf->log = ap_new_log_config(a, new->log);
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding ap_merge_log_config(base->log, conf->log);
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding }
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding }
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding return (void*)conf;
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding}
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#if APR_HAS_SO_ACCEPTFILTER
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#ifndef ACCEPT_FILTER_NAME
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#define ACCEPT_FILTER_NAME "httpready"
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#ifdef __FreeBSD_version
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#if __FreeBSD_version < 411000 /* httpready broken before 4.1.1 */
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#undef ACCEPT_FILTER_NAME
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#define ACCEPT_FILTER_NAME "dataready"
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#endif
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#endif
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#endif
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#endif
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluemstatic void *create_core_server_config(apr_pool_t *a, server_rec *s)
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem{
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem core_server_config *conf;
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem int is_virtual = s->is_virtual;
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem conf = (core_server_config *)apr_pcalloc(a, sizeof(core_server_config));
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* global-default / global-only settings */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!is_virtual) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->ap_document_root = DOCUMENT_LOCATION;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->access_name = DEFAULT_ACCESS_FNAME;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* A mapping only makes sense in the global context */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->accf_map = apr_table_make(a, 5);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#if APR_HAS_SO_ACCEPTFILTER
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_table_setn(conf->accf_map, "http", ACCEPT_FILTER_NAME);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_table_setn(conf->accf_map, "https", "dataready");
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#else
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_table_setn(conf->accf_map, "http", "data");
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_table_setn(conf->accf_map, "https", "data");
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* pcalloc'ed - we have NULL's/0's
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else ** is_virtual ** {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->ap_document_root = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->access_name = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->accf_map = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
9ed9eaf871c58d281af02e76125ceadb5060afa5nd
9ed9eaf871c58d281af02e76125ceadb5060afa5nd /* initialization, no special case for global context */
9ed9eaf871c58d281af02e76125ceadb5060afa5nd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->sec_dir = apr_array_make(a, 40, sizeof(ap_conf_vector_t *));
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna conf->sec_url = apr_array_make(a, 40, sizeof(ap_conf_vector_t *));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* pcalloc'ed - we have NULL's/0's
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->gprof_dir = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna ** recursion stopper; 0 == unset
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna conf->redirect_limit = 0;
f23fb63b05f89f47d7a3099491f2c68dcce432e9kess conf->subreq_limit = 0;
9970ad80054f477c708284a0d030a5bd26e412a9covener
9970ad80054f477c708284a0d030a5bd26e412a9covener conf->protocol = NULL;
9970ad80054f477c708284a0d030a5bd26e412a9covener */
9970ad80054f477c708284a0d030a5bd26e412a9covener
9970ad80054f477c708284a0d030a5bd26e412a9covener conf->trace_enable = AP_TRACE_UNSET;
9970ad80054f477c708284a0d030a5bd26e412a9covener
9970ad80054f477c708284a0d030a5bd26e412a9covener return (void *)conf;
9970ad80054f477c708284a0d030a5bd26e412a9covener}
9970ad80054f477c708284a0d030a5bd26e412a9covener
9970ad80054f477c708284a0d030a5bd26e412a9covenerstatic void *merge_core_server_configs(apr_pool_t *p, void *basev, void *virtv)
9970ad80054f477c708284a0d030a5bd26e412a9covener{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *base = (core_server_config *)basev;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *virt = (core_server_config *)virtv;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = (core_server_config *)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_pmemdup(p, base, sizeof(core_server_config));
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (virt->ap_document_root)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->ap_document_root = virt->ap_document_root;
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd if (virt->access_name)
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd conf->access_name = virt->access_name;
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd
da637bcae7b6e150470e701af29da5604a34a17erbowen /* XXX optimize to keep base->sec_ pointers if virt->sec_ array is empty */
da637bcae7b6e150470e701af29da5604a34a17erbowen conf->sec_dir = apr_array_append(p, base->sec_dir, virt->sec_dir);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor conf->sec_url = apr_array_append(p, base->sec_url, virt->sec_url);
da637bcae7b6e150470e701af29da5604a34a17erbowen
da637bcae7b6e150470e701af29da5604a34a17erbowen if (virt->redirect_limit)
da637bcae7b6e150470e701af29da5604a34a17erbowen conf->redirect_limit = virt->redirect_limit;
da637bcae7b6e150470e701af29da5604a34a17erbowen
da637bcae7b6e150470e701af29da5604a34a17erbowen if (virt->subreq_limit)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->subreq_limit = virt->subreq_limit;
7802d43d20007fa575e43b6ae77d5177ceffdb71sf
7802d43d20007fa575e43b6ae77d5177ceffdb71sf if (virt->trace_enable != AP_TRACE_UNSET)
7802d43d20007fa575e43b6ae77d5177ceffdb71sf conf->trace_enable = virt->trace_enable;
7802d43d20007fa575e43b6ae77d5177ceffdb71sf
86120957a14f91da0a1a103eaf4d7710b1dd9e2asf /* no action for virt->accf_map, not allowed per-vhost */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
113961f0559eb026ea0d379cb7350f82bc09d710druggeri if (virt->protocol)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri conf->protocol = virt->protocol;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri if (virt->gprof_dir)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri conf->gprof_dir = virt->gprof_dir;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri if (virt->error_log_format)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri conf->error_log_format = virt->error_log_format;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri if (virt->error_log_conn)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri conf->error_log_conn = virt->error_log_conn;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri if (virt->error_log_req)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri conf->error_log_req = virt->error_log_req;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri return conf;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri}
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri/* Add per-directory configuration entry (for <directory> section);
113961f0559eb026ea0d379cb7350f82bc09d710druggeri * these are part of the core server config.
113961f0559eb026ea0d379cb7350f82bc09d710druggeri */
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeriAP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri{
113961f0559eb026ea0d379cb7350f82bc09d710druggeri core_server_config *sconf = ap_get_module_config(s->module_config,
113961f0559eb026ea0d379cb7350f82bc09d710druggeri &core_module);
113961f0559eb026ea0d379cb7350f82bc09d710druggeri void **new_space = (void **)apr_array_push(sconf->sec_dir);
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri *new_space = dir_config;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri}
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeriAP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri{
113961f0559eb026ea0d379cb7350f82bc09d710druggeri core_server_config *sconf = ap_get_module_config(s->module_config,
113961f0559eb026ea0d379cb7350f82bc09d710druggeri &core_module);
113961f0559eb026ea0d379cb7350f82bc09d710druggeri void **new_space = (void **)apr_array_push(sconf->sec_url);
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri *new_space = url_config;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri}
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeriAP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri{
113961f0559eb026ea0d379cb7350f82bc09d710druggeri void **new_space = (void **)apr_array_push(conf->sec_file);
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri *new_space = url_config;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri}
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
113961f0559eb026ea0d379cb7350f82bc09d710druggeri/* We need to do a stable sort, qsort isn't stable. So to make it stable
113961f0559eb026ea0d379cb7350f82bc09d710druggeri * we'll be maintaining the original index into the list, and using it
113961f0559eb026ea0d379cb7350f82bc09d710druggeri * as the minor key during sorting. The major key is the number of
113961f0559eb026ea0d379cb7350f82bc09d710druggeri * components (where the root component is zero).
113961f0559eb026ea0d379cb7350f82bc09d710druggeri */
113961f0559eb026ea0d379cb7350f82bc09d710druggeristruct reorder_sort_rec {
113961f0559eb026ea0d379cb7350f82bc09d710druggeri ap_conf_vector_t *elt;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri int orig_index;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive};
113961f0559eb026ea0d379cb7350f82bc09d710druggeri
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int reorder_sorter(const void *va, const void *vb)
54bcd0e21a5c79158afd3b78bf707a493a5fb33crbowen{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const struct reorder_sort_rec *a = va;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const struct reorder_sort_rec *b = vb;
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes core_dir_config *core_a;
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes core_dir_config *core_b;
fb77c505254b6e9c925e23e734463e87574f8f40kess
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes core_a = ap_get_module_config(a->elt, &core_module);
fb77c505254b6e9c925e23e734463e87574f8f40kess core_b = ap_get_module_config(b->elt, &core_module);
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes /* a regex always sorts after a non-regex
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes */
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes if (!core_a->r && core_b->r) {
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes return -1;
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen else if (core_a->r && !core_b->r) {
fb77c505254b6e9c925e23e734463e87574f8f40kess return 1;
fb77c505254b6e9c925e23e734463e87574f8f40kess }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess /* we always sort next by the number of components
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes */
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes if (core_a->d_components < core_b->d_components) {
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes return -1;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (core_a->d_components > core_b->d_components) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess return 1;
fb77c505254b6e9c925e23e734463e87574f8f40kess }
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess /* They have the same number of components, we now have to compare
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * the minor key to maintain the original order (from the config.)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return a->orig_index - b->orig_index;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivevoid ap_core_reorder_directories(apr_pool_t *p, server_rec *s)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *sconf;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_array_header_t *sec_dir;
5bb5fba250bf526bc51d13b25378d54acb93c1cbnoodl struct reorder_sort_rec *sortbin;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int nelts;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_conf_vector_t **elts;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int i;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_pool_t *tmp;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sconf = ap_get_module_config(s->module_config, &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sec_dir = sconf->sec_dir;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive nelts = sec_dir->nelts;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive elts = (ap_conf_vector_t **)sec_dir->elts;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (!nelts) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* simple case of already being sorted... */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* We're not checking this condition to be fast... we're checking
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd * it to avoid trying to palloc zero bytes, which can trigger some
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * memory debuggers to barf
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* we have to allocate tmp space to do a stable sort */
fb77c505254b6e9c925e23e734463e87574f8f40kess apr_pool_create(&tmp, p);
fb77c505254b6e9c925e23e734463e87574f8f40kess sortbin = apr_palloc(tmp, sec_dir->nelts * sizeof(*sortbin));
fb77c505254b6e9c925e23e734463e87574f8f40kess for (i = 0; i < nelts; ++i) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sortbin[i].orig_index = i;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sortbin[i].elt = elts[i];
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive qsort(sortbin, nelts, sizeof(*sortbin), reorder_sorter);
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding /* and now copy back to the original array */
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding for (i = 0; i < nelts; ++i) {
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding elts[i] = sortbin[i].elt;
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding }
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding apr_pool_destroy(tmp);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/*****************************************************************
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen * There are some elements of the core config structures in which
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * other modules have a legitimate interest (this is ugly, but necessary
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * to preserve NCSA back-compatibility). So, we have a bunch of accessors
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding * here...
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding */
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(int) ap_allow_options(request_rec *r)
e4881891552e185a7408318dfc7f62ebabe73cf6niq{
e4881891552e185a7408318dfc7f62ebabe73cf6niq core_dir_config *conf =
e4881891552e185a7408318dfc7f62ebabe73cf6niq (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
e4881891552e185a7408318dfc7f62ebabe73cf6niq
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding return conf->opts;
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding}
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fieldingAP_DECLARE(int) ap_allow_overrides(request_rec *r)
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding{
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding core_dir_config *conf;
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding &core_module);
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding return conf->override;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/*
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl * Optional function coming from mod_authn_core, used for
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl * retrieving the type of autorization
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf */
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsfstatic APR_OPTIONAL_FN_TYPE(authn_ap_auth_type) *authn_ap_auth_type;
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsfAP_DECLARE(const char *) ap_auth_type(request_rec *r)
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl{
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl if (authn_ap_auth_type) {
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf return authn_ap_auth_type(r);
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf }
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf return NULL;
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf}
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf/*
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf * Optional function coming from mod_authn_core, used for
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf * retrieving the authorization realm
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf */
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsfstatic APR_OPTIONAL_FN_TYPE(authn_ap_auth_name) *authn_ap_auth_name;
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsfAP_DECLARE(const char *) ap_auth_name(request_rec *r)
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf{
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf if (authn_ap_auth_name) {
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf return authn_ap_auth_name(r);
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf }
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf return NULL;
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf}
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf/*
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf * Optional function coming from mod_access_compat, used to determine how
cba8c0896ba04d42cf9a9e50df5040fd6bae14a4sf access control interacts with authentication/authorization
cba8c0896ba04d42cf9a9e50df5040fd6bae14a4sf */
cba8c0896ba04d42cf9a9e50df5040fd6bae14a4sfstatic APR_OPTIONAL_FN_TYPE(access_compat_ap_satisfies) *access_compat_ap_satisfies;
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodlAP_DECLARE(int) ap_satisfies(request_rec *r)
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (access_compat_ap_satisfies) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return access_compat_ap_satisfies(r);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
898475b582dd849de5915df0f2089b72ed8b2e2bcovener return SATISFY_NOSPEC;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_document_root(request_rec *r) /* Don't use this! */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf = (core_server_config *)ap_get_module_config(r->server->module_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
898475b582dd849de5915df0f2089b72ed8b2e2bcovener
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return conf->ap_document_root;
898475b582dd849de5915df0f2089b72ed8b2e2bcovener}
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
003f0c9fda6664daf5092a0e42f65ede20098153slive/* Should probably just get rid of this... the only code that cares is
fb77c505254b6e9c925e23e734463e87574f8f40kess * part of the core anyway (and in fact, it isn't publicised to other
fb77c505254b6e9c925e23e734463e87574f8f40kess * modules).
fb77c505254b6e9c925e23e734463e87574f8f40kess */
fb77c505254b6e9c925e23e734463e87574f8f40kess
003f0c9fda6664daf5092a0e42f65ede20098153slivechar *ap_response_code_string(request_rec *r, int error_index)
003f0c9fda6664daf5092a0e42f65ede20098153slive{
003f0c9fda6664daf5092a0e42f65ede20098153slive core_dir_config *dirconf;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd core_request_config *reqconf;
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* check for string registered via ap_custom_response() first */
130d299c4b2b15be45532a176604c71fdc7bea5bnd reqconf = (core_request_config *)ap_get_module_config(r->request_config,
130d299c4b2b15be45532a176604c71fdc7bea5bnd &core_module);
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (reqconf->response_code_strings != NULL &&
130d299c4b2b15be45532a176604c71fdc7bea5bnd reqconf->response_code_strings[error_index] != NULL) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return reqconf->response_code_strings[error_index];
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* check for string specified via ErrorDocument */
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen dirconf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd &core_module);
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess if (dirconf->response_code_strings == NULL) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
b06660a3ed3d885e15d99c0209a46c4657df33fbrbowen
030108b1816bcda3d925df65357feabdce83bc94slive if (dirconf->response_code_strings[error_index] == &errordocument_default) {
030108b1816bcda3d925df65357feabdce83bc94slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return dirconf->response_code_strings[error_index];
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
fb77c505254b6e9c925e23e734463e87574f8f40kess/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */
fb77c505254b6e9c925e23e734463e87574f8f40kessstatic APR_INLINE void do_double_reverse (conn_rec *conn)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess apr_sockaddr_t *sa;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess apr_status_t rv;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (conn->double_reverse) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* already done */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (conn->remote_host == NULL || conn->remote_host[0] == '\0') {
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* single reverse failed, so don't bother */
130d299c4b2b15be45532a176604c71fdc7bea5bnd conn->double_reverse = -1;
130d299c4b2b15be45532a176604c71fdc7bea5bnd return;
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd rv = apr_sockaddr_info_get(&sa, conn->remote_host, APR_UNSPEC, 0, 0, conn->pool);
cdffd1263801c18587cefdebc4510df486d5906brbowen if (rv == APR_SUCCESS) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd while (sa) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (apr_sockaddr_equal(sa, conn->remote_addr)) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd conn->double_reverse = 1;
130d299c4b2b15be45532a176604c71fdc7bea5bnd return;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sa = sa->next;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conn->double_reverse = -1;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config,
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess int type, int *str_is_ip)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess int hostname_lookups;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess int ignored_str_is_ip;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!str_is_ip) { /* caller doesn't want to know */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive str_is_ip = &ignored_str_is_ip;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *str_is_ip = 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* If we haven't checked the host name, and we want to */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (dir_config) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd hostname_lookups =
130d299c4b2b15be45532a176604c71fdc7bea5bnd ((core_dir_config *)ap_get_module_config(dir_config, &core_module))
130d299c4b2b15be45532a176604c71fdc7bea5bnd ->hostname_lookups;
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (hostname_lookups == HOSTNAME_LOOKUP_UNSET) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd hostname_lookups = HOSTNAME_LOOKUP_OFF;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess else {
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess /* the default */
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess hostname_lookups = HOSTNAME_LOOKUP_OFF;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess }
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess if (type != REMOTE_NOLOOKUP
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && conn->remote_host == NULL
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen && (type == REMOTE_DOUBLE_REV
4e10c61d7f924071cad435df940a8f325015b2d3rbowen || hostname_lookups != HOSTNAME_LOOKUP_OFF)) {
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (apr_getnameinfo(&conn->remote_host, conn->remote_addr, 0)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive == APR_SUCCESS) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_str_tolower(conn->remote_host);
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd do_double_reverse(conn);
4e10c61d7f924071cad435df940a8f325015b2d3rbowen if (conn->double_reverse != 1) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd conn->remote_host = NULL;
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* if failed, set it to the NULL string to indicate error */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (conn->remote_host == NULL) {
fb77c505254b6e9c925e23e734463e87574f8f40kess conn->remote_host = "";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
fb77c505254b6e9c925e23e734463e87574f8f40kess }
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (type == REMOTE_DOUBLE_REV) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive do_double_reverse(conn);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (conn->double_reverse == -1) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /*
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Return the desired information; either the remote DNS name, if found,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * or either NULL (if the hostname was requested) or the IP address
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * (if any identifier was requested).
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (conn->remote_host != NULL && conn->remote_host[0] != '\0') {
898475b582dd849de5915df0f2089b72ed8b2e2bcovener return conn->remote_host;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
7b5535ed88e0f561b3bfb3330137bd804846afd4slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (type == REMOTE_HOST || type == REMOTE_DOUBLE_REV) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *str_is_ip = 1;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return conn->remote_ip;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor}
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd/*
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd * Optional function coming from mod_ident, used for looking up ident user
6954edc623ca2c179eb5b33e97e4304d06fd649frbowen */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic APR_OPTIONAL_FN_TYPE(ap_ident_lookup) *ident_lookup;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_get_remote_logname(request_rec *r)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener if (r->connection->remote_logname != NULL) {
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener return r->connection->remote_logname;
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener }
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener if (ident_lookup) {
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener return ident_lookup(r);
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener }
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener return NULL;
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener}
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor/* There are two options regarding what the "name" of a server is. The
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener * "canonical" name as defined by ServerName and Port, or the "client's
fa1c7ce09927decc1eecd1e9a35cc5331078a052covener * name" as supplied by a possible Host: header or full URI.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * The DNS option to UseCanonicalName causes this routine to do a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * reverse lookup on the local IP address of the connection and use
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess * that for the ServerName. This makes its value more reliable while
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * at the same time allowing Demon's magic virtual hosting to work.
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess * The assumption is that DNS lookups are sufficiently quick...
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess * -- fanf 1998-10-03
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess */
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_get_server_name(request_rec *r)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conn_rec *conn = r->connection;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *d;
003f0c9fda6664daf5092a0e42f65ede20098153slive const char *retval;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive switch (d->use_canonical_name) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive case USE_CANONICAL_NAME_ON:
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive retval = r->server->server_hostname;
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd break;
fb77c505254b6e9c925e23e734463e87574f8f40kess case USE_CANONICAL_NAME_DNS:
fb77c505254b6e9c925e23e734463e87574f8f40kess if (conn->local_host == NULL) {
fb77c505254b6e9c925e23e734463e87574f8f40kess if (apr_getnameinfo(&conn->local_host,
fb77c505254b6e9c925e23e734463e87574f8f40kess conn->local_addr, 0) != APR_SUCCESS)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conn->local_host = apr_pstrdup(conn->pool,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd r->server->server_hostname);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_str_tolower(conn->local_host);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
ffe8ed2cd88be2c415ddef11f50394c52df9190ctrawick retval = conn->local_host;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor break;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor case USE_CANONICAL_NAME_OFF:
c68acc9d712af079afa2bd1a5a4aeef9a3ea573ckess case USE_CANONICAL_NAME_UNSET:
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive retval = r->hostname ? r->hostname : r->server->server_hostname;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive break;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive default:
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
1b01d1ee11c612226cb3141eed4581dc179266c1rbowen "ap_get_server_name: Invalid UCN Option somehow");
1b01d1ee11c612226cb3141eed4581dc179266c1rbowen retval = "localhost";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive break;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
6b15044d54a096e6323ff1540f1a491e8de7622dsf return retval;
6b15044d54a096e6323ff1540f1a491e8de7622dsf}
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf/*
6b15044d54a096e6323ff1540f1a491e8de7622dsf * Get the current server name from the request for the purposes
6b15044d54a096e6323ff1540f1a491e8de7622dsf * of using in a URL. If the server name is an IPv6 literal
6b15044d54a096e6323ff1540f1a491e8de7622dsf * address, it will be returned in URL format (e.g., "[fe80::1]").
6b15044d54a096e6323ff1540f1a491e8de7622dsf */
6b15044d54a096e6323ff1540f1a491e8de7622dsfAP_DECLARE(const char *) ap_get_server_name_for_url(request_rec *r)
6b15044d54a096e6323ff1540f1a491e8de7622dsf{
6b15044d54a096e6323ff1540f1a491e8de7622dsf const char *plain_server_name = ap_get_server_name(r);
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf#if APR_HAVE_IPV6
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (ap_strchr_c(plain_server_name, ':')) { /* IPv6 literal? */
6b15044d54a096e6323ff1540f1a491e8de7622dsf return apr_psprintf(r->pool, "[%s]", plain_server_name);
6b15044d54a096e6323ff1540f1a491e8de7622dsf }
6b15044d54a096e6323ff1540f1a491e8de7622dsf#endif
6b15044d54a096e6323ff1540f1a491e8de7622dsf return plain_server_name;
6b15044d54a096e6323ff1540f1a491e8de7622dsf}
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsfAP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r)
6b15044d54a096e6323ff1540f1a491e8de7622dsf{
6b15044d54a096e6323ff1540f1a491e8de7622dsf apr_port_t port;
6b15044d54a096e6323ff1540f1a491e8de7622dsf core_dir_config *d =
6b15044d54a096e6323ff1540f1a491e8de7622dsf (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf switch (d->use_canonical_name) {
6b15044d54a096e6323ff1540f1a491e8de7622dsf case USE_CANONICAL_NAME_OFF:
6b15044d54a096e6323ff1540f1a491e8de7622dsf case USE_CANONICAL_NAME_DNS:
6b15044d54a096e6323ff1540f1a491e8de7622dsf case USE_CANONICAL_NAME_UNSET:
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (d->use_canonical_phys_port == USE_CANONICAL_PHYS_PORT_ON)
6b15044d54a096e6323ff1540f1a491e8de7622dsf port = r->parsed_uri.port_str ? r->parsed_uri.port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf r->connection->local_addr->port ? r->connection->local_addr->port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf r->server->port ? r->server->port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf ap_default_port(r);
6b15044d54a096e6323ff1540f1a491e8de7622dsf else /* USE_CANONICAL_PHYS_PORT_OFF or USE_CANONICAL_PHYS_PORT_UNSET */
6b15044d54a096e6323ff1540f1a491e8de7622dsf port = r->parsed_uri.port_str ? r->parsed_uri.port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf r->server->port ? r->server->port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf ap_default_port(r);
6b15044d54a096e6323ff1540f1a491e8de7622dsf break;
6b15044d54a096e6323ff1540f1a491e8de7622dsf case USE_CANONICAL_NAME_ON:
6b15044d54a096e6323ff1540f1a491e8de7622dsf /* With UseCanonicalName on (and in all versions prior to 1.3)
6b15044d54a096e6323ff1540f1a491e8de7622dsf * Apache will use the hostname and port specified in the
6b15044d54a096e6323ff1540f1a491e8de7622dsf * ServerName directive to construct a canonical name for the
6b15044d54a096e6323ff1540f1a491e8de7622dsf * server. (If no port was specified in the ServerName
6b15044d54a096e6323ff1540f1a491e8de7622dsf * directive, Apache uses the port supplied by the client if
6b15044d54a096e6323ff1540f1a491e8de7622dsf * any is supplied, and finally the default port for the protocol
6b15044d54a096e6323ff1540f1a491e8de7622dsf * used.
6b15044d54a096e6323ff1540f1a491e8de7622dsf */
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (d->use_canonical_phys_port == USE_CANONICAL_PHYS_PORT_ON)
6b15044d54a096e6323ff1540f1a491e8de7622dsf port = r->server->port ? r->server->port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf r->connection->local_addr->port ? r->connection->local_addr->port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf ap_default_port(r);
6b15044d54a096e6323ff1540f1a491e8de7622dsf else /* USE_CANONICAL_PHYS_PORT_OFF or USE_CANONICAL_PHYS_PORT_UNSET */
6b15044d54a096e6323ff1540f1a491e8de7622dsf port = r->server->port ? r->server->port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf ap_default_port(r);
6b15044d54a096e6323ff1540f1a491e8de7622dsf break;
6b15044d54a096e6323ff1540f1a491e8de7622dsf default:
6b15044d54a096e6323ff1540f1a491e8de7622dsf ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
6b15044d54a096e6323ff1540f1a491e8de7622dsf "ap_get_server_port: Invalid UCN Option somehow");
6b15044d54a096e6323ff1540f1a491e8de7622dsf port = ap_default_port(r);
6b15044d54a096e6323ff1540f1a491e8de7622dsf break;
6b15044d54a096e6323ff1540f1a491e8de7622dsf }
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf return port;
6b15044d54a096e6323ff1540f1a491e8de7622dsf}
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsfAP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri,
6b15044d54a096e6323ff1540f1a491e8de7622dsf request_rec *r)
6b15044d54a096e6323ff1540f1a491e8de7622dsf{
6b15044d54a096e6323ff1540f1a491e8de7622dsf unsigned port = ap_get_server_port(r);
6b15044d54a096e6323ff1540f1a491e8de7622dsf const char *host = ap_get_server_name_for_url(r);
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (ap_is_default_port(port, r)) {
6b15044d54a096e6323ff1540f1a491e8de7622dsf return apr_pstrcat(p, ap_http_scheme(r), "://", host, uri, NULL);
6b15044d54a096e6323ff1540f1a491e8de7622dsf }
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf return apr_psprintf(p, "%s://%s:%u%s", ap_http_scheme(r), host, port, uri);
6b15044d54a096e6323ff1540f1a491e8de7622dsf}
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsfAP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r)
6b15044d54a096e6323ff1540f1a491e8de7622dsf{
6b15044d54a096e6323ff1540f1a491e8de7622dsf core_dir_config *d =
6b15044d54a096e6323ff1540f1a491e8de7622dsf (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (d->limit_req_body == AP_LIMIT_REQ_BODY_UNSET) {
6b15044d54a096e6323ff1540f1a491e8de7622dsf return AP_DEFAULT_LIMIT_REQ_BODY;
6b15044d54a096e6323ff1540f1a491e8de7622dsf }
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf return d->limit_req_body;
6b15044d54a096e6323ff1540f1a491e8de7622dsf}
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf/*****************************************************************
6b15044d54a096e6323ff1540f1a491e8de7622dsf *
6b15044d54a096e6323ff1540f1a491e8de7622dsf * Commands... this module handles almost all of the NCSA httpd.conf
af18698b10b429b270551ca3a5d51a75e1c9db22brianp * commands, but most of the old srm.conf is in the the modules.
af18698b10b429b270551ca3a5d51a75e1c9db22brianp */
003f0c9fda6664daf5092a0e42f65ede20098153slive
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess/* returns a parent if it matches the given directive */
af18698b10b429b270551ca3a5d51a75e1c9db22brianpstatic const ap_directive_t * find_parent(const ap_directive_t *dirp,
af18698b10b429b270551ca3a5d51a75e1c9db22brianp const char *what)
af18698b10b429b270551ca3a5d51a75e1c9db22brianp{
003f0c9fda6664daf5092a0e42f65ede20098153slive while (dirp->parent != NULL) {
af18698b10b429b270551ca3a5d51a75e1c9db22brianp dirp = dirp->parent;
af18698b10b429b270551ca3a5d51a75e1c9db22brianp
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd /* ### it would be nice to have atom-ized directives */
003f0c9fda6664daf5092a0e42f65ede20098153slive if (strcasecmp(dirp->directive, what) == 0)
003f0c9fda6664daf5092a0e42f65ede20098153slive return dirp;
fb77c505254b6e9c925e23e734463e87574f8f40kess }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
af18698b10b429b270551ca3a5d51a75e1c9db22brianpAP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd unsigned forbidden)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd{
af18698b10b429b270551ca3a5d51a75e1c9db22brianp const char *gt = (cmd->cmd->name[0] == '<'
af18698b10b429b270551ca3a5d51a75e1c9db22brianp && cmd->cmd->name[strlen(cmd->cmd->name)-1] != '>')
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd ? ">" : "";
13cbe1d8f52c8097cb581e7eb259693b64d41d10poirier const ap_directive_t *found;
13cbe1d8f52c8097cb581e7eb259693b64d41d10poirier
13cbe1d8f52c8097cb581e7eb259693b64d41d10poirier if ((forbidden & NOT_IN_VIRTUALHOST) && cmd->server->is_virtual) {
13cbe1d8f52c8097cb581e7eb259693b64d41d10poirier return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
af18698b10b429b270551ca3a5d51a75e1c9db22brianp " cannot occur within <VirtualHost> section", NULL);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if ((forbidden & (NOT_IN_LIMIT | NOT_IN_DIR_LOC_FILE))
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd && cmd->limited != -1) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
fb77c505254b6e9c925e23e734463e87574f8f40kess " cannot occur within <Limit> or <LimitExcept> "
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd "section", NULL);
41ef8b3051855b802104193ee0a587515af60a37wrowe }
41ef8b3051855b802104193ee0a587515af60a37wrowe
41ef8b3051855b802104193ee0a587515af60a37wrowe if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE) {
41ef8b3051855b802104193ee0a587515af60a37wrowe if (cmd->path != NULL) {
41ef8b3051855b802104193ee0a587515af60a37wrowe return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
41ef8b3051855b802104193ee0a587515af60a37wrowe " cannot occur within <Directory/Location/Files> "
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess "section", NULL);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (cmd->cmd->req_override & EXEC_ON_READ) {
41ef8b3051855b802104193ee0a587515af60a37wrowe /* EXEC_ON_READ must be NOT_IN_DIR_LOC_FILE, if not, it will
41ef8b3051855b802104193ee0a587515af60a37wrowe * (deliberately) segfault below in the individual tests...
41ef8b3051855b802104193ee0a587515af60a37wrowe */
41ef8b3051855b802104193ee0a587515af60a37wrowe return NULL;
41ef8b3051855b802104193ee0a587515af60a37wrowe }
41ef8b3051855b802104193ee0a587515af60a37wrowe }
41ef8b3051855b802104193ee0a587515af60a37wrowe
41ef8b3051855b802104193ee0a587515af60a37wrowe if (((forbidden & NOT_IN_DIRECTORY)
fb77c505254b6e9c925e23e734463e87574f8f40kess && ((found = find_parent(cmd->directive, "<Directory"))
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf || (found = find_parent(cmd->directive, "<DirectoryMatch"))))
41ef8b3051855b802104193ee0a587515af60a37wrowe || ((forbidden & NOT_IN_LOCATION)
41ef8b3051855b802104193ee0a587515af60a37wrowe && ((found = find_parent(cmd->directive, "<Location"))
41ef8b3051855b802104193ee0a587515af60a37wrowe || (found = find_parent(cmd->directive, "<LocationMatch"))))
41ef8b3051855b802104193ee0a587515af60a37wrowe || ((forbidden & NOT_IN_FILES)
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf && ((found = find_parent(cmd->directive, "<Files"))
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf || (found = find_parent(cmd->directive, "<FilesMatch"))))) {
41ef8b3051855b802104193ee0a587515af60a37wrowe return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
41ef8b3051855b802104193ee0a587515af60a37wrowe " cannot occur within ", found->directive,
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd "> section", NULL);
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd }
41ef8b3051855b802104193ee0a587515af60a37wrowe
41ef8b3051855b802104193ee0a587515af60a37wrowe return NULL;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen}
41ef8b3051855b802104193ee0a587515af60a37wrowe
41ef8b3051855b802104193ee0a587515af60a37wrowestatic const char *set_access_name(cmd_parms *cmd, void *dummy,
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick const char *arg)
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess{
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess void *sconf = cmd->server->module_config;
41ef8b3051855b802104193ee0a587515af60a37wrowe core_server_config *conf = ap_get_module_config(sconf, &core_module);
41ef8b3051855b802104193ee0a587515af60a37wrowe
41ef8b3051855b802104193ee0a587515af60a37wrowe const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
41ef8b3051855b802104193ee0a587515af60a37wrowe if (err != NULL) {
41ef8b3051855b802104193ee0a587515af60a37wrowe return err;
9fb925624300c864fe3969a264e52aa83f3c2dd0slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
78f4d313fd5edf76dc5cfb8725e082a08cd29740jwoolley conf->access_name = apr_pstrdup(cmd->pool, arg);
78f4d313fd5edf76dc5cfb8725e082a08cd29740jwoolley return NULL;
2025fe01de41805f6148851335693aa5ebe2faffnd}
2025fe01de41805f6148851335693aa5ebe2faffnd
9fb925624300c864fe3969a264e52aa83f3c2dd0slive
9c233808c898095865fcc0a2dc1cf594d0d8faf3sfstatic const char *set_define(cmd_parms *cmd, void *dummy,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess const char *optarg)
9fb925624300c864fe3969a264e52aa83f3c2dd0slive{
41ef8b3051855b802104193ee0a587515af60a37wrowe const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
41ef8b3051855b802104193ee0a587515af60a37wrowe if (err != NULL) {
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf return err;
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf }
41ef8b3051855b802104193ee0a587515af60a37wrowe
41ef8b3051855b802104193ee0a587515af60a37wrowe if (!ap_exists_config_define(optarg)) {
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf char **newv = (char **)apr_array_push(ap_server_config_defines);
41ef8b3051855b802104193ee0a587515af60a37wrowe *newv = apr_pstrdup(cmd->pool, optarg);
41ef8b3051855b802104193ee0a587515af60a37wrowe }
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf
9fb925624300c864fe3969a264e52aa83f3c2dd0slive return NULL;
41ef8b3051855b802104193ee0a587515af60a37wrowe}
41ef8b3051855b802104193ee0a587515af60a37wrowe
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessstatic const char *unset_define(cmd_parms *cmd, void *dummy,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess const char *optarg)
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess{
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess int i;
41ef8b3051855b802104193ee0a587515af60a37wrowe char **defines;
41ef8b3051855b802104193ee0a587515af60a37wrowe const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
832853bb93c1831daf24e4727c5ca0e1b1786e83lars if (err != NULL) {
832853bb93c1831daf24e4727c5ca0e1b1786e83lars return err;
78f97ce162b66a0dbfd7af4dcd9984f162569b04minfrin }
832853bb93c1831daf24e4727c5ca0e1b1786e83lars
832853bb93c1831daf24e4727c5ca0e1b1786e83lars defines = (char **)ap_server_config_defines->elts;
832853bb93c1831daf24e4727c5ca0e1b1786e83lars for (i = 0; i < ap_server_config_defines->nelts; i++) {
af18698b10b429b270551ca3a5d51a75e1c9db22brianp if (strcmp(defines[i], optarg) == 0) {
af18698b10b429b270551ca3a5d51a75e1c9db22brianp defines[i] = apr_array_pop(ap_server_config_defines);
af18698b10b429b270551ca3a5d51a75e1c9db22brianp break;
79c754eb51681c3389cd966753e902c429f78939trawick }
79c754eb51681c3389cd966753e902c429f78939trawick }
79c754eb51681c3389cd966753e902c429f78939trawick
79c754eb51681c3389cd966753e902c429f78939trawick return NULL;
79c754eb51681c3389cd966753e902c429f78939trawick}
79c754eb51681c3389cd966753e902c429f78939trawick
79c754eb51681c3389cd966753e902c429f78939trawickstatic const char *generate_error(cmd_parms *cmd, void *dummy,
79c754eb51681c3389cd966753e902c429f78939trawick const char *arg)
79c754eb51681c3389cd966753e902c429f78939trawick{
79c754eb51681c3389cd966753e902c429f78939trawick if (!arg || !*arg) {
79c754eb51681c3389cd966753e902c429f78939trawick return "The Error directive was used with no message.";
79c754eb51681c3389cd966753e902c429f78939trawick }
79c754eb51681c3389cd966753e902c429f78939trawick
79c754eb51681c3389cd966753e902c429f78939trawick if (*arg == '"' || *arg == '\'') { /* strip off quotes */
79c754eb51681c3389cd966753e902c429f78939trawick apr_size_t len = strlen(arg);
79c754eb51681c3389cd966753e902c429f78939trawick char last = *(arg + len - 1);
79c754eb51681c3389cd966753e902c429f78939trawick
79c754eb51681c3389cd966753e902c429f78939trawick if (*arg == last) {
79c754eb51681c3389cd966753e902c429f78939trawick return apr_pstrndup(cmd->pool, arg + 1, len - 2);
79c754eb51681c3389cd966753e902c429f78939trawick }
79c754eb51681c3389cd966753e902c429f78939trawick }
79c754eb51681c3389cd966753e902c429f78939trawick
79c754eb51681c3389cd966753e902c429f78939trawick return arg;
79c754eb51681c3389cd966753e902c429f78939trawick}
79c754eb51681c3389cd966753e902c429f78939trawick
79c754eb51681c3389cd966753e902c429f78939trawick#ifdef GPROF
79c754eb51681c3389cd966753e902c429f78939trawickstatic const char *set_gprof_dir(cmd_parms *cmd, void *dummy, const char *arg)
79c754eb51681c3389cd966753e902c429f78939trawick{
79c754eb51681c3389cd966753e902c429f78939trawick void *sconf = cmd->server->module_config;
79c754eb51681c3389cd966753e902c429f78939trawick core_server_config *conf = ap_get_module_config(sconf, &core_module);
79c754eb51681c3389cd966753e902c429f78939trawick
79c754eb51681c3389cd966753e902c429f78939trawick const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
79c754eb51681c3389cd966753e902c429f78939trawick if (err != NULL) {
79c754eb51681c3389cd966753e902c429f78939trawick return err;
79c754eb51681c3389cd966753e902c429f78939trawick }
79c754eb51681c3389cd966753e902c429f78939trawick
79c754eb51681c3389cd966753e902c429f78939trawick conf->gprof_dir = arg;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
003f0c9fda6664daf5092a0e42f65ede20098153slive#endif /*GPROF*/
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *set_add_default_charset(cmd_parms *cmd,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive void *d_, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *d = d_;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!strcasecmp(arg, "Off")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->add_default_charset = ADD_DEFAULT_CHARSET_OFF;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (!strcasecmp(arg, "On")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->add_default_charset = ADD_DEFAULT_CHARSET_ON;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->add_default_charset = ADD_DEFAULT_CHARSET_ON;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->add_default_charset_name = arg;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_document_root(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive void *sconf = cmd->server->module_config;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(sconf, &core_module);
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (err != NULL) {
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive return err;
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive }
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive /* When ap_document_root_check is false; skip all the stuff below */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!ap_document_root_check) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->ap_document_root = arg;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* Make it absolute, relative to ServerRoot */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd arg = ap_server_root_relative(cmd->pool, arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (arg == NULL) {
f7fe99050600166042c04b8e595fb75499eed7f0geoff return "DocumentRoot must be a directory";
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen }
f7fe99050600166042c04b8e595fb75499eed7f0geoff
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen /* TODO: ap_configtestonly */
f7fe99050600166042c04b8e595fb75499eed7f0geoff if (apr_filepath_merge((char**)&conf->ap_document_root, NULL, arg,
f7fe99050600166042c04b8e595fb75499eed7f0geoff APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS
f7fe99050600166042c04b8e595fb75499eed7f0geoff || !ap_is_directory(cmd->pool, arg)) {
f7fe99050600166042c04b8e595fb75499eed7f0geoff if (cmd->server->is_virtual) {
f7fe99050600166042c04b8e595fb75499eed7f0geoff ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0,
f7fe99050600166042c04b8e595fb75499eed7f0geoff cmd->pool,
f7fe99050600166042c04b8e595fb75499eed7f0geoff "Warning: DocumentRoot [%s] does not exist",
f7fe99050600166042c04b8e595fb75499eed7f0geoff arg);
f7fe99050600166042c04b8e595fb75499eed7f0geoff conf->ap_document_root = arg;
f7fe99050600166042c04b8e595fb75499eed7f0geoff }
f7fe99050600166042c04b8e595fb75499eed7f0geoff else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "DocumentRoot must be a directory";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(void) ap_custom_response(request_rec *r, int status,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *string)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_request_config *conf =
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_get_module_config(r->request_config, &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int idx;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (conf->response_code_strings == NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->response_code_strings =
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_pcalloc(r->pool,
fb77c505254b6e9c925e23e734463e87574f8f40kess sizeof(*conf->response_code_strings) * RESPONSE_CODES);
fb77c505254b6e9c925e23e734463e87574f8f40kess }
fb77c505254b6e9c925e23e734463e87574f8f40kess
4f854c24127e28f7ad72ce9a39d4448aaf910fc1slive idx = ap_index_of_response(status);
4f854c24127e28f7ad72ce9a39d4448aaf910fc1slive
4f854c24127e28f7ad72ce9a39d4448aaf910fc1slive conf->response_code_strings[idx] =
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick ((ap_is_url(string) || (*string == '/')) && (*string != '"')) ?
fb77c505254b6e9c925e23e734463e87574f8f40kess apr_pstrdup(r->pool, string) : apr_pstrcat(r->pool, "\"", string, NULL);
fb77c505254b6e9c925e23e734463e87574f8f40kess}
4f854c24127e28f7ad72ce9a39d4448aaf910fc1slive
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslivestatic const char *set_error_document(cmd_parms *cmd, void *conf_,
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive const char *errno_str, const char *msg)
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive{
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive core_dir_config *conf = conf_;
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive int error_number, index_number, idx500;
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive enum { MSG, LOCAL_PATH, REMOTE_PATH } what = MSG;
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor /* 1st parameter should be a 3 digit number, which we recognize;
b5d3d68a9f683722eac7a3ca507c3e571908dfc0rbowen * convert it into an array index
b5d3d68a9f683722eac7a3ca507c3e571908dfc0rbowen */
b5d3d68a9f683722eac7a3ca507c3e571908dfc0rbowen error_number = atoi(errno_str);
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen idx500 = ap_index_of_response(HTTP_INTERNAL_SERVER_ERROR);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (error_number == HTTP_INTERNAL_SERVER_ERROR) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive index_number = idx500;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if ((index_number = ap_index_of_response(error_number)) == idx500) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->pool, "Unsupported HTTP response code ",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive errno_str, NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* Heuristic to determine second argument. */
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh if (ap_strchr_c(msg,' '))
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive what = MSG;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (msg[0] == '/')
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive what = LOCAL_PATH;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (ap_is_url(msg))
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive what = REMOTE_PATH;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor what = MSG;
c68acc9d712af079afa2bd1a5a4aeef9a3ea573ckess
fb109b84906e3ee61680aa289953c2f9e859354erbowen /* The entry should be ignored if it is a full URL for a 401 error */
fb109b84906e3ee61680aa289953c2f9e859354erbowen
fb109b84906e3ee61680aa289953c2f9e859354erbowen if (error_number == 401 && what == REMOTE_PATH) {
fb109b84906e3ee61680aa289953c2f9e859354erbowen ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, cmd->server,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess "cannot use a full URL in a 401 ErrorDocument "
fb109b84906e3ee61680aa289953c2f9e859354erbowen "directive --- ignoring!");
960188481b7025ac8ef7221b67af83dd27e46cd0rjung }
960188481b7025ac8ef7221b67af83dd27e46cd0rjung else { /* Store it... */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (conf->response_code_strings == NULL) {
fb109b84906e3ee61680aa289953c2f9e859354erbowen conf->response_code_strings =
fb109b84906e3ee61680aa289953c2f9e859354erbowen apr_pcalloc(cmd->pool,
fb109b84906e3ee61680aa289953c2f9e859354erbowen sizeof(*conf->response_code_strings) *
fb109b84906e3ee61680aa289953c2f9e859354erbowen RESPONSE_CODES);
960188481b7025ac8ef7221b67af83dd27e46cd0rjung }
960188481b7025ac8ef7221b67af83dd27e46cd0rjung
960188481b7025ac8ef7221b67af83dd27e46cd0rjung if (strcmp(msg, "default") == 0) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* special case: ErrorDocument 404 default restores the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * canned server error response
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->response_code_strings[index_number] = &errordocument_default;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
5155e92c6100b47513159eee1b2b9914ab204a5acovener else {
5155e92c6100b47513159eee1b2b9914ab204a5acovener /* hack. Prefix a " if it is a msg; as that is what
5155e92c6100b47513159eee1b2b9914ab204a5acovener * http_protocol.c relies on to distinguish between
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * a msg and a (local) path.
fb109b84906e3ee61680aa289953c2f9e859354erbowen */
fb109b84906e3ee61680aa289953c2f9e859354erbowen conf->response_code_strings[index_number] = (what == MSG) ?
fb109b84906e3ee61680aa289953c2f9e859354erbowen apr_pstrcat(cmd->pool, "\"",msg,NULL) :
fb109b84906e3ee61680aa289953c2f9e859354erbowen apr_pstrdup(cmd->pool, msg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholesstatic const char *set_allow_opts(cmd_parms *cmd, allow_options_t *opts,
d950cf9262224a223e2ff5c51393708071e14b94covener const char *l)
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor{
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes allow_options_t opt;
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholes int first = 1;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *w, *p = (char *) l;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen char *tok_state;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while ((w = apr_strtok(p, ",", &tok_state)) != NULL) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (first) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf p = NULL;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf *opts = OPT_NONE;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf first = 0;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (!strcasecmp(w, "Indexes")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_INDEXES;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "Includes")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* If Includes is permitted, both Includes and
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * IncludesNOEXEC may be changed. */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = (OPT_INCLUDES | OPT_INC_WITH_EXEC);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "IncludesNOEXEC")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_INCLUDES;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
18ee8bb3db5cc3b04291f89301bd5d14dc271066lgentis else if (!strcasecmp(w, "FollowSymLinks")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_SYM_LINKS;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "SymLinksIfOwnerMatch")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_SYM_OWNER;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "ExecCGI")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_EXECCGI;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "MultiViews")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_MULTI;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "RunScripts")) { /* AI backcompat. Yuck */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_MULTI|OPT_EXECCGI;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "None")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_NONE;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "All")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_ALL;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else {
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf return apr_pstrcat(cmd->pool, "Illegal option ", w, NULL);
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf *opts |= opt;
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf (*opts) &= (~OPT_UNSET);
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf return NULL;
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf}
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsfstatic const char *set_override(cmd_parms *cmd, void *d_, const char *l)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf{
e302f38fd646764ce1a1e1c578d794aef514a9e5sf core_dir_config *d = d_;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf char *w;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf char *k, *v;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* Throw a warning if we're in <Location> or <Files> */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (ap_check_cmd_context(cmd, NOT_IN_LOCATION | NOT_IN_FILES)) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf "Useless use of AllowOverride in line %d of %s.",
e302f38fd646764ce1a1e1c578d794aef514a9e5sf cmd->directive->line_num, cmd->directive->filename);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override = OR_NONE;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf while (l[0]) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf w = ap_getword_conf(cmd->temp_pool, &l);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
4497075b5e08b0c8ee89425a1758258ae80550fcsf k = w;
4497075b5e08b0c8ee89425a1758258ae80550fcsf v = strchr(k, '=');
4497075b5e08b0c8ee89425a1758258ae80550fcsf if (v) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf *v++ = '\0';
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (!strcasecmp(w, "Limit")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override |= OR_LIMIT;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(k, "Options")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override |= OR_OPTIONS;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (v)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf set_allow_opts(cmd, &(d->override_opts), v);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override_opts = OPT_ALL;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "FileInfo")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override |= OR_FILEINFO;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "AuthConfig")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override |= OR_AUTHCFG;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "Indexes")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override |= OR_INDEXES;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "None")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override = OR_NONE;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "All")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->override = OR_ALL;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return apr_pstrcat(cmd->pool, "Illegal override option ", w, NULL);
4497075b5e08b0c8ee89425a1758258ae80550fcsf }
4497075b5e08b0c8ee89425a1758258ae80550fcsf
4497075b5e08b0c8ee89425a1758258ae80550fcsf d->override &= ~OR_UNSET;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return NULL;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf}
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic const char *set_options(cmd_parms *cmd, void *d_, const char *l)
b08558bf6a64f9501ad3eca34eaf4d978bd928cfsf{
b08558bf6a64f9501ad3eca34eaf4d978bd928cfsf core_dir_config *d = d_;
b08558bf6a64f9501ad3eca34eaf4d978bd928cfsf allow_options_t opt;
b08558bf6a64f9501ad3eca34eaf4d978bd928cfsf int first = 1;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf char action;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf while (l[0]) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf char *w = ap_getword_conf(cmd->temp_pool, &l);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf action = '\0';
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (*w == '+' || *w == '-') {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf action = *(w++);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (first) {
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf d->opts = OPT_NONE;
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf first = 0;
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf }
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf if (!strcasecmp(w, "Indexes")) {
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf opt = OPT_INDEXES;
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf }
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf else if (!strcasecmp(w, "Includes")) {
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf opt = (OPT_INCLUDES | OPT_INC_WITH_EXEC);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "IncludesNOEXEC")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_INCLUDES;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "FollowSymLinks")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_SYM_LINKS;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "SymLinksIfOwnerMatch")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_SYM_OWNER;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "ExecCGI")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_EXECCGI;
ce4dc40a4e87991087488f70d96d3447d7557294sf }
ce4dc40a4e87991087488f70d96d3447d7557294sf else if (!strcasecmp(w, "MultiViews")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_MULTI;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf else if (!strcasecmp(w, "RunScripts")) { /* AI backcompat. Yuck */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_MULTI|OPT_EXECCGI;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "None")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_NONE;
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "All")) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf opt = OPT_ALL;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else {
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf return apr_pstrcat(cmd->pool, "Illegal option ", w, NULL);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if ( (cmd->override_opts & opt) != opt ) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return apr_pstrcat(cmd->pool, "Option ", w, " not allowed here", NULL);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (action == '-') {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* we ensure the invariant (d->opts_add & d->opts_remove) == 0 */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->opts_remove |= opt;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->opts_add &= ~opt;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->opts &= ~opt;
e302f38fd646764ce1a1e1c578d794aef514a9e5sf }
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (action == '+') {
a8ee031b2224ce5473826c9d4f603681589245fawrowe d->opts_add |= opt;
a8ee031b2224ce5473826c9d4f603681589245fawrowe d->opts_remove &= ~opt;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor d->opts |= opt;
a8ee031b2224ce5473826c9d4f603681589245fawrowe }
a8ee031b2224ce5473826c9d4f603681589245fawrowe else {
a8ee031b2224ce5473826c9d4f603681589245fawrowe d->opts |= opt;
a8ee031b2224ce5473826c9d4f603681589245fawrowe }
a8ee031b2224ce5473826c9d4f603681589245fawrowe }
a8ee031b2224ce5473826c9d4f603681589245fawrowe
a8ee031b2224ce5473826c9d4f603681589245fawrowe return NULL;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor}
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
a8ee031b2224ce5473826c9d4f603681589245fawrowestatic const char *set_default_type(cmd_parms *cmd, void *d_,
a8ee031b2224ce5473826c9d4f603681589245fawrowe const char *arg)
a8ee031b2224ce5473826c9d4f603681589245fawrowe{
a8ee031b2224ce5473826c9d4f603681589245fawrowe if ((strcasecmp(arg, "off") != 0) && (strcasecmp(arg, "none") != 0)) {
a8ee031b2224ce5473826c9d4f603681589245fawrowe ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "Ignoring deprecated use of DefaultType in line %d of %s.",
a8ee031b2224ce5473826c9d4f603681589245fawrowe cmd->directive->line_num, cmd->directive->filename);
a8ee031b2224ce5473826c9d4f603681589245fawrowe }
a8ee031b2224ce5473826c9d4f603681589245fawrowe
34b157732214cedcd129cd9fe7c4290757505d60minfrin return NULL;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor}
a8ee031b2224ce5473826c9d4f603681589245fawrowe
a8ee031b2224ce5473826c9d4f603681589245fawrowe/*
a8ee031b2224ce5473826c9d4f603681589245fawrowe * Note what data should be used when forming file ETag values.
a8ee031b2224ce5473826c9d4f603681589245fawrowe * It would be nicer to do this as an ITERATE, but then we couldn't
02c86afa991026c4146423dc84bc126e57d28df6wrowe * remember the +/- state properly.
34b157732214cedcd129cd9fe7c4290757505d60minfrin */
34b157732214cedcd129cd9fe7c4290757505d60minfrinstatic const char *set_etag_bits(cmd_parms *cmd, void *mconfig,
34b157732214cedcd129cd9fe7c4290757505d60minfrin const char *args_p)
34b157732214cedcd129cd9fe7c4290757505d60minfrin{
a8ee031b2224ce5473826c9d4f603681589245fawrowe core_dir_config *cfg;
a8ee031b2224ce5473826c9d4f603681589245fawrowe etag_components_t bit;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char action;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *token;
003f0c9fda6664daf5092a0e42f65ede20098153slive const char *args;
a5f060e0c74a44cb8896ae794c08f94f7c9a46a7covener int valid;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd int first;
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele int explicit;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg = (core_dir_config *)mconfig;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive args = args_p;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive first = 1;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive explicit = 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while (args[0] != '\0') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive action = '*';
fb77c505254b6e9c925e23e734463e87574f8f40kess bit = ETAG_UNSET;
a5f060e0c74a44cb8896ae794c08f94f7c9a46a7covener valid = 1;
fb77c505254b6e9c925e23e734463e87574f8f40kess token = ap_getword_conf(cmd->temp_pool, &args);
c976a7c7d20f2be319b128dd7d0b1568da224c0arbowen if ((*token == '+') || (*token == '-')) {
fb77c505254b6e9c925e23e734463e87574f8f40kess action = *token;
fb77c505254b6e9c925e23e734463e87574f8f40kess token++;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else {
530eba85dbd41b8a0fa5255d3648d1440199a661slive /*
530eba85dbd41b8a0fa5255d3648d1440199a661slive * The occurrence of an absolute setting wipes
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * out any previous relative ones. The first such
530eba85dbd41b8a0fa5255d3648d1440199a661slive * occurrence forgets any inherited ones, too.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
530eba85dbd41b8a0fa5255d3648d1440199a661slive if (first) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg->etag_bits = ETAG_UNSET;
530eba85dbd41b8a0fa5255d3648d1440199a661slive cfg->etag_add = ETAG_UNSET;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd cfg->etag_remove = ETAG_UNSET;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd first = 0;
530eba85dbd41b8a0fa5255d3648d1440199a661slive }
fb77c505254b6e9c925e23e734463e87574f8f40kess }
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (strcasecmp(token, "None") == 0) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (action != '*') {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd valid = 0;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd cfg->etag_bits = bit = ETAG_NONE;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd explicit = 1;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else if (strcasecmp(token, "All") == 0) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (action != '*') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive valid = 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else {
0db981f8fdfb62c5149efa079f0369b73d472d04rpluem explicit = 1;
0db981f8fdfb62c5149efa079f0369b73d472d04rpluem cfg->etag_bits = bit = ETAG_ALL;
0db981f8fdfb62c5149efa079f0369b73d472d04rpluem }
0db981f8fdfb62c5149efa079f0369b73d472d04rpluem }
0db981f8fdfb62c5149efa079f0369b73d472d04rpluem else if (strcasecmp(token, "Size") == 0) {
0db981f8fdfb62c5149efa079f0369b73d472d04rpluem bit = ETAG_SIZE;
0db981f8fdfb62c5149efa079f0369b73d472d04rpluem }
0db981f8fdfb62c5149efa079f0369b73d472d04rpluem else if ((strcasecmp(token, "LMTime") == 0)
a5f060e0c74a44cb8896ae794c08f94f7c9a46a7covener || (strcasecmp(token, "MTime") == 0)
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor || (strcasecmp(token, "LastModified") == 0)) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor bit = ETAG_MTIME;
a5f060e0c74a44cb8896ae794c08f94f7c9a46a7covener }
a5f060e0c74a44cb8896ae794c08f94f7c9a46a7covener else if (strcasecmp(token, "INode") == 0) {
a5f060e0c74a44cb8896ae794c08f94f7c9a46a7covener bit = ETAG_INODE;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->pool, "Unknown keyword '",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive token, "' for ", cmd->cmd->name,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive " directive", NULL);
003f0c9fda6664daf5092a0e42f65ede20098153slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (! valid) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->pool, cmd->cmd->name, " keyword '",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive token, "' cannot be used with '+' or '-'",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive NULL);
003f0c9fda6664daf5092a0e42f65ede20098153slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (action == '+') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /*
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess * Make sure it's in the 'add' list and absent from the
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess * 'subtract' list.
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess */
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess cfg->etag_add |= bit;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess cfg->etag_remove &= (~ bit);
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (action == '-') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg->etag_remove |= bit;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg->etag_add &= (~ bit);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /*
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Non-relative values wipe out any + or - values
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * accumulated so far.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg->etag_bits |= bit;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg->etag_add = ETAG_UNSET;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd cfg->etag_remove = ETAG_UNSET;
fb77c505254b6e9c925e23e734463e87574f8f40kess explicit = 1;
030108b1816bcda3d925df65357feabdce83bc94slive }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor }
030108b1816bcda3d925df65357feabdce83bc94slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /*
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd * Any setting at all will clear the 'None' and 'Unset' bits.
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (cfg->etag_add != ETAG_UNSET) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd cfg->etag_add &= (~ ETAG_UNSET);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (cfg->etag_remove != ETAG_UNSET) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg->etag_remove &= (~ ETAG_UNSET);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (explicit) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg->etag_bits &= (~ ETAG_UNSET);
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess if ((cfg->etag_bits & ETAG_NONE) != ETAG_NONE) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cfg->etag_bits &= (~ ETAG_NONE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_enable_mmap(cmd_parms *cmd, void *d_,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
003f0c9fda6664daf5092a0e42f65ede20098153slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *d = d_;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (strcasecmp(arg, "on") == 0) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->enable_mmap = ENABLE_MMAP_ON;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
003f0c9fda6664daf5092a0e42f65ede20098153slive else if (strcasecmp(arg, "off") == 0) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->enable_mmap = ENABLE_MMAP_OFF;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess return "parameter must be 'on' or 'off'";
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
030108b1816bcda3d925df65357feabdce83bc94slive return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *set_enable_sendfile(cmd_parms *cmd, void *d_,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *d = d_;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess if (strcasecmp(arg, "on") == 0) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess d->enable_sendfile = ENABLE_SENDFILE_ON;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess else if (strcasecmp(arg, "off") == 0) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->enable_sendfile = ENABLE_SENDFILE_OFF;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "parameter must be 'on' or 'off'";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
003f0c9fda6664daf5092a0e42f65ede20098153slive
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen/*
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Report a missing-'>' syntax error.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic char *unclosed_directive(cmd_parms *cmd)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
fb77c505254b6e9c925e23e734463e87574f8f40kess return apr_pstrcat(cmd->pool, cmd->cmd->name,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "> directive missing closing '>'", NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding/*
fb77c505254b6e9c925e23e734463e87574f8f40kess * Report a missing args in '<Foo >' syntax error.
fb77c505254b6e9c925e23e734463e87574f8f40kess */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic char *missing_container_arg(cmd_parms *cmd)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd{
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return apr_pstrcat(cmd->pool, cmd->cmd->name,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd "> directive requires additional arguments", NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fieldingAP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd,
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding void *dummy,
7654193c1faf603feec999850322ad79e6c551bcnd const char *arg)
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding{
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding const char *endp = ap_strrchr_c(arg, '>');
c97e8972ab1f4dd167e3dc4db87daf91114009fbnd const char *limited_methods;
7654193c1faf603feec999850322ad79e6c551bcnd void *tog = cmd->cmd->cmd_data;
7654193c1faf603feec999850322ad79e6c551bcnd apr_int64_t limited = 0;
7654193c1faf603feec999850322ad79e6c551bcnd apr_int64_t old_limited = cmd->limited;
7654193c1faf603feec999850322ad79e6c551bcnd const char *errmsg;
7654193c1faf603feec999850322ad79e6c551bcnd
7654193c1faf603feec999850322ad79e6c551bcnd if (endp == NULL) {
7654193c1faf603feec999850322ad79e6c551bcnd return unclosed_directive(cmd);
7654193c1faf603feec999850322ad79e6c551bcnd }
7654193c1faf603feec999850322ad79e6c551bcnd
7654193c1faf603feec999850322ad79e6c551bcnd limited_methods = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
7654193c1faf603feec999850322ad79e6c551bcnd
7654193c1faf603feec999850322ad79e6c551bcnd if (!limited_methods[0]) {
c97e8972ab1f4dd167e3dc4db87daf91114009fbnd return missing_container_arg(cmd);
7654193c1faf603feec999850322ad79e6c551bcnd }
7654193c1faf603feec999850322ad79e6c551bcnd
7654193c1faf603feec999850322ad79e6c551bcnd while (limited_methods[0]) {
439acee10571861c670c438038a62f90a08bf137covener char *method = ap_getword_conf(cmd->temp_pool, &limited_methods);
439acee10571861c670c438038a62f90a08bf137covener int methnum;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor /* check for builtin or module registered method number */
439acee10571861c670c438038a62f90a08bf137covener methnum = ap_method_number_of(method);
439acee10571861c670c438038a62f90a08bf137covener
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (methnum == M_TRACE && !tog) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "TRACE cannot be controlled by <Limit>, see TraceEnable";
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener }
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener else if (methnum == M_INVALID) {
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener /* method has not been registered yet, but resorce restriction
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener * is always checked before method handling, so register it.
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener */
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener methnum = ap_method_register(cmd->pool,
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener apr_pstrdup(cmd->pool, method));
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener }
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener limited |= (AP_METHOD_BIT << methnum);
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener }
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener /* Killing two features with one function,
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener * if (tog == NULL) <Limit>, else <LimitExcept>
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor */
df5042f69eea159c73cd7b16542d4ca7d879b0b5trawick limited = tog ? ~limited : limited;
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener if (!(old_limited & limited)) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->pool, cmd->cmd->name,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "> directive excludes all methods", NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if ((old_limited & limited) == old_limited) {
fb77c505254b6e9c925e23e734463e87574f8f40kess return apr_pstrcat(cmd->pool, cmd->cmd->name,
fb77c505254b6e9c925e23e734463e87574f8f40kess "> directive specifies methods already excluded",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->limited &= limited;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive errmsg = ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
fb77c505254b6e9c925e23e734463e87574f8f40kess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess cmd->limited = old_limited;
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return errmsg;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* XXX: Bogus - need to do this differently (at least OS2/Netware suffer
9ed9eaf871c58d281af02e76125ceadb5060afa5nd * the same problem!!!
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * We use this in <DirectoryMatch> and <FilesMatch>, to ensure that
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * people don't get bitten by wrong-cased regex matches
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess#ifdef WIN32
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define USE_ICASE AP_REG_ICASE
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#else
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#define USE_ICASE 0
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *errmsg;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *endp = ap_strrchr_c(arg, '>');
fb77c505254b6e9c925e23e734463e87574f8f40kess int old_overrides = cmd->override;
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd char *old_path = cmd->path;
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd core_dir_config *conf;
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool);
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd ap_regex_t *r = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const command_rec *thiscmd = cmd->cmd;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
750d12c59545dbbac70390988de94f7e901b08f2niq if (err != NULL) {
750d12c59545dbbac70390988de94f7e901b08f2niq return err;
750d12c59545dbbac70390988de94f7e901b08f2niq }
750d12c59545dbbac70390988de94f7e901b08f2niq
750d12c59545dbbac70390988de94f7e901b08f2niq if (endp == NULL) {
750d12c59545dbbac70390988de94f7e901b08f2niq return unclosed_directive(cmd);
750d12c59545dbbac70390988de94f7e901b08f2niq }
750d12c59545dbbac70390988de94f7e901b08f2niq
750d12c59545dbbac70390988de94f7e901b08f2niq arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
750d12c59545dbbac70390988de94f7e901b08f2niq
750d12c59545dbbac70390988de94f7e901b08f2niq if (!arg[0]) {
750d12c59545dbbac70390988de94f7e901b08f2niq return missing_container_arg(cmd);
750d12c59545dbbac70390988de94f7e901b08f2niq }
750d12c59545dbbac70390988de94f7e901b08f2niq
750d12c59545dbbac70390988de94f7e901b08f2niq cmd->path = ap_getword_conf(cmd->pool, &arg);
750d12c59545dbbac70390988de94f7e901b08f2niq cmd->override = OR_ALL|ACCESS_CONF;
750d12c59545dbbac70390988de94f7e901b08f2niq
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (!strcmp(cmd->path, "~")) {
750d12c59545dbbac70390988de94f7e901b08f2niq cmd->path = ap_getword_conf(cmd->pool, &arg);
750d12c59545dbbac70390988de94f7e901b08f2niq if (!cmd->path)
6b15044d54a096e6323ff1540f1a491e8de7622dsf return "<Directory ~ > block must specify a path";
6b15044d54a096e6323ff1540f1a491e8de7622dsf r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (!r) {
6b15044d54a096e6323ff1540f1a491e8de7622dsf return "Regex could not be compiled";
6b15044d54a096e6323ff1540f1a491e8de7622dsf }
6b15044d54a096e6323ff1540f1a491e8de7622dsf }
1a0ca5f6b566a5eb77d63f466fcf78fb388a4182igalic else if (thiscmd->cmd_data) { /* <DirectoryMatch> */
1a0ca5f6b566a5eb77d63f466fcf78fb388a4182igalic r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
011e567af90fe9d72bbabf8cc5e373b4436b9d08rbowen if (!r) {
1a0ca5f6b566a5eb77d63f466fcf78fb388a4182igalic return "Regex could not be compiled";
1a0ca5f6b566a5eb77d63f466fcf78fb388a4182igalic }
6b15044d54a096e6323ff1540f1a491e8de7622dsf }
6b15044d54a096e6323ff1540f1a491e8de7622dsf else if (!strcmp(cmd->path, "/") == 0)
6b15044d54a096e6323ff1540f1a491e8de7622dsf {
6b15044d54a096e6323ff1540f1a491e8de7622dsf char *newpath;
6b15044d54a096e6323ff1540f1a491e8de7622dsf
6b15044d54a096e6323ff1540f1a491e8de7622dsf /*
750d12c59545dbbac70390988de94f7e901b08f2niq * Ensure that the pathname is canonical, and append the trailing /
750d12c59545dbbac70390988de94f7e901b08f2niq */
94aba9caa9b2f7a0e95a55f51264c908b69470e2igalic apr_status_t rv = apr_filepath_merge(&newpath, NULL, cmd->path,
94aba9caa9b2f7a0e95a55f51264c908b69470e2igalic APR_FILEPATH_TRUENAME, cmd->pool);
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (rv != APR_SUCCESS && rv != APR_EPATHWILD) {
6b15044d54a096e6323ff1540f1a491e8de7622dsf return apr_pstrcat(cmd->pool, "<Directory \"", cmd->path,
750d12c59545dbbac70390988de94f7e901b08f2niq "\"> path is invalid.", NULL);
750d12c59545dbbac70390988de94f7e901b08f2niq }
750d12c59545dbbac70390988de94f7e901b08f2niq
6b15044d54a096e6323ff1540f1a491e8de7622dsf cmd->path = newpath;
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (cmd->path[strlen(cmd->path) - 1] != '/')
6b15044d54a096e6323ff1540f1a491e8de7622dsf cmd->path = apr_pstrcat(cmd->pool, cmd->path, "/", NULL);
750d12c59545dbbac70390988de94f7e901b08f2niq }
750d12c59545dbbac70390988de94f7e901b08f2niq
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* initialize our config and fetch it */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf = ap_set_config_vectors(cmd->server, new_dir_conf, cmd->path,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module, cmd->pool);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_dir_conf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (errmsg != NULL)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return errmsg;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->r = r;
003f0c9fda6664daf5092a0e42f65ede20098153slive conf->d = cmd->path;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->d_is_fnmatch = (apr_fnmatch_test(conf->d) != 0);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* Make this explicit - the "/" root has 0 elements, that is, we
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd * will always merge it, and it will always sort and merge first.
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd * All others are sorted and tested by the number of slashes.
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (strcmp(conf->d, "/") == 0)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->d_components = 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->d_components = ap_count_dirs(conf->d);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_add_per_dir_conf(cmd->server, new_dir_conf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (*arg != '\0') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd "> arguments not (yet) supported.", NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->path = old_path;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->override = old_overrides;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodlstatic const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl{
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl const char *errmsg;
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl const char *endp = ap_strrchr_c(arg, '>');
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int old_overrides = cmd->override;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *old_path = cmd->path;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *conf;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_regex_t *r = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const command_rec *thiscmd = cmd->cmd;
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool);
a00429a6b3b4dbb113b6dc67cfc0507f610276e9takashi const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (err != NULL) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd return err;
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd
a00429a6b3b4dbb113b6dc67cfc0507f610276e9takashi if (endp == NULL) {
a00429a6b3b4dbb113b6dc67cfc0507f610276e9takashi return unclosed_directive(cmd);
955d7fc3e7adb6463b7243e15c04e858718e799etakashi }
955d7fc3e7adb6463b7243e15c04e858718e799etakashi
955d7fc3e7adb6463b7243e15c04e858718e799etakashi arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
955d7fc3e7adb6463b7243e15c04e858718e799etakashi
955d7fc3e7adb6463b7243e15c04e858718e799etakashi if (!arg[0]) {
955d7fc3e7adb6463b7243e15c04e858718e799etakashi return missing_container_arg(cmd);
955d7fc3e7adb6463b7243e15c04e858718e799etakashi }
955d7fc3e7adb6463b7243e15c04e858718e799etakashi
955d7fc3e7adb6463b7243e15c04e858718e799etakashi cmd->path = ap_getword_conf(cmd->pool, &arg);
955d7fc3e7adb6463b7243e15c04e858718e799etakashi cmd->override = OR_ALL|ACCESS_CONF;
78f97ce162b66a0dbfd7af4dcd9984f162569b04minfrin
955d7fc3e7adb6463b7243e15c04e858718e799etakashi if (thiscmd->cmd_data) { /* <LocationMatch> */
955d7fc3e7adb6463b7243e15c04e858718e799etakashi r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
955d7fc3e7adb6463b7243e15c04e858718e799etakashi if (!r) {
955d7fc3e7adb6463b7243e15c04e858718e799etakashi return "Regex could not be compiled";
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else if (!strcmp(cmd->path, "~")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->path = ap_getword_conf(cmd->pool, &arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!r) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "Regex could not be compiled";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a04a96aae08a62f2d9d5833b3313a9751fa3f680yoshiki
55d36f9b61520c2374ab463e77e8a62daa416398nd /* initialize our config and fetch it */
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess conf = ap_set_config_vectors(cmd->server, new_url_conf, cmd->path,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module, cmd->pool);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_url_conf);
003f0c9fda6664daf5092a0e42f65ede20098153slive if (errmsg != NULL)
55d36f9b61520c2374ab463e77e8a62daa416398nd return errmsg;
55d36f9b61520c2374ab463e77e8a62daa416398nd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->d = apr_pstrdup(cmd->pool, cmd->path); /* No mangling, please */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->r = r;
fb77c505254b6e9c925e23e734463e87574f8f40kess
fb77c505254b6e9c925e23e734463e87574f8f40kess ap_add_per_url_conf(cmd->server, new_url_conf);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (*arg != '\0') {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd "> arguments not (yet) supported.", NULL);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->path = old_path;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->override = old_overrides;
55d36f9b61520c2374ab463e77e8a62daa416398nd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
55d36f9b61520c2374ab463e77e8a62daa416398nd}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
55d36f9b61520c2374ab463e77e8a62daa416398nd const char *errmsg;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen const char *endp = ap_strrchr_c(arg, '>');
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int old_overrides = cmd->override;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd char *old_path = cmd->path;
55d36f9b61520c2374ab463e77e8a62daa416398nd core_dir_config *conf;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_regex_t *r = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const command_rec *thiscmd = cmd->cmd;
55d36f9b61520c2374ab463e77e8a62daa416398nd core_dir_config *c = mconfig;
55d36f9b61520c2374ab463e77e8a62daa416398nd ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
55d36f9b61520c2374ab463e77e8a62daa416398nd const char *err = ap_check_cmd_context(cmd,
55d36f9b61520c2374ab463e77e8a62daa416398nd NOT_IN_LOCATION | NOT_IN_LIMIT);
55d36f9b61520c2374ab463e77e8a62daa416398nd
bea526116133aa3d7dabd1924bfc580b37fbf22aslive if (err != NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return err;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (endp == NULL) {
bea526116133aa3d7dabd1924bfc580b37fbf22aslive return unclosed_directive(cmd);
bea526116133aa3d7dabd1924bfc580b37fbf22aslive }
bea526116133aa3d7dabd1924bfc580b37fbf22aslive
fb77c505254b6e9c925e23e734463e87574f8f40kess arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
bea526116133aa3d7dabd1924bfc580b37fbf22aslive
bea526116133aa3d7dabd1924bfc580b37fbf22aslive if (!arg[0]) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return missing_container_arg(cmd);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->path = ap_getword_conf(cmd->pool, &arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* Only if not an .htaccess file */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!old_path) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->override = OR_ALL|ACCESS_CONF;
3621f3acee323a877639a96d84891095eb07933aminfrin }
003f0c9fda6664daf5092a0e42f65ede20098153slive
003f0c9fda6664daf5092a0e42f65ede20098153slive if (thiscmd->cmd_data) { /* <FilesMatch> */
003f0c9fda6664daf5092a0e42f65ede20098153slive r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin if (!r) {
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return "Regex could not be compiled";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (!strcmp(cmd->path, "~")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->path = ap_getword_conf(cmd->pool, &arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
5b258a8d58679c6587757189339bb3c2d0488f93poirier if (!r) {
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return "Regex could not be compiled";
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin }
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen else {
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin char *newpath;
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin /* Ensure that the pathname is canonical, but we
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin * can't test the case/aliases without a fixed path */
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin if (apr_filepath_merge(&newpath, "", cmd->path,
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin 0, cmd->pool) != APR_SUCCESS)
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return apr_pstrcat(cmd->pool, "<Files \"", cmd->path,
3621f3acee323a877639a96d84891095eb07933aminfrin "\"> is invalid.", NULL);
3621f3acee323a877639a96d84891095eb07933aminfrin cmd->path = newpath;
3621f3acee323a877639a96d84891095eb07933aminfrin }
3621f3acee323a877639a96d84891095eb07933aminfrin
3621f3acee323a877639a96d84891095eb07933aminfrin /* initialize our config and fetch it */
3621f3acee323a877639a96d84891095eb07933aminfrin conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path,
3621f3acee323a877639a96d84891095eb07933aminfrin &core_module, cmd->pool);
3621f3acee323a877639a96d84891095eb07933aminfrin
3621f3acee323a877639a96d84891095eb07933aminfrin errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
3621f3acee323a877639a96d84891095eb07933aminfrin if (errmsg != NULL)
3621f3acee323a877639a96d84891095eb07933aminfrin return errmsg;
3621f3acee323a877639a96d84891095eb07933aminfrin
3621f3acee323a877639a96d84891095eb07933aminfrin conf->d = cmd->path;
3621f3acee323a877639a96d84891095eb07933aminfrin conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;
3621f3acee323a877639a96d84891095eb07933aminfrin conf->r = r;
3621f3acee323a877639a96d84891095eb07933aminfrin
3621f3acee323a877639a96d84891095eb07933aminfrin ap_add_file_conf(c, new_file_conf);
3621f3acee323a877639a96d84891095eb07933aminfrin
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin if (*arg != '\0') {
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
3621f3acee323a877639a96d84891095eb07933aminfrin "> arguments not (yet) supported.", NULL);
03aa31ad82759363ba1a55589e517b16308ef635minfrin }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
c68acc9d712af079afa2bd1a5a4aeef9a3ea573ckess cmd->path = old_path;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->override = old_overrides;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
7b5535ed88e0f561b3bfb3330137bd804846afd4slivestatic const char *ifsection(cmd_parms *cmd, void *mconfig, const char *arg)
7b5535ed88e0f561b3bfb3330137bd804846afd4slive{
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *errmsg;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *endp = ap_strrchr_c(arg, '>');
7b5535ed88e0f561b3bfb3330137bd804846afd4slive int old_overrides = cmd->override;
7b5535ed88e0f561b3bfb3330137bd804846afd4slive char *old_path = cmd->path;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd core_dir_config *conf;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const command_rec *thiscmd = cmd->cmd;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd core_dir_config *c = mconfig;
7b5535ed88e0f561b3bfb3330137bd804846afd4slive ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *err = ap_check_cmd_context(cmd,
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin NOT_IN_LOCATION | NOT_IN_LIMIT);
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin const char *condition;
3621f3acee323a877639a96d84891095eb07933aminfrin const char *expr_err;
3621f3acee323a877639a96d84891095eb07933aminfrin
3621f3acee323a877639a96d84891095eb07933aminfrin if (err != NULL) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return err;
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin }
3621f3acee323a877639a96d84891095eb07933aminfrin
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin if (endp == NULL) {
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return unclosed_directive(cmd);
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin }
3621f3acee323a877639a96d84891095eb07933aminfrin
3621f3acee323a877639a96d84891095eb07933aminfrin arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
03aa31ad82759363ba1a55589e517b16308ef635minfrin
3621f3acee323a877639a96d84891095eb07933aminfrin if (!arg[0]) {
3621f3acee323a877639a96d84891095eb07933aminfrin return missing_container_arg(cmd);
3621f3acee323a877639a96d84891095eb07933aminfrin }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
3621f3acee323a877639a96d84891095eb07933aminfrin condition = ap_getword_conf(cmd->pool, &arg);
3621f3acee323a877639a96d84891095eb07933aminfrin /* Only if not an .htaccess file */
03aa31ad82759363ba1a55589e517b16308ef635minfrin if (!old_path) {
3621f3acee323a877639a96d84891095eb07933aminfrin cmd->override = OR_ALL|ACCESS_CONF;
3621f3acee323a877639a96d84891095eb07933aminfrin }
3621f3acee323a877639a96d84891095eb07933aminfrin
03aa31ad82759363ba1a55589e517b16308ef635minfrin /* initialize our config and fetch it */
03aa31ad82759363ba1a55589e517b16308ef635minfrin conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path,
03aa31ad82759363ba1a55589e517b16308ef635minfrin &core_module, cmd->pool);
03aa31ad82759363ba1a55589e517b16308ef635minfrin
03aa31ad82759363ba1a55589e517b16308ef635minfrin conf->condition = ap_expr_parse_cmd(cmd, condition, &expr_err, NULL);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor if (expr_err) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_psprintf(cmd->pool, "Cannot parse condition clause: %s", expr_err);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
003f0c9fda6664daf5092a0e42f65ede20098153slive
fb77c505254b6e9c925e23e734463e87574f8f40kess errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (errmsg != NULL)
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele return errmsg;
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->d = cmd->path;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->d_is_fnmatch = 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->r = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_add_file_conf(c, new_file_conf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*arg != '\0') {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess "> arguments not supported.", NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->path = old_path;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->override = old_overrides;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic module *find_module(server_rec *s, const char *name)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module *found = ap_find_linked_module(name);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
891df99fdfa41fc8a486568f4d31ddf4a571258adreid /* search prelinked stuff */
891df99fdfa41fc8a486568f4d31ddf4a571258adreid if (!found) {
59368b594c9b09b59ae58c7de26d2d5ce1c99a29takashi ap_module_symbol_t *current = ap_prelinked_module_symbols;
be192cefa381d5bae6868034687471754cb43175sf
891df99fdfa41fc8a486568f4d31ddf4a571258adreid for (; current->name; ++current) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!strcmp(current->name, name)) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive found = current->modp;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive break;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick }
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick /* search dynamic stuff */
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick if (!found) {
9f38f3ec3e8087985d108a24ae796962fef83644takashi APR_OPTIONAL_FN_TYPE(ap_find_loaded_module_symbol) *check_symbol =
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick APR_RETRIEVE_OPTIONAL_FN(ap_find_loaded_module_symbol);
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick if (check_symbol) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor /*
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen * There are two phases where calling ap_find_loaded_module_symbol
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick * is problematic:
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick *
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen * During reading of the config, ap_server_conf is invalid but s
9f38f3ec3e8087985d108a24ae796962fef83644takashi * points to the main server config, if passed from cmd->server
9f38f3ec3e8087985d108a24ae796962fef83644takashi * of an EXEC_ON_READ directive.
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick *
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick * During config parsing, s may be a virtual host that would cause
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick * a segfault in mod_so if passed to ap_find_loaded_module_symbol,
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick * because mod_so's server config for vhosts is initialized later.
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick * But ap_server_conf is already set at this time.
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick *
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick * Therefore we use s if it is not virtual and ap_server_conf if
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor * s is virtual.
85349f40d98fb3fc7a18ef25dc40eaaae6eead1ctakashi */
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener found = check_symbol(s->is_virtual ? ap_server_conf : s, name);
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick }
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick }
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return found;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
003f0c9fda6664daf5092a0e42f65ede20098153slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd const char *endp = ap_strrchr_c(arg, '>');
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int not = (arg[0] == '!');
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd module *found;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (endp == NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return unclosed_directive(cmd);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
130d299c4b2b15be45532a176604c71fdc7bea5bnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (not) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive arg++;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (!arg[0]) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess return missing_container_arg(cmd);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess found = find_module(cmd->server, arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
130d299c4b2b15be45532a176604c71fdc7bea5bnd if ((!not && found) || (not && !found)) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_directive_t *parent = NULL;
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_directive_t *current = NULL;
130d299c4b2b15be45532a176604c71fdc7bea5bnd const char *retval;
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd &current, &parent, "<IfModule");
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd *(ap_directive_t **)mconfig = current;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return retval;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
6c5c651b0b97607b8c8b4965c1385c67699f217fnd else {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd *(ap_directive_t **)mconfig = NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return ap_soak_end_container(cmd, "<IfModule");
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
6c5c651b0b97607b8c8b4965c1385c67699f217fnd
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisdAP_DECLARE(int) ap_exists_config_define(const char *name)
750d12c59545dbbac70390988de94f7e901b08f2niq{
4bb78e7cdd53f50240cff4ad7a97c7ed36483797slive char **defines;
4bb78e7cdd53f50240cff4ad7a97c7ed36483797slive int i;
4bb78e7cdd53f50240cff4ad7a97c7ed36483797slive
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd defines = (char **)ap_server_config_defines->elts;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd for (i = 0; i < ap_server_config_defines->nelts; i++) {
4bb78e7cdd53f50240cff4ad7a97c7ed36483797slive if (strcmp(defines[i], name) == 0) {
4bb78e7cdd53f50240cff4ad7a97c7ed36483797slive return 1;
4bb78e7cdd53f50240cff4ad7a97c7ed36483797slive }
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd }
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd return 0;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd}
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisdstatic const char *start_ifdefine(cmd_parms *cmd, void *dummy, const char *arg)
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd{
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd const char *endp;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd int defined;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd int not = 0;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd endp = ap_strrchr_c(arg, '>');
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd if (endp == NULL) {
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd return unclosed_directive(cmd);
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd }
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd if (arg[0] == '!') {
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd not = 1;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd arg++;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd }
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd if (!arg[0]) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return missing_container_arg(cmd);
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd }
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd defined = ap_exists_config_define(arg);
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd if ((!not && defined) || (not && !defined)) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor ap_directive_t *parent = NULL;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd ap_directive_t *current = NULL;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd const char *retval;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &current, &parent, "<IfDefine");
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *(ap_directive_t **)dummy = current;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return retval;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess else {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd *(ap_directive_t **)dummy = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return ap_soak_end_container(cmd, "<IfDefine");
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* httpd.conf commands... beginning with the <VirtualHost> business */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *virtualhost_section(cmd_parms *cmd, void *dummy,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen const char *arg)
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen{
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess server_rec *main_server = cmd->server, *s;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen const char *errmsg;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *endp = ap_strrchr_c(arg, '>');
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_pool_t *p = cmd->pool;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if (err != NULL) {
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen return err;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen }
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (endp == NULL) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd return unclosed_directive(cmd);
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd
7ef9b6763ad87846cf83c3f71467f43e349d080aerikabele arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if (!arg[0]) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return missing_container_arg(cmd);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
03e0a375c2435102fb2b51e34cccff52acbfddcdnd /* FIXME: There's another feature waiting to happen here -- since you
03e0a375c2435102fb2b51e34cccff52acbfddcdnd can now put multiple addresses/names on a single <VirtualHost>
03e0a375c2435102fb2b51e34cccff52acbfddcdnd you might want to use it to group common definitions and then
03e0a375c2435102fb2b51e34cccff52acbfddcdnd define other "subhosts" with their individual differences. But
03e0a375c2435102fb2b51e34cccff52acbfddcdnd personally I'd rather just do it with a macro preprocessor. -djg */
03e0a375c2435102fb2b51e34cccff52acbfddcdnd if (main_server->is_virtual) {
03e0a375c2435102fb2b51e34cccff52acbfddcdnd return "<VirtualHost> doesn't nest!";
03e0a375c2435102fb2b51e34cccff52acbfddcdnd }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
03e0a375c2435102fb2b51e34cccff52acbfddcdnd errmsg = ap_init_virtual_host(p, arg, main_server, &s);
03e0a375c2435102fb2b51e34cccff52acbfddcdnd if (errmsg) {
03e0a375c2435102fb2b51e34cccff52acbfddcdnd return errmsg;
03e0a375c2435102fb2b51e34cccff52acbfddcdnd }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
03e0a375c2435102fb2b51e34cccff52acbfddcdnd s->next = main_server->next;
03e0a375c2435102fb2b51e34cccff52acbfddcdnd main_server->next = s;
03e0a375c2435102fb2b51e34cccff52acbfddcdnd
03e0a375c2435102fb2b51e34cccff52acbfddcdnd s->defn_name = cmd->directive->filename;
03e0a375c2435102fb2b51e34cccff52acbfddcdnd s->defn_line_number = cmd->directive->line_num;
03e0a375c2435102fb2b51e34cccff52acbfddcdnd
03e0a375c2435102fb2b51e34cccff52acbfddcdnd cmd->server = s;
03e0a375c2435102fb2b51e34cccff52acbfddcdnd
03e0a375c2435102fb2b51e34cccff52acbfddcdnd errmsg = ap_walk_config(cmd->directive->first_child, cmd,
03e0a375c2435102fb2b51e34cccff52acbfddcdnd s->lookup_defaults);
03e0a375c2435102fb2b51e34cccff52acbfddcdnd
03e0a375c2435102fb2b51e34cccff52acbfddcdnd cmd->server = main_server;
03e0a375c2435102fb2b51e34cccff52acbfddcdnd
03e0a375c2435102fb2b51e34cccff52acbfddcdnd return errmsg;
03e0a375c2435102fb2b51e34cccff52acbfddcdnd}
03e0a375c2435102fb2b51e34cccff52acbfddcdnd
03e0a375c2435102fb2b51e34cccff52acbfddcdndstatic const char *set_server_alias(cmd_parms *cmd, void *dummy,
03e0a375c2435102fb2b51e34cccff52acbfddcdnd const char *arg)
03e0a375c2435102fb2b51e34cccff52acbfddcdnd{
03e0a375c2435102fb2b51e34cccff52acbfddcdnd if (!cmd->server->names) {
03e0a375c2435102fb2b51e34cccff52acbfddcdnd return "ServerAlias only used in <VirtualHost>";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while (*arg) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char **item, *name = ap_getword_conf(cmd->pool, &arg);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (ap_is_matchexp(name)) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive item = (char **)apr_array_push(cmd->server->wild_names);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
003f0c9fda6664daf5092a0e42f65ede20098153slive item = (char **)apr_array_push(cmd->server->names);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd *item = name;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
6fad623c3cc52b4a84d4d36538f6eed886f49f98covener
6fad623c3cc52b4a84d4d36538f6eed886f49f98covener return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_accf_map(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *iproto, const char* iaccf)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(cmd->server->module_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char* proto;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess char* accf;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (err != NULL) {
fb77c505254b6e9c925e23e734463e87574f8f40kess return err;
fb77c505254b6e9c925e23e734463e87574f8f40kess }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive proto = apr_pstrdup(cmd->pool, iproto);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_str_tolower(proto);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive accf = apr_pstrdup(cmd->pool, iaccf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_str_tolower(accf);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen apr_table_setn(conf->accf_map, proto, accf);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess return NULL;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen}
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowenAP_DECLARE(const char*) ap_get_server_protocol(server_rec* s)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd{
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen core_server_config *conf = ap_get_module_config(s->module_config,
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor &core_module);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return conf->protocol;
6fad623c3cc52b4a84d4d36538f6eed886f49f98covener}
6fad623c3cc52b4a84d4d36538f6eed886f49f98covener
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowenAP_DECLARE(void) ap_set_server_protocol(server_rec* s, const char* proto)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(s->module_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->protocol = proto;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_protocol(cmd_parms *cmd, void *dummy,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
e0ef044feba0082771091af42798cada5bb1f4fcrbowen const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(cmd->server->module_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd char* proto;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (err != NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return err;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive proto = apr_pstrdup(cmd->pool, arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_str_tolower(proto);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->protocol = proto;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_server_string_slot(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* This one's pretty generic... */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int offset = (int)(long)cmd->info;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *struct_ptr = (char *)cmd->server;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen NOT_IN_DIR_LOC_FILE);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if (err != NULL) {
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen return err;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen *(const char **)(struct_ptr + offset) = arg;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen return NULL;
2f505ba07f89ba6a175d6ceae67fb273c4eb0993covener}
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covener/*
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener * The ServerName directive takes one argument with format
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covener * [scheme://]fully-qualified-domain-name[:port], for instance
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covener * ServerName www.example.com
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * ServerName www.example.com:80
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * ServerName https://www.example.com:443
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *server_hostname_port(cmd_parms *cmd, void *dummy, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
ae134ecc8faf4e6a8eb68e1c3724506771442a46rbowen const char *portstr, *part;
ae134ecc8faf4e6a8eb68e1c3724506771442a46rbowen char *scheme;
e0ef044feba0082771091af42798cada5bb1f4fcrbowen int port;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (err != NULL) {
72580dbc2a55511f13f377063725b9f143b20826stoddard return err;
72580dbc2a55511f13f377063725b9f143b20826stoddard }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess part = ap_strstr_c(arg, "://");
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
72580dbc2a55511f13f377063725b9f143b20826stoddard if (part) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor scheme = apr_pstrndup(cmd->pool, arg, part - arg);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor ap_str_tolower(scheme);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor cmd->server->server_scheme = (const char *)scheme;
72580dbc2a55511f13f377063725b9f143b20826stoddard part += 3;
56d7eed7205462540aec7202cd82d9f5516fc537kess } else {
72580dbc2a55511f13f377063725b9f143b20826stoddard part = arg;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive portstr = ap_strchr_c(part, ':');
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if (portstr) {
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen cmd->server->server_hostname = apr_pstrndup(cmd->pool, part,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen portstr - part);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen portstr++;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen port = atoi(portstr);
ef8e89e090461194ecadd31e8796a2c51e0531a2kess if (port <= 0 || port >= 65536) { /* 65536 == 1<<16 */
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen return apr_pstrcat(cmd->temp_pool, "The port number \"", arg,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen "\" is outside the appropriate range "
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen "(i.e., 1..65535).", NULL);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen }
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen }
2f505ba07f89ba6a175d6ceae67fb273c4eb0993covener else {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor cmd->server->server_hostname = apr_pstrdup(cmd->pool, part);
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener port = 0;
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener }
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covener
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->server->port = port;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_signature_flag(cmd_parms *cmd, void *d_,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd core_dir_config *d = d_;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
e0ef044feba0082771091af42798cada5bb1f4fcrbowen if (strcasecmp(arg, "On") == 0) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->server_signature = srv_sig_on;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor else if (strcasecmp(arg, "Off") == 0) {
72580dbc2a55511f13f377063725b9f143b20826stoddard d->server_signature = srv_sig_off;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (strcasecmp(arg, "EMail") == 0) {
72580dbc2a55511f13f377063725b9f143b20826stoddard d->server_signature = srv_sig_withmail;
72580dbc2a55511f13f377063725b9f143b20826stoddard }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "ServerSignature: use one of: off | on | email";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
fb77c505254b6e9c925e23e734463e87574f8f40kess}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_server_root(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen{
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if (err != NULL) {
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen return err;
ef8e89e090461194ecadd31e8796a2c51e0531a2kess }
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if ((apr_filepath_merge((char**)&ap_server_root, NULL, arg,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS)
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen || !ap_is_directory(cmd->temp_pool, ap_server_root)) {
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covener return "ServerRoot must be a valid directory";
2f505ba07f89ba6a175d6ceae67fb273c4eb0993covener }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener return NULL;
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener}
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covener
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covenerstatic const char *set_timeout(cmd_parms *cmd, void *dummy, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (err != NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return err;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive cmd->server->timeout = apr_time_from_sec(atoi(arg));
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele return NULL;
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele}
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_allow2f(cmd_parms *cmd, void *d_, int arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *d = d_;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen d->allow_encoded_slashes = arg != 0;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen return NULL;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen}
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *set_hostname_lookups(cmd_parms *cmd, void *d_,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen const char *arg)
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *d = d_;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!strcasecmp(arg, "on")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->hostname_lookups = HOSTNAME_LOOKUP_ON;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (!strcasecmp(arg, "off")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->hostname_lookups = HOSTNAME_LOOKUP_OFF;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
fb77c505254b6e9c925e23e734463e87574f8f40kess else if (!strcasecmp(arg, "double")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->hostname_lookups = HOSTNAME_LOOKUP_DOUBLE;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "parameter must be 'on', 'off', or 'double'";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
7852e17fb37b2a02ccdcab107f2c7f5fd41fd201nd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_serverpath(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (err != NULL) {
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive return err;
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive }
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive cmd->server->path = arg;
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive cmd->server->pathlen = (int)strlen(arg);
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive return NULL;
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive}
d950cf9262224a223e2ff5c51393708071e14b94covener
d950cf9262224a223e2ff5c51393708071e14b94covenerstatic const char *set_content_md5(cmd_parms *cmd, void *d_, int arg)
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic{
d950cf9262224a223e2ff5c51393708071e14b94covener core_dir_config *d = d_;
d950cf9262224a223e2ff5c51393708071e14b94covener
d950cf9262224a223e2ff5c51393708071e14b94covener d->content_md5 = arg != 0;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return NULL;
d950cf9262224a223e2ff5c51393708071e14b94covener}
d950cf9262224a223e2ff5c51393708071e14b94covener
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorstatic const char *set_accept_path_info(cmd_parms *cmd, void *d_, const char *arg)
d950cf9262224a223e2ff5c51393708071e14b94covener{
d950cf9262224a223e2ff5c51393708071e14b94covener core_dir_config *d = d_;
d950cf9262224a223e2ff5c51393708071e14b94covener
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic if (strcasecmp(arg, "on") == 0) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor d->accept_path_info = AP_REQ_ACCEPT_PATH_INFO;
d950cf9262224a223e2ff5c51393708071e14b94covener }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor else if (strcasecmp(arg, "off") == 0) {
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic d->accept_path_info = AP_REQ_REJECT_PATH_INFO;
d950cf9262224a223e2ff5c51393708071e14b94covener }
d950cf9262224a223e2ff5c51393708071e14b94covener else if (strcasecmp(arg, "default") == 0) {
d950cf9262224a223e2ff5c51393708071e14b94covener d->accept_path_info = AP_REQ_DEFAULT_PATH_INFO;
d950cf9262224a223e2ff5c51393708071e14b94covener }
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic else {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return "AcceptPathInfo must be set to on, off or default";
d950cf9262224a223e2ff5c51393708071e14b94covener }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
e4e60c2f7ba8f12b687f588b89e413842e9f2d76igalic return NULL;
d950cf9262224a223e2ff5c51393708071e14b94covener}
d950cf9262224a223e2ff5c51393708071e14b94covener
d950cf9262224a223e2ff5c51393708071e14b94covenerstatic const char *set_use_canonical_name(cmd_parms *cmd, void *d_,
d950cf9262224a223e2ff5c51393708071e14b94covener const char *arg)
d950cf9262224a223e2ff5c51393708071e14b94covener{
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor core_dir_config *d = d_;
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive if (strcasecmp(arg, "on") == 0) {
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive d->use_canonical_name = USE_CANONICAL_NAME_ON;
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive }
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive else if (strcasecmp(arg, "off") == 0) {
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive d->use_canonical_name = USE_CANONICAL_NAME_OFF;
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor else if (strcasecmp(arg, "dns") == 0) {
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive d->use_canonical_name = USE_CANONICAL_NAME_DNS;
234c8b28171d7e12b3c1f85b60fabd7c908a9c37slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
dc223428958ad9ff05011545bcdda000887b93e5slive return "parameter must be 'on', 'off', or 'dns'";
beb923bec9bff2b49ce5027df2fe944e2b74e28brederpj }
beb923bec9bff2b49ce5027df2fe944e2b74e28brederpj
dc223428958ad9ff05011545bcdda000887b93e5slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_use_canonical_phys_port(cmd_parms *cmd, void *d_,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess const char *arg)
fb77c505254b6e9c925e23e734463e87574f8f40kess{
d8c44cd75cf575fe51319280c12445109e878523noodl core_dir_config *d = d_;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
030108b1816bcda3d925df65357feabdce83bc94slive if (strcasecmp(arg, "on") == 0) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor d->use_canonical_phys_port = USE_CANONICAL_PHYS_PORT_ON;
37742b630743e470b94618ecb3560fbd82e50b59rbowen }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else if (strcasecmp(arg, "off") == 0) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd d->use_canonical_phys_port = USE_CANONICAL_PHYS_PORT_OFF;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "parameter must be 'on' or 'off'";
fb77c505254b6e9c925e23e734463e87574f8f40kess }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess return NULL;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess}
37742b630743e470b94618ecb3560fbd82e50b59rbowen
37742b630743e470b94618ecb3560fbd82e50b59rbowenstatic const char *include_config (cmd_parms *cmd, void *dummy,
37742b630743e470b94618ecb3560fbd82e50b59rbowen const char *name)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_directive_t *conftree = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *conffile, *error;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive unsigned *recursion;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int optional = cmd->cmd->cmd_data ? 1 : 0;
e8811b6d38f756b325446ded5d96857d13856511takashi void *data;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd apr_pool_userdata_get(&data, "ap_include_sentinel", cmd->pool);
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (data) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd recursion = data;
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
ca908c21f63a71c5efa7d32bd2cfafe9a42ba1fbrbowen else {
130d299c4b2b15be45532a176604c71fdc7bea5bnd data = recursion = apr_palloc(cmd->pool, sizeof(*recursion));
130d299c4b2b15be45532a176604c71fdc7bea5bnd *recursion = 0;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd apr_pool_userdata_setn(data, "ap_include_sentinel", NULL, cmd->pool);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (++*recursion > AP_MAX_INCLUDE_DEPTH) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd *recursion = 0;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return apr_psprintf(cmd->pool, "Exceeded maximum include depth of %u, "
05201775eaa6b363b8a119c8aea5db246b967591yoshiki "There appears to be a recursion.",
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd AP_MAX_INCLUDE_DEPTH);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conffile = ap_server_root_relative(cmd->pool, name);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (!conffile) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess *recursion = 0;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return apr_pstrcat(cmd->pool, "Invalid Include path ",
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd name, NULL);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd error = ap_process_fnmatch_configs(cmd->server, conffile, &conftree,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd cmd->pool, cmd->temp_pool,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd optional);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (error) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd *recursion = 0;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return error;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess *(ap_directive_t **)dummy = conftree;
37742b630743e470b94618ecb3560fbd82e50b59rbowen
37742b630743e470b94618ecb3560fbd82e50b59rbowen /* recursion level done */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*recursion) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive --*recursion;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
8490b2f9f6469d5089163f6dd303d9a81f8e908ctrawickstatic const char *set_loglevel(cmd_parms *cmd, void *config_, const char *arg_)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *level_str;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int level;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module *module;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *arg = apr_pstrdup(cmd->temp_pool, arg_);
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess struct ap_logconf *log;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess const char *err;
030108b1816bcda3d925df65357feabdce83bc94slive
030108b1816bcda3d925df65357feabdce83bc94slive /* XXX: what check is necessary here? */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#if 0
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (err != NULL) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return err;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd#endif
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (cmd->path) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *dconf = config_;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (!dconf->log) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess dconf->log = ap_new_log_config(cmd->pool, NULL);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive log = dconf->log;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive log = &cmd->server->log;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sf if (arg == NULL)
7fbd7281d06cec1918aa370214df77c572f871a9sf return "LogLevel requires level keyword or module loglevel specifier";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive level_str = ap_strchr(arg, ':');
7fbd7281d06cec1918aa370214df77c572f871a9sf
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (level_str == NULL) {
7fbd7281d06cec1918aa370214df77c572f871a9sf err = ap_parse_log_level(arg, &log->level);
7fbd7281d06cec1918aa370214df77c572f871a9sf if (err != NULL)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return err;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_reset_module_loglevels(log, APLOG_NO_MODULE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Setting LogLevel for all modules to %s", arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *level_str++ = '\0';
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if (!*level_str) {
1597043cec6ad37fa4154bf09b0fccdabed1a239slive return apr_psprintf(cmd->temp_pool, "Module specifier '%s' must be "
1597043cec6ad37fa4154bf09b0fccdabed1a239slive "followed by a log level keyword", arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
530eba85dbd41b8a0fa5255d3648d1440199a661slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive err = ap_parse_log_level(level_str, &level);
530eba85dbd41b8a0fa5255d3648d1440199a661slive if (err != NULL)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_psprintf(cmd->temp_pool, "%s:%s: %s", arg, level_str, err);
530eba85dbd41b8a0fa5255d3648d1440199a661slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if ((module = find_module(cmd->server, arg)) == NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *name = apr_psprintf(cmd->temp_pool, "%s_module", arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_error(APLOG_MARK, APLOG_TRACE6, 0, cmd->server,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Cannot find module '%s', trying '%s'", arg, name);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive module = find_module(cmd->server, name);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (module == NULL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_psprintf(cmd->temp_pool, "Cannot find module %s", arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_set_module_loglevel(cmd->pool, log, module->module_index, level);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Setting LogLevel for module %s to %s", module->name,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive level_str);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char sport[20];
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *conf;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if ((conf->server_signature == srv_sig_off)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive || (conf->server_signature == srv_sig_unset)) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_snprintf(sport, sizeof sport, "%u", (unsigned) ap_get_server_port(r));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (conf->server_signature == srv_sig_withmail) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(r->pool, prefix, "<address>",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_get_server_banner(),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive " Server at <a href=\"",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_is_url(r->server->server_admin) ? "" : "mailto:",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_escape_html(r->pool, r->server->server_admin),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "\">",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_escape_html(r->pool, ap_get_server_name(r)),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "</a> Port ", sport,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "</address>\n", NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(r->pool, prefix, "<address>", ap_get_server_banner(),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive " Server at ",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_escape_html(r->pool, ap_get_server_name(r)),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive " Port ", sport,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "</address>\n", NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/*
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Handle a request to include the server's OS platform in the Server
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * response header field (the ServerTokens directive). Unfortunately
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * this requires a new global in order to communicate the setting back to
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * http_main so it can insert the information in the right place in the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * string.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic char *server_banner = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int banner_locked = 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *server_description = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveenum server_token_type {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive SrvTk_MAJOR, /* eg: Apache/2 */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive SrvTk_MINOR, /* eg. Apache/2.0 */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive SrvTk_MINIMAL, /* eg: Apache/2.0.41 */
7fbd7281d06cec1918aa370214df77c572f871a9sf SrvTk_OS, /* eg: Apache/2.0.41 (UNIX) */
7fbd7281d06cec1918aa370214df77c572f871a9sf SrvTk_FULL, /* eg: Apache/2.0.41 (UNIX) PHP/4.2.2 FooBar/1.2b */
7fbd7281d06cec1918aa370214df77c572f871a9sf SrvTk_PRODUCT_ONLY /* eg: Apache */
7fbd7281d06cec1918aa370214df77c572f871a9sf};
7fbd7281d06cec1918aa370214df77c572f871a9sfstatic enum server_token_type ap_server_tokens = SrvTk_FULL;
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sfstatic apr_status_t reset_banner(void *dummy)
7fbd7281d06cec1918aa370214df77c572f871a9sf{
7fbd7281d06cec1918aa370214df77c572f871a9sf banner_locked = 0;
7fbd7281d06cec1918aa370214df77c572f871a9sf ap_server_tokens = SrvTk_FULL;
7fbd7281d06cec1918aa370214df77c572f871a9sf server_banner = NULL;
7fbd7281d06cec1918aa370214df77c572f871a9sf server_description = NULL;
7fbd7281d06cec1918aa370214df77c572f871a9sf return APR_SUCCESS;
7fbd7281d06cec1918aa370214df77c572f871a9sf}
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sfAP_DECLARE(void) ap_get_server_revision(ap_version_t *version)
7fbd7281d06cec1918aa370214df77c572f871a9sf{
7fbd7281d06cec1918aa370214df77c572f871a9sf version->major = AP_SERVER_MAJORVERSION_NUMBER;
7fbd7281d06cec1918aa370214df77c572f871a9sf version->minor = AP_SERVER_MINORVERSION_NUMBER;
7fbd7281d06cec1918aa370214df77c572f871a9sf version->patch = AP_SERVER_PATCHLEVEL_NUMBER;
7fbd7281d06cec1918aa370214df77c572f871a9sf version->add_string = AP_SERVER_ADD_STRING;
7fbd7281d06cec1918aa370214df77c572f871a9sf}
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sfAP_DECLARE(const char *) ap_get_server_description(void)
7fbd7281d06cec1918aa370214df77c572f871a9sf{
7fbd7281d06cec1918aa370214df77c572f871a9sf return server_description ? server_description :
7fbd7281d06cec1918aa370214df77c572f871a9sf AP_SERVER_BASEVERSION " (" PLATFORM ")";
7fbd7281d06cec1918aa370214df77c572f871a9sf}
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sfAP_DECLARE(const char *) ap_get_server_banner(void)
7fbd7281d06cec1918aa370214df77c572f871a9sf{
7fbd7281d06cec1918aa370214df77c572f871a9sf return server_banner ? server_banner : AP_SERVER_BASEVERSION;
7fbd7281d06cec1918aa370214df77c572f871a9sf}
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sfAP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *component)
7fbd7281d06cec1918aa370214df77c572f871a9sf{
7fbd7281d06cec1918aa370214df77c572f871a9sf if (! banner_locked) {
7fbd7281d06cec1918aa370214df77c572f871a9sf /*
7fbd7281d06cec1918aa370214df77c572f871a9sf * If the version string is null, register our cleanup to reset the
7fbd7281d06cec1918aa370214df77c572f871a9sf * pointer on pool destruction. We also know that, if NULL,
7fbd7281d06cec1918aa370214df77c572f871a9sf * we are adding the original SERVER_BASEVERSION string.
7fbd7281d06cec1918aa370214df77c572f871a9sf */
7fbd7281d06cec1918aa370214df77c572f871a9sf if (server_banner == NULL) {
7fbd7281d06cec1918aa370214df77c572f871a9sf apr_pool_cleanup_register(pconf, NULL, reset_banner,
7fbd7281d06cec1918aa370214df77c572f871a9sf apr_pool_cleanup_null);
7fbd7281d06cec1918aa370214df77c572f871a9sf server_banner = apr_pstrdup(pconf, component);
7fbd7281d06cec1918aa370214df77c572f871a9sf }
7fbd7281d06cec1918aa370214df77c572f871a9sf else {
7fbd7281d06cec1918aa370214df77c572f871a9sf /*
7fbd7281d06cec1918aa370214df77c572f871a9sf * Tack the given component identifier to the end of
7fbd7281d06cec1918aa370214df77c572f871a9sf * the existing string.
7fbd7281d06cec1918aa370214df77c572f871a9sf */
7fbd7281d06cec1918aa370214df77c572f871a9sf server_banner = apr_pstrcat(pconf, server_banner, " ",
7fbd7281d06cec1918aa370214df77c572f871a9sf component, NULL);
7fbd7281d06cec1918aa370214df77c572f871a9sf }
7fbd7281d06cec1918aa370214df77c572f871a9sf }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive server_description = apr_pstrcat(pconf, server_description, " ",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive component, NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/*
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * This routine adds the real server base identity to the banner string,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * and then locks out changes until the next reconfig.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic void set_banner(apr_pool_t *pconf)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if (ap_server_tokens == SrvTk_PRODUCT_ONLY) {
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen ap_add_version_component(pconf, AP_SERVER_BASEPRODUCT);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else if (ap_server_tokens == SrvTk_MINIMAL) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_add_version_component(pconf, AP_SERVER_BASEVERSION);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
8b052d682204371decc64f942aede5ef1da98955erikabele else if (ap_server_tokens == SrvTk_MINOR) {
8b052d682204371decc64f942aede5ef1da98955erikabele ap_add_version_component(pconf, AP_SERVER_BASEPRODUCT "/" AP_SERVER_MINORREVISION);
8b052d682204371decc64f942aede5ef1da98955erikabele }
8b052d682204371decc64f942aede5ef1da98955erikabele else if (ap_server_tokens == SrvTk_MAJOR) {
8b052d682204371decc64f942aede5ef1da98955erikabele ap_add_version_component(pconf, AP_SERVER_BASEPRODUCT "/" AP_SERVER_MAJORVERSION);
8b052d682204371decc64f942aede5ef1da98955erikabele }
8b052d682204371decc64f942aede5ef1da98955erikabele else {
7fbd7281d06cec1918aa370214df77c572f871a9sf ap_add_version_component(pconf, AP_SERVER_BASEVERSION " (" PLATFORM ")");
7fbd7281d06cec1918aa370214df77c572f871a9sf }
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sf /*
7fbd7281d06cec1918aa370214df77c572f871a9sf * Lock the server_banner string if we're not displaying
fd410ae1fa431e734e6d0cd3c006002d4904466apoirier * the full set of tokens
7fbd7281d06cec1918aa370214df77c572f871a9sf */
7fbd7281d06cec1918aa370214df77c572f871a9sf if (ap_server_tokens != SrvTk_FULL) {
7fbd7281d06cec1918aa370214df77c572f871a9sf banner_locked++;
7fbd7281d06cec1918aa370214df77c572f871a9sf }
7fbd7281d06cec1918aa370214df77c572f871a9sf server_description = AP_SERVER_BASEVERSION " (" PLATFORM ")";
7fbd7281d06cec1918aa370214df77c572f871a9sf}
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sfstatic const char *set_serv_tokens(cmd_parms *cmd, void *dummy,
7fbd7281d06cec1918aa370214df77c572f871a9sf const char *arg1, const char *arg2)
7fbd7281d06cec1918aa370214df77c572f871a9sf{
7fbd7281d06cec1918aa370214df77c572f871a9sf const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sf if (err != NULL) {
7fbd7281d06cec1918aa370214df77c572f871a9sf return err;
7fbd7281d06cec1918aa370214df77c572f871a9sf }
7fbd7281d06cec1918aa370214df77c572f871a9sf
7fbd7281d06cec1918aa370214df77c572f871a9sf if (!strcasecmp(arg1, "OS")) {
7fbd7281d06cec1918aa370214df77c572f871a9sf ap_server_tokens = SrvTk_OS;
7fbd7281d06cec1918aa370214df77c572f871a9sf }
7fbd7281d06cec1918aa370214df77c572f871a9sf else if (!strcasecmp(arg1, "Min") || !strcasecmp(arg1, "Minimal")) {
7fbd7281d06cec1918aa370214df77c572f871a9sf ap_server_tokens = SrvTk_MINIMAL;
7fbd7281d06cec1918aa370214df77c572f871a9sf }
7fbd7281d06cec1918aa370214df77c572f871a9sf else if (!strcasecmp(arg1, "Major")) {
7fbd7281d06cec1918aa370214df77c572f871a9sf ap_server_tokens = SrvTk_MAJOR;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (!strcasecmp(arg1, "Minor") ) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_server_tokens = SrvTk_MINOR;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (!strcasecmp(arg1, "Prod") || !strcasecmp(arg1, "ProductOnly")) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess ap_server_tokens = SrvTk_PRODUCT_ONLY;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_server_tokens = SrvTk_FULL;
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele }
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_limit_req_line(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
fb77c505254b6e9c925e23e734463e87574f8f40kess{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int lim;
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if (err != NULL) {
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen return err;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd lim = atoi(arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (lim < 0) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->temp_pool, "LimitRequestLine \"", arg,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "\" must be a non-negative integer", NULL);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick }
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick cmd->server->limit_req_line = lim;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return NULL;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick}
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_req_fieldsize(cmd_parms *cmd, void *dummy,
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen const char *arg)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick int lim;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (err != NULL) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return err;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick }
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick lim = atoi(arg);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (lim < 0) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return apr_pstrcat(cmd->temp_pool, "LimitRequestFieldsize \"", arg,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick "\" must be a non-negative integer",
a0fed3e26656887c8458aa1081d516d08ced3c84trawick NULL);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick }
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick cmd->server->limit_req_fieldsize = lim;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return NULL;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_req_fields(cmd_parms *cmd, void *dummy,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick int lim;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (err != NULL) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return err;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick }
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick lim = atoi(arg);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (lim < 0) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return apr_pstrcat(cmd->temp_pool, "LimitRequestFields \"", arg,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick "\" must be a non-negative integer (0 = no limit)",
a0fed3e26656887c8458aa1081d516d08ced3c84trawick NULL);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick }
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor
a0fed3e26656887c8458aa1081d516d08ced3c84trawick cmd->server->limit_req_fields = lim;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return NULL;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_req_body(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick core_dir_config *conf = conf_;
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick char *errp;
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick if (APR_SUCCESS != apr_strtoff(&conf->limit_req_body, arg, &errp, 10)) {
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick return "LimitRequestBody argument is not parsable.";
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick }
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick if (*errp || conf->limit_req_body < 0) {
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick return "LimitRequestBody requires a non-negative integer.";
a0fed3e26656887c8458aa1081d516d08ced3c84trawick }
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return NULL;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorstatic const char *set_limit_xml_req_body(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick core_dir_config *conf = conf_;
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick conf->limit_xml_body = atol(arg);
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick if (conf->limit_xml_body < 0)
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick return "LimitXMLRequestBody requires a non-negative integer.";
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick return NULL;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawickAP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick core_dir_config *conf;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick conf = ap_get_module_config(r->per_dir_config, &core_module);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (conf->limit_xml_body == AP_LIMIT_UNSET)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return AP_DEFAULT_LIMIT_XML_BODY;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return (size_t)conf->limit_xml_body;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#if !defined (RLIMIT_CPU) || !(defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)) || !defined (RLIMIT_NPROC)
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *no_set_limit(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg, const char *arg2)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_log_error(APLOG_MARK, APLOG_ERR, 0, cmd->server,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick "%s not supported on this platform", cmd->cmd->name);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return NULL;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#endif
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#ifdef RLIMIT_CPU
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorstatic const char *set_limit_cpu(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg, const char *arg2)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick core_dir_config *conf = conf_;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_unixd_set_rlimit(cmd, &conf->limit_cpu, arg, arg2, RLIMIT_CPU);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return NULL;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#endif
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_mem(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg, const char * arg2)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick core_dir_config *conf = conf_;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#if defined(RLIMIT_AS)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2 ,RLIMIT_AS);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#elif defined(RLIMIT_DATA)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_DATA);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#elif defined(RLIMIT_VMEM)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_VMEM);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor#endif
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
215694531f7d868b906df96e22a80e6a1d2326a6lgentis return NULL;
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#endif
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#ifdef RLIMIT_NPROC
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_nproc(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg, const char * arg2)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick core_dir_config *conf = conf_;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick ap_unixd_set_rlimit(cmd, &conf->limit_nproc, arg, arg2, RLIMIT_NPROC);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return NULL;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick}
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#endif
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_recursion_limit(cmd_parms *cmd, void *dummy,
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor const char *arg1, const char *arg2)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick{
a0fed3e26656887c8458aa1081d516d08ced3c84trawick core_server_config *conf = ap_get_module_config(cmd->server->module_config,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick &core_module);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick int limit = atoi(arg1);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (limit <= 0) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return "The recursion limit must be greater than zero.";
a0fed3e26656887c8458aa1081d516d08ced3c84trawick }
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (limit < 4) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick "Limiting internal redirects to very low numbers may "
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick "cause normal requests to fail.");
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick }
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick conf->redirect_limit = limit;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick if (arg2) {
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick limit = atoi(arg2);
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick if (limit <= 0) {
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick return "The recursion limit must be greater than zero.";
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick }
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick if (limit < 4) {
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick "Limiting the subrequest depth to a very low level may"
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick " cause normal requests to fail.");
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick }
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick }
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick conf->subreq_limit = limit;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick return NULL;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick}
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawickstatic void log_backtrace(const request_rec *r)
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick{
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick const request_rec *top = r;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick "r->uri = %s", r->uri ? r->uri : "(unexpectedly NULL)");
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick while (top && (top->prev || top->main)) {
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick if (top->prev) {
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick top = top->prev;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick "redirected from r->uri = %s",
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick top->uri ? top->uri : "(unexpectedly NULL)");
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick }
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick if (!top->prev && top->main) {
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick top = top->main;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick "subrequested from r->uri = %s",
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick top->uri ? top->uri : "(unexpectedly NULL)");
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick }
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick }
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick}
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick/*
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick * check whether redirect limit is reached
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick */
2b6c7b8eb5fbc43564898aedac730df7e91da475trawickAP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r)
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick{
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick core_server_config *conf = ap_get_module_config(r->server->module_config,
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick &core_module);
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick const request_rec *top = r;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick int redirects = 0, subreqs = 0;
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick int rlimit = conf->redirect_limit
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ? conf->redirect_limit
a0fed3e26656887c8458aa1081d516d08ced3c84trawick : AP_DEFAULT_MAX_INTERNAL_REDIRECTS;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick int slimit = conf->subreq_limit
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ? conf->subreq_limit
a0fed3e26656887c8458aa1081d516d08ced3c84trawick : AP_DEFAULT_MAX_SUBREQ_DEPTH;
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick
a0fed3e26656887c8458aa1081d516d08ced3c84trawick while (top->prev || top->main) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (top->prev) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (++redirects >= rlimit) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick /* uuh, too much. */
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick "Request exceeded the limit of %d internal "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "redirects due to probable configuration error. "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Use 'LimitInternalRecursion' to increase the "
003f0c9fda6664daf5092a0e42f65ede20098153slive "limit if necessary. Use 'LogLevel debug' to get "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "a backtrace.", rlimit);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* post backtrace */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive log_backtrace(r);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* return failure */
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener return 1;
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener }
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener top = top->prev;
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener }
fb77c505254b6e9c925e23e734463e87574f8f40kess
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener if (!top->prev && top->main) {
3386d67e54f92fdf6a3ffc5f7f8081eed6c44badslive if (++subreqs >= slimit) {
3386d67e54f92fdf6a3ffc5f7f8081eed6c44badslive /* uuh, too much. */
05201775eaa6b363b8a119c8aea5db246b967591yoshiki ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen "Request exceeded the limit of %d subrequest "
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen "nesting levels due to probable configuration "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "error. Use 'LimitInternalRecursion' to increase "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "the limit if necessary. Use 'LogLevel debug' to "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "get a backtrace.", slimit);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* post backtrace */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive log_backtrace(r);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* return failure */
9e0536cd66a389bdaa758a825b8bbd8fea665a3eigalic return 1;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive top = top->main;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
9e0536cd66a389bdaa758a825b8bbd8fea665a3eigalic }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* recursion state: ok */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *set_trace_enable(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg1)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(cmd->server->module_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (strcasecmp(arg1, "on") == 0) {
9e0536cd66a389bdaa758a825b8bbd8fea665a3eigalic conf->trace_enable = AP_TRACE_ENABLE;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess else if (strcasecmp(arg1, "off") == 0) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->trace_enable = AP_TRACE_DISABLE;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
13e5182a0c199ecc7a73db97b6448a544e940868slive else if (strcasecmp(arg1, "extended") == 0) {
13e5182a0c199ecc7a73db97b6448a544e940868slive conf->trace_enable = AP_TRACE_EXTENDED;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "TraceEnable must be one of 'on', 'off', or 'extended'";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
9e0536cd66a389bdaa758a825b8bbd8fea665a3eigalic
9e0536cd66a389bdaa758a825b8bbd8fea665a3eigalic return NULL;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd}
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic apr_hash_t *errorlog_hash;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic int log_constant_item(const ap_errorlog_info *info, const char *arg,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd char *buf, int buflen)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd{
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive char *end = apr_cpystrn(buf, arg, buflen);
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive return end - buf;
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive}
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic char *parse_errorlog_misc_string(apr_pool_t *p,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess ap_errorlog_format_item *it,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char **sa)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
13e5182a0c199ecc7a73db97b6448a544e940868slive const char *s;
13e5182a0c199ecc7a73db97b6448a544e940868slive char scratch[MAX_STRING_LEN];
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *d = scratch;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess /*
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * non-leading white space terminates this string to allow the next field
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * separator to be inserted
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
13e5182a0c199ecc7a73db97b6448a544e940868slive int at_start = 1;
13e5182a0c199ecc7a73db97b6448a544e940868slive
13e5182a0c199ecc7a73db97b6448a544e940868slive it->func = log_constant_item;
b00583f8e126bbb00b06dcf06af06c9d07978701kess s = *sa;
13e5182a0c199ecc7a73db97b6448a544e940868slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while (*s && *s != '%' && (*s != ' ' || at_start) && d < scratch + MAX_STRING_LEN) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (*s != '\\') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*s != ' ') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive at_start = 0;
0d5b778ac63bc803c0dd1a4fdef371fe7a0f4b57kess }
13e5182a0c199ecc7a73db97b6448a544e940868slive *d++ = *s++;
13e5182a0c199ecc7a73db97b6448a544e940868slive }
13e5182a0c199ecc7a73db97b6448a544e940868slive else {
13e5182a0c199ecc7a73db97b6448a544e940868slive s++;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive switch (*s) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess case 'r':
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *d++ = '\r';
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive s++;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive break;
13e5182a0c199ecc7a73db97b6448a544e940868slive case 'n':
96969ed53a757bd9e0a4d7f2f499c9db5ef7899eigalic *d++ = '\n';
96969ed53a757bd9e0a4d7f2f499c9db5ef7899eigalic s++;
96969ed53a757bd9e0a4d7f2f499c9db5ef7899eigalic break;
96969ed53a757bd9e0a4d7f2f499c9db5ef7899eigalic case 't':
96969ed53a757bd9e0a4d7f2f499c9db5ef7899eigalic *d++ = '\t';
96969ed53a757bd9e0a4d7f2f499c9db5ef7899eigalic s++;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive break;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess case '\0':
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* handle end of string */
13e5182a0c199ecc7a73db97b6448a544e940868slive *d++ = '\\';
13e5182a0c199ecc7a73db97b6448a544e940868slive break;
13e5182a0c199ecc7a73db97b6448a544e940868slive default:
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* copy next char verbatim */
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive *d++ = *s++;
13e5182a0c199ecc7a73db97b6448a544e940868slive break;
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive }
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive }
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive }
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive *d = '\0';
13e5182a0c199ecc7a73db97b6448a544e940868slive it->arg = apr_pstrdup(p, scratch);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
13e5182a0c199ecc7a73db97b6448a544e940868slive *sa = s;
13e5182a0c199ecc7a73db97b6448a544e940868slive return NULL;
13e5182a0c199ecc7a73db97b6448a544e940868slive}
13e5182a0c199ecc7a73db97b6448a544e940868slive
13e5182a0c199ecc7a73db97b6448a544e940868slivestatic char *parse_errorlog_item(apr_pool_t *p, ap_errorlog_format_item *it,
13e5182a0c199ecc7a73db97b6448a544e940868slive const char **sa)
13e5182a0c199ecc7a73db97b6448a544e940868slive{
13e5182a0c199ecc7a73db97b6448a544e940868slive const char *s = *sa;
13e5182a0c199ecc7a73db97b6448a544e940868slive ap_errorlog_handler *handler;
13e5182a0c199ecc7a73db97b6448a544e940868slive int i;
13e5182a0c199ecc7a73db97b6448a544e940868slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*s != '%') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*s == ' ') {
2cef7e294acb5d8b8b5dcb21a55438da0b73f63figalic it->flags |= AP_ERRORLOG_FLAG_FIELD_SEP;
3b9c7ec844aa240622a33735d1b9cbac4232e268rbowen }
2cef7e294acb5d8b8b5dcb21a55438da0b73f63figalic return parse_errorlog_misc_string(p, it, sa);
2cef7e294acb5d8b8b5dcb21a55438da0b73f63figalic }
3b9c7ec844aa240622a33735d1b9cbac4232e268rbowen
3b9c7ec844aa240622a33735d1b9cbac4232e268rbowen ++s;
fb77c505254b6e9c925e23e734463e87574f8f40kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*s == ' ') {
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* percent-space (% ) is a field separator */
130d299c4b2b15be45532a176604c71fdc7bea5bnd it->flags |= AP_ERRORLOG_FLAG_FIELD_SEP;
130d299c4b2b15be45532a176604c71fdc7bea5bnd *sa = ++s;
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* recurse */
130d299c4b2b15be45532a176604c71fdc7bea5bnd return parse_errorlog_item(p, it, sa);
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd else if (*s == '%') {
130d299c4b2b15be45532a176604c71fdc7bea5bnd it->arg = "%";
130d299c4b2b15be45532a176604c71fdc7bea5bnd it->func = log_constant_item;
130d299c4b2b15be45532a176604c71fdc7bea5bnd *sa = ++s;
130d299c4b2b15be45532a176604c71fdc7bea5bnd return NULL;
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while (*s) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive switch (*s) {
fb77c505254b6e9c925e23e734463e87574f8f40kess case '{':
fb77c505254b6e9c925e23e734463e87574f8f40kess ++s;
fb77c505254b6e9c925e23e734463e87574f8f40kess it->arg = ap_getword(p, &s, '}');
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive break;
130d299c4b2b15be45532a176604c71fdc7bea5bnd case '+':
130d299c4b2b15be45532a176604c71fdc7bea5bnd ++s;
130d299c4b2b15be45532a176604c71fdc7bea5bnd it->flags |= AP_ERRORLOG_FLAG_REQUIRED;
130d299c4b2b15be45532a176604c71fdc7bea5bnd break;
130d299c4b2b15be45532a176604c71fdc7bea5bnd case '-':
130d299c4b2b15be45532a176604c71fdc7bea5bnd ++s;
130d299c4b2b15be45532a176604c71fdc7bea5bnd it->flags |= AP_ERRORLOG_FLAG_NULL_AS_HYPHEN;
130d299c4b2b15be45532a176604c71fdc7bea5bnd break;
130d299c4b2b15be45532a176604c71fdc7bea5bnd case '0':
130d299c4b2b15be45532a176604c71fdc7bea5bnd case '1':
130d299c4b2b15be45532a176604c71fdc7bea5bnd case '2':
130d299c4b2b15be45532a176604c71fdc7bea5bnd case '3':
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd case '4':
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd case '5':
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive case '6':
fb77c505254b6e9c925e23e734463e87574f8f40kess case '7':
fb77c505254b6e9c925e23e734463e87574f8f40kess case '8':
fb77c505254b6e9c925e23e734463e87574f8f40kess case '9':
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess i = *s - '0';
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess while (apr_isdigit(*++s))
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess i = i * 10 + (*s) - '0';
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess it->min_loglevel = i;
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess break;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive case 'M':
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive it->func = NULL;
9e0536cd66a389bdaa758a825b8bbd8fea665a3eigalic it->flags |= AP_ERRORLOG_FLAG_MESSAGE;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *sa = ++s;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive default:
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen handler = (ap_errorlog_handler *)apr_hash_get(errorlog_hash, s, 1);
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen if (!handler) {
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen char dummy[2];
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen dummy[0] = *s;
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen dummy[1] = '\0';
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen return apr_pstrcat(p, "Unrecognized error log format directive %",
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen dummy, NULL);
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen }
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen it->func = handler->func;
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen *sa = ++s;
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen return NULL;
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen }
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen }
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen return "Ran off end of error log format parsing args to some directive";
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen}
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowenstatic apr_array_header_t *parse_errorlog_string(apr_pool_t *p,
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen const char *s,
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen const char **err,
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen int is_main_fmt)
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen{
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen apr_array_header_t *a = apr_array_make(p, 30,
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen sizeof(ap_errorlog_format_item));
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen char *res;
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen int seen_msg_fmt = 0;
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen while (s && *s) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_errorlog_format_item *item =
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (ap_errorlog_format_item *)apr_array_push(a);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive memset(item, 0, sizeof(*item));
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen res = parse_errorlog_item(p, item, &s);
ef8e89e090461194ecadd31e8796a2c51e0531a2kess if (res) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *err = res;
530eba85dbd41b8a0fa5255d3648d1440199a661slive return NULL;
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele }
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele if (item->flags & AP_ERRORLOG_FLAG_MESSAGE) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!is_main_fmt) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *err = "%M cannot be used in once-per-request or "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "once-per-connection formats";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd seen_msg_fmt = 1;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (is_main_fmt && item->flags & AP_ERRORLOG_FLAG_REQUIRED) {
ef8e89e090461194ecadd31e8796a2c51e0531a2kess *err = "The '+' flag cannot be used in the main error log format";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen if (!is_main_fmt && item->min_loglevel) {
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen *err = "The loglevel cannot be used as a condition in "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "once-per-request or once-per-connection formats";
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (item->min_loglevel > APLOG_TRACE8) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *err = "The specified loglevel modifier is out of range";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (is_main_fmt && !seen_msg_fmt) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *err = "main ErrorLogFormat must contain message format string '%M'";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen return a;
ef8e89e090461194ecadd31e8796a2c51e0531a2kess}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_errorlog_format(cmd_parms *cmd, void *dummy,
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele const char *arg1, const char *arg2)
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err_string = NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(cmd->server->module_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!arg2) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->error_log_format = parse_errorlog_string(cmd->pool, arg1,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &err_string, 1);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
ef8e89e090461194ecadd31e8796a2c51e0531a2kess else if (!strcasecmp(arg1, "connection")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!conf->error_log_conn) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->error_log_conn = apr_array_make(cmd->pool, 5,
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen sizeof(apr_array_header_t *));
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen if (*arg2) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_array_header_t **e;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive e = (apr_array_header_t **) apr_array_push(conf->error_log_conn);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *e = parse_errorlog_string(cmd->pool, arg2, &err_string, 0);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (!strcasecmp(arg1, "request")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!conf->error_log_req) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->error_log_req = apr_array_make(cmd->pool, 5,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sizeof(apr_array_header_t *));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (*arg2) {
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen apr_array_header_t **e;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd e = (apr_array_header_t **) apr_array_push(conf->error_log_req);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *e = parse_errorlog_string(cmd->pool, arg2, &err_string, 0);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele }
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive err_string = "ErrorLogFormat type must be one of request, connection";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return err_string;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(void) ap_register_errorlog_handler(apr_pool_t *p, char *tag,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_errorlog_handler_fn_t *handler,
ef8e89e090461194ecadd31e8796a2c51e0531a2kess int flags)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_errorlog_handler *log_struct = apr_palloc(p, sizeof(*log_struct));
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen log_struct->func = handler;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen log_struct->flags = flags;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen apr_hash_set(errorlog_hash, tag, 1, (const void *)log_struct);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* Note --- ErrorDocument will now work from .htaccess files.
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess * The AllowOverride of Fileinfo allows webmasters to turn it off
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess */
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessstatic const command_rec core_cmds[] = {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess/* Old access config file commands */
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessAP_INIT_RAW_ARGS("<Directory", dirsection, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Container for directives affecting resources located in the specified "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "directories"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_RAW_ARGS("<Location", urlsection, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Container for directives affecting resources accessed through the "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "specified URL paths"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_RAW_ARGS("<VirtualHost", virtualhost_section, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Container to map directives to a particular virtual host, takes one or "
fb77c505254b6e9c925e23e734463e87574f8f40kess "more host addresses"),
003f0c9fda6664daf5092a0e42f65ede20098153sliveAP_INIT_RAW_ARGS("<Files", filesection, NULL, OR_ALL,
fb77c505254b6e9c925e23e734463e87574f8f40kess "Container for directives affecting files matching specified patterns"),
fb77c505254b6e9c925e23e734463e87574f8f40kessAP_INIT_RAW_ARGS("<Limit", ap_limit_section, NULL, OR_LIMIT | OR_AUTHCFG,
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele "Container for authentication directives when accessed using specified HTTP "
18b4b0fd6056093002ddef488636bf5ebe415ef0erikabele "methods"),
003f0c9fda6664daf5092a0e42f65ede20098153sliveAP_INIT_RAW_ARGS("<LimitExcept", ap_limit_section, (void*)1,
18831446030f4eda7e0563c92a896ccfdb6eb1d7slive OR_LIMIT | OR_AUTHCFG,
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen "Container for authentication directives to be applied when any HTTP "
ef8e89e090461194ecadd31e8796a2c51e0531a2kess "method other than those specified is used to access the resource"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("<IfModule", start_ifmod, NULL, EXEC_ON_READ | OR_ALL,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Container for directives based on existence of specified modules"),
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowenAP_INIT_TAKE1("<IfDefine", start_ifdefine, NULL, EXEC_ON_READ | OR_ALL,
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "Container for directives based on existence of command line defines"),
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowenAP_INIT_RAW_ARGS("<DirectoryMatch", dirsection, (void*)1, RSRC_CONF,
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "Container for directives affecting resources located in the "
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "specified directories"),
4cafc94e99922f00654e1779d30c2cccf5278c4fkessAP_INIT_RAW_ARGS("<LocationMatch", urlsection, (void*)1, RSRC_CONF,
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "Container for directives affecting resources accessed through the "
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "specified URL paths"),
4cafc94e99922f00654e1779d30c2cccf5278c4fkessAP_INIT_RAW_ARGS("<FilesMatch", filesection, (void*)1, OR_ALL,
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "Container for directives affecting files matching specified patterns"),
27303c8bb552a8a5fc859feb735d686fc59f59a1yoshiki#ifdef GPROF
4cafc94e99922f00654e1779d30c2cccf5278c4fkessAP_INIT_TAKE1("GprofDir", set_gprof_dir, NULL, RSRC_CONF,
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "Directory to plop gmon.out files"),
4cafc94e99922f00654e1779d30c2cccf5278c4fkess#endif
4cafc94e99922f00654e1779d30c2cccf5278c4fkessAP_INIT_TAKE1("AddDefaultCharset", set_add_default_charset, NULL, OR_FILEINFO,
fb77c505254b6e9c925e23e734463e87574f8f40kess "The name of the default charset to add to any Content-Type without one or 'Off' to disable"),
fb77c505254b6e9c925e23e734463e87574f8f40kessAP_INIT_TAKE1("AcceptPathInfo", set_accept_path_info, NULL, OR_FILEINFO,
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "Set to on or off for PATH_INFO to be accepted by handlers, or default for the per-handler preference"),
4cafc94e99922f00654e1779d30c2cccf5278c4fkessAP_INIT_TAKE1("Define", set_define, NULL, RSRC_CONF,
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "Define the existence of a variable. Same as passing -D to the command line."),
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3sliveAP_INIT_TAKE1("UnDefine", unset_define, NULL, RSRC_CONF,
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "Undefine the existence of a variable. Undo a Define."),
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowenAP_INIT_RAW_ARGS("Error", generate_error, NULL, OR_ALL,
6452eaa76913f6ba732f88cfce6d4f8bf142482bkess "Generate error message from within configuration"),
4cafc94e99922f00654e1779d30c2cccf5278c4fkessAP_INIT_RAW_ARGS("<If", ifsection, NULL, OR_ALL,
27303c8bb552a8a5fc859feb735d686fc59f59a1yoshiki "Container for directives to be conditionally applied"),
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive/* Old resource config file commands */
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowenAP_INIT_RAW_ARGS("AccessFileName", set_access_name, NULL, RSRC_CONF,
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "Name(s) of per-directory config files (default: .htaccess)"),
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3sliveAP_INIT_TAKE1("DocumentRoot", set_document_root, NULL, RSRC_CONF,
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "Root directory of the document tree"),
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3sliveAP_INIT_TAKE2("ErrorDocument", set_error_document, NULL, OR_FILEINFO,
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "Change responses for HTTP errors"),
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3sliveAP_INIT_RAW_ARGS("AllowOverride", set_override, NULL, ACCESS_CONF,
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "Controls what groups of directives can be configured by per-directory "
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "config files"),
4cafc94e99922f00654e1779d30c2cccf5278c4fkessAP_INIT_RAW_ARGS("Options", set_options, NULL, OR_OPTIONS,
fb77c505254b6e9c925e23e734463e87574f8f40kess "Set a number of attributes for a given directory"),
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowenAP_INIT_TAKE1("DefaultType", set_default_type, NULL, OR_FILEINFO,
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "the default media type for otherwise untyped files (DEPRECATED)"),
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3sliveAP_INIT_RAW_ARGS("FileETag", set_etag_bits, NULL, OR_FILEINFO,
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "Specify components used to construct a file's ETag"),
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3sliveAP_INIT_TAKE1("EnableMMAP", set_enable_mmap, NULL, OR_FILEINFO,
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive "Controls whether memory-mapping may be used to read files"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("EnableSendfile", set_enable_sendfile, NULL, OR_FILEINFO,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Controls whether sendfile may be used to transmit files"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a8ee031b2224ce5473826c9d4f603681589245fawrowe/* Old server config file commands */
a8ee031b2224ce5473826c9d4f603681589245fawrowe
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("Protocol", set_protocol, NULL, RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "Set the Protocol for httpd to use."),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE2("AcceptFilter", set_accf_map, NULL, RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "Set the Accept Filter to use for a protocol"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("Port", ap_set_deprecated, NULL, RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "Port was replaced with Listen in Apache 2.0"),
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowenAP_INIT_TAKE1("HostnameLookups", set_hostname_lookups, NULL,
a8ee031b2224ce5473826c9d4f603681589245fawrowe ACCESS_CONF|RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "\"on\" to enable, \"off\" to disable reverse DNS lookups, or \"double\" to "
a8ee031b2224ce5473826c9d4f603681589245fawrowe "enable double-reverse DNS lookups"),
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorAP_INIT_TAKE1("ServerAdmin", set_server_string_slot,
a8ee031b2224ce5473826c9d4f603681589245fawrowe (void *)APR_OFFSETOF(server_rec, server_admin), RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "The email address of the server administrator"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("ServerName", server_hostname_port, NULL, RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "The hostname and port of the server"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("ServerSignature", set_signature_flag, NULL, OR_ALL,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "En-/disable server signature (on|off|email)"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("ServerRoot", set_server_root, NULL, RSRC_CONF | EXEC_ON_READ,
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen "Common directory of server-related files (logs, confs, etc.)"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("ErrorLog", set_server_string_slot,
a8ee031b2224ce5473826c9d4f603681589245fawrowe (void *)APR_OFFSETOF(server_rec, error_fname), RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "The filename of the error log"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE12("ErrorLogFormat", set_errorlog_format, NULL, RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "Format string for the ErrorLog"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_RAW_ARGS("ServerAlias", set_server_alias, NULL, RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "A name or names alternately used to access the server"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("ServerPath", set_serverpath, NULL, RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "The pathname the server can be reached at"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("Timeout", set_timeout, NULL, RSRC_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "Timeout duration (sec)"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_FLAG("ContentDigest", set_content_md5, NULL, OR_OPTIONS,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "whether or not to send a Content-MD5 header with each request"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("UseCanonicalName", set_use_canonical_name, NULL,
a8ee031b2224ce5473826c9d4f603681589245fawrowe RSRC_CONF|ACCESS_CONF,
a8ee031b2224ce5473826c9d4f603681589245fawrowe "How to work out the ServerName : Port when constructing URLs"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("UseCanonicalPhysicalPort", set_use_canonical_phys_port, NULL,
a8ee031b2224ce5473826c9d4f603681589245fawrowe RSRC_CONF|ACCESS_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Whether to use the physical Port when constructing URLs"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* TODO: RlimitFoo should all be part of mod_cgi, not in the core */
003f0c9fda6664daf5092a0e42f65ede20098153slive/* TODO: ListenBacklog in MPM */
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("Include", include_config, NULL,
2e5e2673cb64d3e4d445d911c6f61ac171020725nd (RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Name(s) of the config file(s) to be included; fails if the wildcard does "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "not match at least one file"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("IncludeOptional", include_config, (void*)1,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
2e5e2673cb64d3e4d445d911c6f61ac171020725nd "Name or pattern of the config file(s) to be included; ignored if the file "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "does not exist or the pattern does not match any files"),
733738e83a9b0113476e3f67992c2278d61ee4dakessAP_INIT_ITERATE("LogLevel", set_loglevel, NULL, RSRC_CONF|ACCESS_CONF,
733738e83a9b0113476e3f67992c2278d61ee4dakess "Level of verbosity in error logging"),
2e5e2673cb64d3e4d445d911c6f61ac171020725ndAP_INIT_TAKE1("NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF,
2e5e2673cb64d3e4d445d911c6f61ac171020725nd "A numeric IP address:port, or the name of a host"),
2e5e2673cb64d3e4d445d911c6f61ac171020725ndAP_INIT_TAKE12("ServerTokens", set_serv_tokens, NULL, RSRC_CONF,
2e5e2673cb64d3e4d445d911c6f61ac171020725nd "Determine tokens displayed in the Server: header - Min(imal), "
2e5e2673cb64d3e4d445d911c6f61ac171020725nd "Major, Minor, Prod, OS or Full"),
2e5e2673cb64d3e4d445d911c6f61ac171020725ndAP_INIT_TAKE1("LimitRequestLine", set_limit_req_line, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Limit on maximum size of an HTTP request line"),
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndAP_INIT_TAKE1("LimitRequestFieldsize", set_limit_req_fieldsize, NULL,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd RSRC_CONF,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd "Limit on maximum size of an HTTP request header field"),
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndAP_INIT_TAKE1("LimitRequestFields", set_limit_req_fields, NULL, RSRC_CONF,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd "Limit (0 = unlimited) on max number of header fields in a request message"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("LimitRequestBody", set_limit_req_body,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (void*)APR_OFFSETOF(core_dir_config, limit_req_body), OR_ALL,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Limit (in bytes) on maximum size of request message body"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("LimitXMLRequestBody", set_limit_xml_req_body, NULL, OR_ALL,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Limit (in bytes) on maximum size of an XML-based request "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "body"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_RAW_ARGS("Mutex", ap_set_mutex, NULL, RSRC_CONF,
003f0c9fda6664daf5092a0e42f65ede20098153slive "mutex (or \"default\") and mechanism"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd/* System Resource Controls */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#ifdef RLIMIT_CPU
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE12("RLimitCPU", set_limit_cpu,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (void*)APR_OFFSETOF(core_dir_config, limit_cpu),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive OR_ALL, "Soft/hard limits for max CPU usage in seconds"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#else
206b5dce9e48924aa9f12ce87f14856a4cd3fb68takashiAP_INIT_TAKE12("RLimitCPU", no_set_limit, NULL,
0e4c8b384f21029c01f06824ec522bb2cbec1d0enoirin OR_ALL, "Soft/hard limits for max CPU usage in seconds"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined (RLIMIT_AS)
b6ab9bfd820e424c2e9544d629ae67af24e90dcerbowenAP_INIT_TAKE12("RLimitMEM", set_limit_mem,
ffe8ed2cd88be2c415ddef11f50394c52df9190ctrawick (void*)APR_OFFSETOF(core_dir_config, limit_mem),
ffe8ed2cd88be2c415ddef11f50394c52df9190ctrawick OR_ALL, "Soft/hard limits for max memory usage per process"),
b6ab9bfd820e424c2e9544d629ae67af24e90dcerbowen#else
fff1d314f760fc17a49215e8818b3e57691efa43niqAP_INIT_TAKE12("RLimitMEM", no_set_limit, NULL,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd OR_ALL, "Soft/hard limits for max memory usage per process"),
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd#endif
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd#ifdef RLIMIT_NPROC
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE12("RLimitNPROC", set_limit_nproc,
fff1d314f760fc17a49215e8818b3e57691efa43niq (void*)APR_OFFSETOF(core_dir_config, limit_nproc),
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen OR_ALL, "soft/hard limits for max number of processes per uid"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#else
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE12("RLimitNPROC", no_set_limit, NULL,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive OR_ALL, "soft/hard limits for max number of processes per uid"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
003f0c9fda6664daf5092a0e42f65ede20098153slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* internal recursion stopper */
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE12("LimitInternalRecursion", set_recursion_limit, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "maximum recursion depth of internal redirects and subrequests"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("ForceType", ap_set_string_slot_lower,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (void *)APR_OFFSETOF(core_dir_config, mime_type), OR_FILEINFO,
e08ad1a326852610a7930269638a43657fc50d06sctemme "a mime type that overrides other configured type"),
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE1("SetHandler", ap_set_string_slot_lower,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (void *)APR_OFFSETOF(core_dir_config, handler), OR_FILEINFO,
06fcf16883e133e49db046945cbcf728d4cc6e37rbowen "a handler name that overrides any other configured handler"),
06fcf16883e133e49db046945cbcf728d4cc6e37rbowenAP_INIT_TAKE1("SetOutputFilter", ap_set_string_slot,
06fcf16883e133e49db046945cbcf728d4cc6e37rbowen (void *)APR_OFFSETOF(core_dir_config, output_filters), OR_FILEINFO,
06fcf16883e133e49db046945cbcf728d4cc6e37rbowen "filter (or ; delimited list of filters) to be run on the request content"),
06fcf16883e133e49db046945cbcf728d4cc6e37rbowenAP_INIT_TAKE1("SetInputFilter", ap_set_string_slot,
06fcf16883e133e49db046945cbcf728d4cc6e37rbowen (void *)APR_OFFSETOF(core_dir_config, input_filters), OR_FILEINFO,
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor "filter (or ; delimited list of filters) to be run on the request body"),
06fcf16883e133e49db046945cbcf728d4cc6e37rbowenAP_INIT_FLAG("AllowEncodedSlashes", set_allow2f, NULL, RSRC_CONF,
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick "Allow URLs containing '/' encoded as '%2F'"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick/* scoreboard.c directives */
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("ScoreboardFile", ap_set_scoreboard, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "A file for Apache to maintain runtime process management information"),
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndAP_INIT_FLAG("ExtendedStatus", ap_set_extended_status, NULL, RSRC_CONF,
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor "\"On\" to track extended status information, \"Off\" to disable"),
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndAP_INIT_FLAG("SeeRequestTail", ap_set_reqtail, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "For extended status, \"On\" to see the last 63 chars of "
e6ab342447cf6b4c22bbe66169718d0e9b78819apoirier "the request line, \"Off\" (default) to see the first 63"),
e6ab342447cf6b4c22bbe66169718d0e9b78819apoirier
e6ab342447cf6b4c22bbe66169718d0e9b78819apoirier/*
e6ab342447cf6b4c22bbe66169718d0e9b78819apoirier * These are default configuration directives that mpms can/should
e6ab342447cf6b4c22bbe66169718d0e9b78819apoirier * pay attention to.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * XXX These are not for all platforms, and even some Unix MPMs might not want
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * some directives.
fb77c505254b6e9c925e23e734463e87574f8f40kess */
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE1("PidFile", ap_mpm_set_pidfile, NULL, RSRC_CONF,
e08ad1a326852610a7930269638a43657fc50d06sctemme "A file for logging the server process ID"),
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE1("MaxRequestsPerChild", ap_mpm_set_max_requests, NULL, RSRC_CONF,
e08ad1a326852610a7930269638a43657fc50d06sctemme "Maximum number of connections a particular child serves before "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "dying. (DEPRECATED, use MaxConnectionsPerChild)"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("MaxConnectionsPerChild", ap_mpm_set_max_requests, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Maximum number of connections a particular child serves before dying."),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("CoreDumpDirectory", ap_mpm_set_coredumpdir, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "The location of the directory Apache changes to before dumping core"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("MaxMemFree", ap_mpm_set_max_mem_free, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Maximum number of 1k blocks a particular childs allocator may hold."),
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_TAKE1("ThreadStackSize", ap_mpm_set_thread_stacksize, NULL, RSRC_CONF,
e08ad1a326852610a7930269638a43657fc50d06sctemme "Size in bytes of stack used by threads handling client connections"),
e08ad1a326852610a7930269638a43657fc50d06sctemme#if AP_ENABLE_EXCEPTION_HOOK
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE1("EnableExceptionHook", ap_mpm_set_exception_hook, NULL, RSRC_CONF,
e08ad1a326852610a7930269638a43657fc50d06sctemme "Controls whether exception hook may be called after a crash"),
e08ad1a326852610a7930269638a43657fc50d06sctemme#endif
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE1("TraceEnable", set_trace_enable, NULL, RSRC_CONF,
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor "'on' (default), 'off' or 'extended' to trace request body content"),
e08ad1a326852610a7930269638a43657fc50d06sctemme{ NULL }
e08ad1a326852610a7930269638a43657fc50d06sctemme};
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim/*****************************************************************
29edaaeea24c41820e486944635348cd7fae1d11rbowen *
e08ad1a326852610a7930269638a43657fc50d06sctemme * Core handlers for various phases of server operation...
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r)
e08ad1a326852610a7930269638a43657fc50d06sctemme{
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen void *sconf = r->server->module_config;
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen core_server_config *conf = ap_get_module_config(sconf, &core_module);
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen apr_status_t rv;
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen /* XXX this seems too specific, this should probably become
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen * some general-case test
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen */
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen if (r->proxyreq) {
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen return HTTP_FORBIDDEN;
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen }
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen if (!r->uri || ((r->uri[0] != '/') && strcmp(r->uri, "*"))) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Invalid URI in request %s", r->the_request);
ef8e89e090461194ecadd31e8796a2c51e0531a2kess return HTTP_BAD_REQUEST;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (r->server->path
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && !strncmp(r->uri, r->server->path, r->server->pathlen)
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim && (r->server->path[r->server->pathlen - 1] == '/'
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive || r->uri[r->server->pathlen] == '/'
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive || r->uri[r->server->pathlen] == '\0'))
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* skip all leading /'s (e.g. http://localhost///foo)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * so we are looking at only the relative path.
fb77c505254b6e9c925e23e734463e87574f8f40kess */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *path = r->uri + r->server->pathlen;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd while (*path == '/') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ++path;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if ((rv = apr_filepath_merge(&r->filename, conf->ap_document_root, path,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive APR_FILEPATH_TRUENAME
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive | APR_FILEPATH_SECUREROOT, r->pool))
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive != APR_SUCCESS) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen "Cannot map %s to file", r->the_request);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return HTTP_FORBIDDEN;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r->canonical_filename = r->filename;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
003f0c9fda6664daf5092a0e42f65ede20098153slive else {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /*
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Make sure that we do not mess up the translation by adding two
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * /'s in a row. This happens under windows when the document
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * root ends with a /
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* skip all leading /'s (e.g. http://localhost///foo)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * so we are looking at only the relative path.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
7228d3b2eebddc214348190bcc62d80b5e7087e2rbowen char *path = r->uri;
7228d3b2eebddc214348190bcc62d80b5e7087e2rbowen while (*path == '/') {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor ++path;
7228d3b2eebddc214348190bcc62d80b5e7087e2rbowen }
58e56a1d61ae176cc5ecb7c4863881736947d8b8rbowen if ((rv = apr_filepath_merge(&r->filename, conf->ap_document_root, path,
58e56a1d61ae176cc5ecb7c4863881736947d8b8rbowen APR_FILEPATH_TRUENAME
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd | APR_FILEPATH_SECUREROOT, r->pool))
58e56a1d61ae176cc5ecb7c4863881736947d8b8rbowen != APR_SUCCESS) {
58e56a1d61ae176cc5ecb7c4863881736947d8b8rbowen ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Cannot map %s to file", r->the_request);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return HTTP_FORBIDDEN;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r->canonical_filename = r->filename;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
ef8e89e090461194ecadd31e8796a2c51e0531a2kess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return OK;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/*****************************************************************
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Test the filesystem name through directory_walk and file_walk
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int core_map_to_storage(request_rec *r)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int access_status;
003f0c9fda6664daf5092a0e42f65ede20098153slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if ((access_status = ap_directory_walk(r))) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return access_status;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess if ((access_status = ap_file_walk(r))) {
fb77c505254b6e9c925e23e734463e87574f8f40kess return access_status;
fb77c505254b6e9c925e23e734463e87574f8f40kess }
fb77c505254b6e9c925e23e734463e87574f8f40kess
ef8e89e090461194ecadd31e8796a2c51e0531a2kess return OK;
ef8e89e090461194ecadd31e8796a2c51e0531a2kess}
ef8e89e090461194ecadd31e8796a2c51e0531a2kess
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int do_nothing(request_rec *r) { return OK; }
530eba85dbd41b8a0fa5255d3648d1440199a661slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int core_override_type(request_rec *r)
530eba85dbd41b8a0fa5255d3648d1440199a661slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *conf =
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (core_dir_config *)ap_get_module_config(r->per_dir_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive &core_module);
23b36269d124e7a6aaa5221891f7ae2ef3eeb158jerenkrantz
23b36269d124e7a6aaa5221891f7ae2ef3eeb158jerenkrantz /* Check for overrides with ForceType / SetHandler
7b5535ed88e0f561b3bfb3330137bd804846afd4slive */
7b5535ed88e0f561b3bfb3330137bd804846afd4slive if (conf->mime_type && strcmp(conf->mime_type, "none"))
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_set_content_type(r, (char*) conf->mime_type);
f35c904c3b359610a46e94fbb4ba8495b2338521slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (conf->handler && strcmp(conf->handler, "none"))
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r->handler = conf->handler;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* Deal with the poor soul who is trying to force path_info to be
ef8e89e090461194ecadd31e8796a2c51e0531a2kess * accepted within the core_handler, where they will let the subreq
ef8e89e090461194ecadd31e8796a2c51e0531a2kess * address its contents. This is toggled by the user in the very
dc111bcea580da3da174c25be0fd7a8f22c86fe1jim * beginning of the fixup phase, so modules should override the user's
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * discretion in their own module fixup phase. It is tristate, if
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * the user doesn't specify, the result is 2 (which the module may
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * interpret to its own customary behavior.) It won't be touched
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * if the value is no longer undefined (2), so any module changing
530eba85dbd41b8a0fa5255d3648d1440199a661slive * the value prior to the fixup phase OVERRIDES the user's choice.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if ((r->used_path_info == AP_REQ_DEFAULT_PATH_INFO)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && (conf->accept_path_info != 3)) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r->used_path_info = conf->accept_path_info;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a21fb2799923b1c25a351f09e690bd46806f2fa2jim
2eb5346b17b3b69767cfe87d0f632efd6d15500djim return OK;
9e59849752ebadf803f76453fe3b64e2cee8d190rbowen}
a21fb2799923b1c25a351f09e690bd46806f2fa2jim
2eb5346b17b3b69767cfe87d0f632efd6d15500djimstatic int default_handler(request_rec *r)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conn_rec *c = r->connection;
530eba85dbd41b8a0fa5255d3648d1440199a661slive apr_bucket_brigade *bb;
530eba85dbd41b8a0fa5255d3648d1440199a661slive apr_bucket *e;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_dir_config *d;
cf1595220a90759be0a39ab8b11c8cb834b698a9ianh int errstatus;
cf1595220a90759be0a39ab8b11c8cb834b698a9ianh apr_file_t *fd = NULL;
cf1595220a90759be0a39ab8b11c8cb834b698a9ianh apr_status_t status;
cf1595220a90759be0a39ab8b11c8cb834b698a9ianh /* XXX if/when somebody writes a content-md5 filter we either need to
cf1595220a90759be0a39ab8b11c8cb834b698a9ianh * remove this support or coordinate when to use the filter vs.
cf1595220a90759be0a39ab8b11c8cb834b698a9ianh * when to use this code
1a1cf0ee9229ee29e5750b25dd94dbb9b04072cfianh * The current choice of when to compute the md5 here matches the 1.3
1a1cf0ee9229ee29e5750b25dd94dbb9b04072cfianh * support fairly closely (unlike 1.3, we don't handle computing md5
9e59849752ebadf803f76453fe3b64e2cee8d190rbowen * when the charset is translated).
1a1cf0ee9229ee29e5750b25dd94dbb9b04072cfianh */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive int bld_content_md5;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
530eba85dbd41b8a0fa5255d3648d1440199a661slive d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
9e59849752ebadf803f76453fe3b64e2cee8d190rbowen &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive bld_content_md5 = (d->content_md5 & 1)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && r->output_filters->frec->ftype != AP_FTYPE_RESOURCE;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
9e59849752ebadf803f76453fe3b64e2cee8d190rbowen ap_allow_standard_methods(r, MERGE_ALLOW, M_GET, M_OPTIONS, M_POST, -1);
530eba85dbd41b8a0fa5255d3648d1440199a661slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* If filters intend to consume the request body, they must
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * register an InputFilter to slurp the contents of the POST
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * data from the POST input stream. It no longer exists when
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * the output filters are invoked by the default handler.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
23b36269d124e7a6aaa5221891f7ae2ef3eeb158jerenkrantz if ((errstatus = ap_discard_request_body(r)) != OK) {
23b36269d124e7a6aaa5221891f7ae2ef3eeb158jerenkrantz return errstatus;
7b5535ed88e0f561b3bfb3330137bd804846afd4slive }
7b5535ed88e0f561b3bfb3330137bd804846afd4slive
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor if (r->method_number == M_GET || r->method_number == M_POST) {
a21fb2799923b1c25a351f09e690bd46806f2fa2jim if (r->finfo.filetype == APR_NOFILE) {
a21fb2799923b1c25a351f09e690bd46806f2fa2jim ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
a21fb2799923b1c25a351f09e690bd46806f2fa2jim "File does not exist: %s", r->filename);
a21fb2799923b1c25a351f09e690bd46806f2fa2jim return HTTP_NOT_FOUND;
a21fb2799923b1c25a351f09e690bd46806f2fa2jim }
a21fb2799923b1c25a351f09e690bd46806f2fa2jim
a21fb2799923b1c25a351f09e690bd46806f2fa2jim /* Don't try to serve a dir. Some OSs do weird things with
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * raw I/O on a dir.
f35c904c3b359610a46e94fbb4ba8495b2338521slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (r->finfo.filetype == APR_DIR) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "Attempt to serve directory: %s", r->filename);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return HTTP_NOT_FOUND;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kess if ((r->used_path_info != AP_REQ_ACCEPT_PATH_INFO) &&
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r->path_info && *r->path_info)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* default to reject */
003f0c9fda6664daf5092a0e42f65ede20098153slive ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen "File does not exist: %s",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_pstrcat(r->pool, r->filename, r->path_info, NULL));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return HTTP_NOT_FOUND;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* We understood the (non-GET) method, but it might not be legal for
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive this particular resource. Check to see if the 'deliver_script'
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive flag is set. If so, then we go ahead and deliver the file since
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd it isn't really content (only GET normally returns content).
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive Note: based on logic further above, the only possible non-GET
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive method at this point is POST. In the future, we should enable
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd script delivery for all methods. */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (r->method_number != M_GET) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd core_request_config *req_cfg;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive req_cfg = ap_get_module_config(r->request_config, &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (!req_cfg->deliver_script) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* The flag hasn't been set for this request. Punt. */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess "This resource does not accept the %s method.",
db1b819ff8966e3c6a5ca03c59a8ae06c2cecc9frbowen r->method);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return HTTP_METHOD_NOT_ALLOWED;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if ((status = apr_file_open(&fd, r->filename, APR_READ | APR_BINARY
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd#if APR_HAS_SENDFILE
c97e8972ab1f4dd167e3dc4db87daf91114009fbnd | AP_SENDFILE_ENABLED(d->enable_sendfile)
c97e8972ab1f4dd167e3dc4db87daf91114009fbnd#endif
c97e8972ab1f4dd167e3dc4db87daf91114009fbnd , 0, r->pool)) != APR_SUCCESS) {
2025fe01de41805f6148851335693aa5ebe2faffnd ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
91d09a9328c13761516ce2fedeeb23f525d4ec75nd "file permissions deny server access: %s", r->filename);
91d09a9328c13761516ce2fedeeb23f525d4ec75nd return HTTP_FORBIDDEN;
9f1dd1339447bf4b291682cd94bf9f28bc2685e0niq }
91d09a9328c13761516ce2fedeeb23f525d4ec75nd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_update_mtime(r, r->finfo.mtime);
db1b819ff8966e3c6a5ca03c59a8ae06c2cecc9frbowen ap_set_last_modified(r);
db1b819ff8966e3c6a5ca03c59a8ae06c2cecc9frbowen ap_set_etag(r);
db1b819ff8966e3c6a5ca03c59a8ae06c2cecc9frbowen apr_table_setn(r->headers_out, "Accept-Ranges", "bytes");
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_set_content_length(r, r->finfo.size);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (bld_content_md5) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_table_setn(r->headers_out, "Content-MD5",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_md5digest(r->pool, fd));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd bb = apr_brigade_create(r->pool, c->bucket_alloc);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if ((errstatus = ap_meets_conditions(r)) != OK) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_file_close(fd);
003f0c9fda6664daf5092a0e42f65ede20098153slive r->status = errstatus;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive e = apr_brigade_insert_file(bb, fd, 0, r->finfo.size, r->pool);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#if APR_HAS_MMAP
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (d->enable_mmap == ENABLE_MMAP_OFF) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (void)apr_bucket_file_enable_mmap(e, 0);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#endif
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive e = apr_bucket_eos_create(c->bucket_alloc);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive APR_BRIGADE_INSERT_TAIL(bb, e);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive status = ap_pass_brigade(r->output_filters, bb);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (status == APR_SUCCESS
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive || r->status != HTTP_OK
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive || c->aborted) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return OK;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* no way to know what type of error occurred */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "default_handler: ap_pass_brigade returned %i",
003f0c9fda6664daf5092a0e42f65ede20098153slive status);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return HTTP_INTERNAL_SERVER_ERROR;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else { /* unusual method (not GET or POST) */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (r->method_number == M_INVALID) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* See if this looks like an undecrypted SSL handshake attempt.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * It's safe to look a couple bytes into the_request if it exists, as it's
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * always allocated at least MIN_LINE_ALLOC (80) bytes.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (r->the_request
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && r->the_request[0] == 0x16
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && (r->the_request[1] == 0x2 || r->the_request[1] == 0x3)) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
130d299c4b2b15be45532a176604c71fdc7bea5bnd "Invalid method in request %s - possible attempt to establish SSL connection on non-SSL port", r->the_request);
130d299c4b2b15be45532a176604c71fdc7bea5bnd } else {
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
130d299c4b2b15be45532a176604c71fdc7bea5bnd "Invalid method in request %s", r->the_request);
130d299c4b2b15be45532a176604c71fdc7bea5bnd }
130d299c4b2b15be45532a176604c71fdc7bea5bnd return HTTP_NOT_IMPLEMENTED;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (r->method_number == M_OPTIONS) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return ap_send_http_options(r);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return HTTP_METHOD_NOT_ALLOWED;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* Optional function coming from mod_logio, used for logging of output
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * traffic
003f0c9fda6664daf5092a0e42f65ede20098153slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAPR_OPTIONAL_FN_TYPE(ap_logio_add_bytes_out) *ap__logio_add_bytes_out;
6b64034fa2a644ba291c484c0c01c7df5b8d982ckessAPR_OPTIONAL_FN_TYPE(authz_some_auth_required) *ap__authz_ap_some_auth_required;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fa71303e53e7ef460728446b8290d05ed0895136trawick/* Insist that at least one module will undertake to provide system
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * security by dropping startup privileges.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jortonstatic int sys_privileges = 0;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowenAP_DECLARE(int) ap_sys_privileges_handlers(int inc)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sys_privileges += inc;
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton return sys_privileges;
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton}
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton{
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton ap_mutex_init(pconf);
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return APR_SUCCESS;
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton}
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jortonstatic int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton{
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton ap__logio_add_bytes_out = APR_RETRIEVE_OPTIONAL_FN(ap_logio_add_bytes_out);
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton ident_lookup = APR_RETRIEVE_OPTIONAL_FN(ap_ident_lookup);
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton ap__authz_ap_some_auth_required = APR_RETRIEVE_OPTIONAL_FN(authz_some_auth_required);
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton authn_ap_auth_type = APR_RETRIEVE_OPTIONAL_FN(authn_ap_auth_type);
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jorton authn_ap_auth_name = APR_RETRIEVE_OPTIONAL_FN(authn_ap_auth_name);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive access_compat_ap_satisfies = APR_RETRIEVE_OPTIONAL_FN(access_compat_ap_satisfies);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive set_banner(pconf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_setup_make_content_type(pconf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_setup_auth_internal(ptemp);
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe if (!sys_privileges) {
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe ap_log_error(APLOG_MARK, APLOG_CRIT, 0, NULL,
f59a2b72270d63d121d6a1a01d85fb87d8a8bb45rbowen "Server MUST relinquish startup privileges before "
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe "accepting connections. Please ensure mod_unixd "
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe "or other system security module is loaded.");
d2ec55d959780924c999ce1a75d54e1030896608covener return !OK;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen }
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe return OK;
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe}
12099dff89f3135d53929f4f1bdb42c7d044d928nd
12099dff89f3135d53929f4f1bdb42c7d044d928ndstatic void core_insert_filter(request_rec *r)
12099dff89f3135d53929f4f1bdb42c7d044d928nd{
12099dff89f3135d53929f4f1bdb42c7d044d928nd core_dir_config *conf = (core_dir_config *)
12099dff89f3135d53929f4f1bdb42c7d044d928nd ap_get_module_config(r->per_dir_config,
12099dff89f3135d53929f4f1bdb42c7d044d928nd &core_module);
12099dff89f3135d53929f4f1bdb42c7d044d928nd const char *filter, *filters = conf->output_filters;
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe if (filters) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor while (*filters && (filter = ap_getword(r->pool, &filters, ';'))) {
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe ap_add_output_filter(filter, NULL, r, r->connection);
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe }
12099dff89f3135d53929f4f1bdb42c7d044d928nd }
12099dff89f3135d53929f4f1bdb42c7d044d928nd
12099dff89f3135d53929f4f1bdb42c7d044d928nd filters = conf->input_filters;
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe if (filters) {
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe while (*filters && (filter = ap_getword(r->pool, &filters, ';'))) {
20b0f809c3823eda58808be053ffc305dfa9c785sf ap_add_input_filter(filter, NULL, r, r->connection);
20b0f809c3823eda58808be053ffc305dfa9c785sf }
20b0f809c3823eda58808be053ffc305dfa9c785sf }
20b0f809c3823eda58808be053ffc305dfa9c785sf}
20b0f809c3823eda58808be053ffc305dfa9c785sf
20b0f809c3823eda58808be053ffc305dfa9c785sfstatic apr_size_t num_request_notes = AP_NUM_STD_NOTES;
20b0f809c3823eda58808be053ffc305dfa9c785sf
20b0f809c3823eda58808be053ffc305dfa9c785sfstatic apr_status_t reset_request_notes(void *dummy)
20b0f809c3823eda58808be053ffc305dfa9c785sf{
20b0f809c3823eda58808be053ffc305dfa9c785sf num_request_notes = AP_NUM_STD_NOTES;
20b0f809c3823eda58808be053ffc305dfa9c785sf return APR_SUCCESS;
20b0f809c3823eda58808be053ffc305dfa9c785sf}
20b0f809c3823eda58808be053ffc305dfa9c785sf
20b0f809c3823eda58808be053ffc305dfa9c785sfAP_DECLARE(apr_size_t) ap_register_request_note(void)
20b0f809c3823eda58808be053ffc305dfa9c785sf{
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe apr_pool_cleanup_register(apr_hook_global_pool, NULL, reset_request_notes,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_pool_cleanup_null);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return num_request_notes++;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
fb77c505254b6e9c925e23e734463e87574f8f40kessAP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num)
fb294b146e7ceb48e3983ee3684ba6c6506241c0jim{
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_request_config *req_cfg;
003f0c9fda6664daf5092a0e42f65ede20098153slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (note_num >= num_request_notes) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return NULL;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen }
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen req_cfg = (core_request_config *)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_get_module_config(r->request_config, &core_module);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (!req_cfg) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return NULL;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return &(req_cfg->notes[note_num]);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
3c6c63407f1855ddfc45ac69b69a2a9bf15135e6rbowen
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessstatic int core_create_req(request_rec *r)
1fd5131d5732e639b0b4225ca0afea717c41bc11trawick{
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess /* Alloc the config struct and the array of request notes in
3c6c63407f1855ddfc45ac69b69a2a9bf15135e6rbowen * a single block for efficiency
3c6c63407f1855ddfc45ac69b69a2a9bf15135e6rbowen */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_request_config *req_cfg;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive req_cfg = apr_pcalloc(r->pool, sizeof(core_request_config) +
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sizeof(void *) * num_request_notes);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive req_cfg->notes = (void **)((char *)req_cfg + sizeof(core_request_config));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen /* ### temporarily enable script delivery as the default */
ffe8ed2cd88be2c415ddef11f50394c52df9190ctrawick req_cfg->deliver_script = 1;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
3c6c63407f1855ddfc45ac69b69a2a9bf15135e6rbowen if (r->main) {
ffe8ed2cd88be2c415ddef11f50394c52df9190ctrawick core_request_config *main_req_cfg = (core_request_config *)
3c6c63407f1855ddfc45ac69b69a2a9bf15135e6rbowen ap_get_module_config(r->main->request_config, &core_module);
3c6c63407f1855ddfc45ac69b69a2a9bf15135e6rbowen req_cfg->bb = main_req_cfg->bb;
fb77c505254b6e9c925e23e734463e87574f8f40kess }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen else {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive req_cfg->bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_set_module_config(r->request_config, &core_module, req_cfg);
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return OK;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive}
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessstatic int core_create_proxy_req(request_rec *r, request_rec *pr)
130d299c4b2b15be45532a176604c71fdc7bea5bnd{
130d299c4b2b15be45532a176604c71fdc7bea5bnd return core_create_req(pr);
130d299c4b2b15be45532a176604c71fdc7bea5bnd}
130d299c4b2b15be45532a176604c71fdc7bea5bnd
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
130d299c4b2b15be45532a176604c71fdc7bea5bnd apr_socket_t *csd, long id, void *sbh,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_bucket_alloc_t *alloc)
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim{
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim apr_status_t rv;
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim c->sbh = sbh;
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim (void)ap_update_child_status(c->sbh, SERVER_BUSY_READ, (request_rec *)NULL);
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim
d56970df0a3d627ea0bc8867a9d336cfe67da7b2nd /* Got a connection structure, so initialize what fields we can
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim * (the rest are zeroed out by pcalloc).
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim */
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim c->conn_config = ap_create_conn_config(ptrans);
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim c->notes = apr_table_make(ptrans, 5);
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim c->pool = ptrans;
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen if ((rv = apr_socket_addr_get(&c->local_addr, APR_LOCAL, csd))
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim != APR_SUCCESS) {
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim "apr_socket_addr_get(APR_LOCAL)");
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim apr_socket_close(csd);
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim return NULL;
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim }
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim apr_sockaddr_ip_get(&c->local_ip, c->local_addr);
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim if ((rv = apr_socket_addr_get(&c->remote_addr, APR_REMOTE, csd))
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim != APR_SUCCESS) {
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd ap_log_error(APLOG_MARK, APLOG_INFO, rv, server,
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd "apr_socket_addr_get(APR_REMOTE)");
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd apr_socket_close(csd);
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd return NULL;
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd }
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd
4e8794dab6bbd15eb0bb016c7a4efb8b0572d558nd apr_sockaddr_ip_get(&c->remote_ip, c->remote_addr);
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim c->base_server = server;
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd c->id = id;
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd c->bucket_alloc = alloc;
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd c->cs = (conn_state_t *)apr_pcalloc(ptrans, sizeof(conn_state_t));
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd APR_RING_INIT(&(c->cs->timeout_list), conn_state_t, timeout_list);
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim c->cs->expiration_time = 0;
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim c->cs->state = CONN_STATE_CHECK_REQUEST_LINE_READABLE;
4e8794dab6bbd15eb0bb016c7a4efb8b0572d558nd c->cs->c = c;
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim c->cs->p = ptrans;
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd c->cs->bucket_alloc = alloc;
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd c->clogging_input_filters = 0;
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return c;
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim}
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jimstatic int core_pre_connection(conn_rec *c, void *csd)
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim{
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim core_net_rec *net = apr_palloc(c->pool, sizeof(*net));
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim apr_status_t rv;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* The Nagle algorithm says that we should delay sending partial
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * packets in hopes of getting more data. We don't want to do
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * this; we are not telnet. There are bad interactions between
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * persistent connections and Nagle's algorithm that have very severe
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * performance penalties. (Failing to disable Nagle is not much of a
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * problem with simple HTTP.)
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive rv = apr_socket_opt_set(csd, APR_TCP_NODELAY, 1);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* expected cause is that the client disconnected already,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * hence the debug level
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "apr_socket_opt_set(APR_TCP_NODELAY)");
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive }
a23acbbd61b9565caecea9931b6bcdf0b6228cbbslive
a23acbbd61b9565caecea9931b6bcdf0b6228cbbslive /* The core filter requires the timeout mode to be set, which
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * incidentally sets the socket to be nonblocking. If this
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * is not initialized correctly, Linux - for example - will
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * be initially blocking, while Solaris will be non blocking
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener * and any initial read will fail.
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive rv = apr_socket_timeout_set(csd, c->base_server->timeout);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (rv != APR_SUCCESS) {
a23acbbd61b9565caecea9931b6bcdf0b6228cbbslive /* expected cause is that the client disconnected already */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_cerror(APLOG_MARK, APLOG_DEBUG, rv, c,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "apr_socket_timeout_set");
01710fa5f312f3a9cd1969d1809cf6c19a7f3d31niq }
a23acbbd61b9565caecea9931b6bcdf0b6228cbbslive
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener net->c = c;
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener net->in_ctx = NULL;
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener net->out_ctx = NULL;
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener net->client_socket = csd;
a23acbbd61b9565caecea9931b6bcdf0b6228cbbslive
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_set_module_config(net->c->conn_config, &core_module, csd);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL, net->c);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_add_output_filter_handle(ap_core_output_filter_handle, net, NULL, net->c);
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener return DONE;
130d299c4b2b15be45532a176604c71fdc7bea5bnd}
e8811b6d38f756b325446ded5d96857d13856511takashi
e8811b6d38f756b325446ded5d96857d13856511takashistatic void register_hooks(apr_pool_t *p)
e8811b6d38f756b325446ded5d96857d13856511takashi{
e8811b6d38f756b325446ded5d96857d13856511takashi errorlog_hash = apr_hash_make(p);
e8811b6d38f756b325446ded5d96857d13856511takashi ap_register_log_hooks(p);
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_expr_init(p);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* create_connection and pre_connection should always be hooked
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * APR_HOOK_REALLY_LAST by core to give other modules the opportunity
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess * to install alternate network transports and stop other functions
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd * from being run.
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_hook_create_connection(core_create_conn, NULL, NULL,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd APR_HOOK_REALLY_LAST);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_hook_pre_connection(core_pre_connection, NULL, NULL,
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener APR_HOOK_REALLY_LAST);
130d299c4b2b15be45532a176604c71fdc7bea5bnd
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_hook_pre_config(core_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST);
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_hook_open_logs(ap_open_logs,NULL,NULL,APR_HOOK_REALLY_FIRST);
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_hook_child_init(ap_logs_child_init,NULL,NULL,APR_HOOK_MIDDLE);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd ap_hook_handler(default_handler,NULL,NULL,APR_HOOK_REALLY_LAST);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess /* FIXME: I suspect we can eliminate the need for these do_nothings - Ben */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_hook_type_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_hook_fixups(core_override_type,NULL,NULL,APR_HOOK_REALLY_FIRST);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_hook_create_request(core_create_req, NULL, NULL, APR_HOOK_MIDDLE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive APR_OPTIONAL_HOOK(proxy, create_req, core_create_proxy_req, NULL, NULL,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive APR_HOOK_MIDDLE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_hook_pre_mpm(ap_create_scoreboard, NULL, NULL, APR_HOOK_MIDDLE);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess
a23acbbd61b9565caecea9931b6bcdf0b6228cbbslive /* register the core's insert_filter hook and register core-provided
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * filters
130d299c4b2b15be45532a176604c71fdc7bea5bnd */
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_hook_insert_filter(core_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen ap_core_input_filter_handle =
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_register_input_filter("CORE_IN", ap_core_input_filter,
130d299c4b2b15be45532a176604c71fdc7bea5bnd NULL, AP_FTYPE_NETWORK);
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_content_length_filter_handle =
4cf1c07a88ef51e11570c775507cd7d2c3e35a97slive ap_register_output_filter("CONTENT_LENGTH", ap_content_length_filter,
4cf1c07a88ef51e11570c775507cd7d2c3e35a97slive NULL, AP_FTYPE_PROTOCOL);
4cf1c07a88ef51e11570c775507cd7d2c3e35a97slive ap_core_output_filter_handle =
4cf1c07a88ef51e11570c775507cd7d2c3e35a97slive ap_register_output_filter("CORE", ap_core_output_filter,
4cf1c07a88ef51e11570c775507cd7d2c3e35a97slive NULL, AP_FTYPE_NETWORK);
4cf1c07a88ef51e11570c775507cd7d2c3e35a97slive ap_subreq_core_filter_handle =
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener ap_register_output_filter("SUBREQ_CORE", ap_sub_req_output_filter,
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener NULL, AP_FTYPE_CONTENT_SET);
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener ap_old_write_func =
18ee8bb3db5cc3b04291f89301bd5d14dc271066lgentis ap_register_output_filter("OLD_WRITE", ap_old_write_filter,
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener NULL, AP_FTYPE_RESOURCE - 10);
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener}
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener
ffec3e56ff5331a2d732ec07e9d107303fed43f4covenerAP_DECLARE_MODULE(core) = {
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener MPM20_MODULE_STUFF,
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener AP_PLATFORM_REWRITE_ARGS_HOOK, /* hook to run before apache parses args */
18ee8bb3db5cc3b04291f89301bd5d14dc271066lgentis create_core_dir_config, /* create per-directory config structure */
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener merge_core_dir_configs, /* merge per-directory config structures */
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener create_core_server_config, /* create per-server config structure */
e6ab342447cf6b4c22bbe66169718d0e9b78819apoirier merge_core_server_configs, /* merge per-server config structures */
130d299c4b2b15be45532a176604c71fdc7bea5bnd core_cmds, /* command apr_table_t */
130d299c4b2b15be45532a176604c71fdc7bea5bnd register_hooks /* register hooks */
130d299c4b2b15be45532a176604c71fdc7bea5bnd};
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive