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 * 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.
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "http_protocol.h" /* For index_of_response(). Grump. */
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "http_main.h" /* For the default_handler below... */
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna#include "mod_so.h" /* for ap_find_loaded_module_symbol */
4e9f8c5414e5fe39b5393641533edca65f6e8b91poirier#if defined(RLIMIT_CPU) || defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) || defined (RLIMIT_NPROC)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna/* LimitRequestBody handling */
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna/* LimitXMLRequestBody handling */
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna/* maximum include nesting level */
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 * 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 * This file could almost be mod_core.c, except for the stuff which affects
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe * the http_conf_globals.
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/* Provide ap_document_root_check storage and default value = true */
5ae609a8a09239d20f48a4a95c4f21b713995babwrowe/* magic pointer for ErrorDocument xxx "default" */
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorstatic void *create_core_dir_config(apr_pool_t *a, char *dir)
7e8f5c6496b3825b6b128e2aacc4b1b09d28553dpquerna conf = (core_dir_config *)apr_pcalloc(a, sizeof(core_dir_config));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* conf->r and conf->d[_*] are initialized by dirsection() or left NULL */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->override_opts = OPT_UNSET | OPT_ALL | OPT_SYM_OWNER | OPT_MULTI;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->use_canonical_phys_port = USE_CANONICAL_PHYS_PORT_UNSET;
fb77c505254b6e9c925e23e734463e87574f8f40kess#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->sec_file = apr_array_make(a, 2, sizeof(ap_conf_vector_t *));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->add_default_charset = ADD_DEFAULT_CHARSET_UNSET;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* Overriding all negotiation
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Flag for use of inodes in ETags.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return (void *)conf;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* Create this conf by duplicating the base, replacing elements
130d299c4b2b15be45532a176604c71fdc7bea5bnd * (or creating copies for merging) where new-> values exist.
ef8e89e090461194ecadd31e8796a2c51e0531a2kess conf = (core_dir_config *)apr_pmemdup(a, base, sizeof(core_dir_config));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* there was no explicit setting of new->opts, so we merge
003f0c9fda6664daf5092a0e42f65ede20098153slive * preserve the invariant (opts_add & opts_remove) == 0
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts_add = (conf->opts_add & ~new->opts_remove) | new->opts_add;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts_remove = (conf->opts_remove & ~new->opts_add)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->opts = (conf->opts & ~conf->opts_remove) | conf->opts_add;
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. */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* otherwise we just copy, because an explicit opts setting
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * overrides all earlier +/- modifiers
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->response_code_strings = new->response_code_strings;
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding /* If we merge, the merge-result must have it's own array
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sizeof(*conf->response_code_strings) * RESPONSE_CODES);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive for (i = 0; i < RESPONSE_CODES; ++i) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->response_code_strings[i] = new->response_code_strings[i];
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding /* Otherwise we simply use the base->response_code_strings array
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding if (new->use_canonical_name != USE_CANONICAL_NAME_UNSET) {
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding if (new->use_canonical_phys_port != USE_CANONICAL_PHYS_PORT_UNSET) {
843a03fe0b138a4c1f64cb90a014e9417ac30691fielding conf->use_canonical_phys_port = new->use_canonical_phys_port;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier /* If we merge, the merge-result must have it's own array
77ead9e0262e4f08ec336d1a65b2edef7705c839nd conf->sec_file = apr_array_append(a, base->sec_file, new->sec_file);
77ead9e0262e4f08ec336d1a65b2edef7705c839nd /* Otherwise we simply use the base->sec_file array
77ead9e0262e4f08ec336d1a65b2edef7705c839nd if (new->add_default_charset != ADD_DEFAULT_CHARSET_UNSET) {
77ead9e0262e4f08ec336d1a65b2edef7705c839nd conf->add_default_charset_name = new->add_default_charset_name;
003f0c9fda6664daf5092a0e42f65ede20098153slive /* Overriding all negotiation
b12b918ae6baf9c5762ed61b7393d0e2198378c0nd * Now merge the setting of the FileETag directive.
113961f0559eb026ea0d379cb7350f82bc09d710druggeri (conf->etag_add & (~ new->etag_remove)) | new->etag_add;
113961f0559eb026ea0d379cb7350f82bc09d710druggeri (conf->etag_remove & (~ new->etag_add)) | new->etag_remove;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (conf->etag_bits & (~ conf->etag_remove)) | conf->etag_add;
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz if (new->enable_sendfile != ENABLE_SENDFILE_UNSET) {
1f53e295ebd19aed1767d12da7abfab9936c148cjerenkrantz conf->allow_encoded_slashes = new->allow_encoded_slashes;
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding return (void*)conf;
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem#if __FreeBSD_version < 411000 /* httpready broken before 4.1.1 */
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluemstatic void *create_core_server_config(apr_pool_t *a, server_rec *s)
5528d1a30ae8560e2d7a96d734ffe31500dc6113rpluem conf = (core_server_config *)apr_pcalloc(a, sizeof(core_server_config));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* global-default / global-only settings */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* A mapping only makes sense in the global context */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_table_setn(conf->accf_map, "http", ACCEPT_FILTER_NAME);
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;
9ed9eaf871c58d281af02e76125ceadb5060afa5nd /* initialization, no special case for global context */
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 /* pcalloc'ed - we have NULL's/0's
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->gprof_dir = NULL;
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna ** recursion stopper; 0 == unset
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna conf->redirect_limit = 0;
f23fb63b05f89f47d7a3099491f2c68dcce432e9kess conf->subreq_limit = 0;
9970ad80054f477c708284a0d030a5bd26e412a9covener conf->protocol = NULL;
9970ad80054f477c708284a0d030a5bd26e412a9covener return (void *)conf;
9970ad80054f477c708284a0d030a5bd26e412a9covenerstatic void *merge_core_server_configs(apr_pool_t *p, void *basev, void *virtv)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *base = (core_server_config *)basev;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *virt = (core_server_config *)virtv;
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);
86120957a14f91da0a1a103eaf4d7710b1dd9e2asf /* no action for virt->accf_map, not allowed per-vhost */
113961f0559eb026ea0d379cb7350f82bc09d710druggeri/* Add per-directory configuration entry (for <directory> section);
113961f0559eb026ea0d379cb7350f82bc09d710druggeri * these are part of the core server config.
113961f0559eb026ea0d379cb7350f82bc09d710druggeriAP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri core_server_config *sconf = ap_get_module_config(s->module_config,
113961f0559eb026ea0d379cb7350f82bc09d710druggeri void **new_space = (void **)apr_array_push(sconf->sec_dir);
113961f0559eb026ea0d379cb7350f82bc09d710druggeriAP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri core_server_config *sconf = ap_get_module_config(s->module_config,
113961f0559eb026ea0d379cb7350f82bc09d710druggeri void **new_space = (void **)apr_array_push(sconf->sec_url);
113961f0559eb026ea0d379cb7350f82bc09d710druggeriAP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config)
113961f0559eb026ea0d379cb7350f82bc09d710druggeri void **new_space = (void **)apr_array_push(conf->sec_file);
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).
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int reorder_sorter(const void *va, const void *vb)
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes core_a = ap_get_module_config(a->elt, &core_module);
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes /* a regex always sorts after a non-regex
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess /* we always sort next by the number of components
4c7bdb15764021d39e486adb7bc2166d3f683773bnicholes if (core_a->d_components < core_b->d_components) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (core_a->d_components > core_b->d_components) {
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.)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivevoid ap_core_reorder_directories(apr_pool_t *p, server_rec *s)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive sconf = ap_get_module_config(s->module_config, &core_module);
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 /* we have to allocate tmp space to do a stable sort */
fb77c505254b6e9c925e23e734463e87574f8f40kess sortbin = apr_palloc(tmp, sec_dir->nelts * sizeof(*sortbin));
fb77c505254b6e9c925e23e734463e87574f8f40kess for (i = 0; i < nelts; ++i) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive qsort(sortbin, nelts, sizeof(*sortbin), reorder_sorter);
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding /* and now copy back to the original array */
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding for (i = 0; i < nelts; ++i) {
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
e4881891552e185a7408318dfc7f62ebabe73cf6niq (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fielding conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl * Optional function coming from mod_authn_core, used for
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl * retrieving the type of autorization
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsfstatic APR_OPTIONAL_FN_TYPE(authn_ap_auth_type) *authn_ap_auth_type;
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf * Optional function coming from mod_authn_core, used for
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf * retrieving the authorization realm
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsfstatic APR_OPTIONAL_FN_TYPE(authn_ap_auth_name) *authn_ap_auth_name;
141fd59714368d3bbe3a3d8f5b8dc8a516c48f9fsf * Optional function coming from mod_access_compat, used to determine how
cba8c0896ba04d42cf9a9e50df5040fd6bae14a4sf access control interacts with authentication/authorization
cba8c0896ba04d42cf9a9e50df5040fd6bae14a4sfstatic APR_OPTIONAL_FN_TYPE(access_compat_ap_satisfies) *access_compat_ap_satisfies;
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_document_root(request_rec *r) /* Don't use this! */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf = (core_server_config *)ap_get_module_config(r->server->module_config,
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).
003f0c9fda6664daf5092a0e42f65ede20098153slivechar *ap_response_code_string(request_rec *r, int error_index)
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* check for string registered via ap_custom_response() first */
130d299c4b2b15be45532a176604c71fdc7bea5bnd reqconf = (core_request_config *)ap_get_module_config(r->request_config,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* check for string specified via ErrorDocument */
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen dirconf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
030108b1816bcda3d925df65357feabdce83bc94slive if (dirconf->response_code_strings[error_index] == &errordocument_default) {
fb77c505254b6e9c925e23e734463e87574f8f40kess/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */
fb77c505254b6e9c925e23e734463e87574f8f40kessstatic APR_INLINE void do_double_reverse (conn_rec *conn)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* already done */
130d299c4b2b15be45532a176604c71fdc7bea5bnd if (conn->remote_host == NULL || conn->remote_host[0] == '\0') {
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* single reverse failed, so don't bother */
130d299c4b2b15be45532a176604c71fdc7bea5bnd rv = apr_sockaddr_info_get(&sa, conn->remote_host, APR_UNSPEC, 0, 0, conn->pool);
130d299c4b2b15be45532a176604c71fdc7bea5bnd while (sa) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* If we haven't checked the host name, and we want to */
130d299c4b2b15be45532a176604c71fdc7bea5bnd ((core_dir_config *)ap_get_module_config(dir_config, &core_module))
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess /* the default */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (apr_getnameinfo(&conn->remote_host, conn->remote_addr, 0)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* if failed, set it to the NULL string to indicate error */
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).
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (conn->remote_host != NULL && conn->remote_host[0] != '\0') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (type == REMOTE_HOST || type == REMOTE_DOUBLE_REV) {
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd * Optional function coming from mod_ident, used for looking up ident user
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic APR_OPTIONAL_FN_TYPE(ap_ident_lookup) *ident_lookup;
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_get_remote_logname(request_rec *r)
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 * 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
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_get_server_name(request_rec *r)
003f0c9fda6664daf5092a0e42f65ede20098153slive const char *retval;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive retval = r->hostname ? r->hostname : r->server->server_hostname;
1b01d1ee11c612226cb3141eed4581dc179266c1rbowen "ap_get_server_name: Invalid UCN Option somehow");
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]").
6b15044d54a096e6323ff1540f1a491e8de7622dsfAP_DECLARE(const char *) ap_get_server_name_for_url(request_rec *r)
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (ap_strchr_c(plain_server_name, ':')) { /* IPv6 literal? */
6b15044d54a096e6323ff1540f1a491e8de7622dsfAP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r)
6b15044d54a096e6323ff1540f1a491e8de7622dsf (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
6b15044d54a096e6323ff1540f1a491e8de7622dsf switch (d->use_canonical_name) {
6b15044d54a096e6323ff1540f1a491e8de7622dsf if (d->use_canonical_phys_port == USE_CANONICAL_PHYS_PORT_ON)
6b15044d54a096e6323ff1540f1a491e8de7622dsf r->connection->local_addr->port ? r->connection->local_addr->port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf else /* USE_CANONICAL_PHYS_PORT_OFF or USE_CANONICAL_PHYS_PORT_UNSET */
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 if (d->use_canonical_phys_port == USE_CANONICAL_PHYS_PORT_ON)
6b15044d54a096e6323ff1540f1a491e8de7622dsf r->connection->local_addr->port ? r->connection->local_addr->port :
6b15044d54a096e6323ff1540f1a491e8de7622dsf else /* USE_CANONICAL_PHYS_PORT_OFF or USE_CANONICAL_PHYS_PORT_UNSET */
6b15044d54a096e6323ff1540f1a491e8de7622dsf "ap_get_server_port: Invalid UCN Option somehow");
6b15044d54a096e6323ff1540f1a491e8de7622dsfAP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri,
6b15044d54a096e6323ff1540f1a491e8de7622dsf return apr_pstrcat(p, ap_http_scheme(r), "://", host, uri, NULL);
6b15044d54a096e6323ff1540f1a491e8de7622dsf return apr_psprintf(p, "%s://%s:%u%s", ap_http_scheme(r), host, port, uri);
6b15044d54a096e6323ff1540f1a491e8de7622dsfAP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r)
6b15044d54a096e6323ff1540f1a491e8de7622dsf (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
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.
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)
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd /* ### it would be nice to have atom-ized directives */
af18698b10b429b270551ca3a5d51a75e1c9db22brianpAP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
13cbe1d8f52c8097cb581e7eb259693b64d41d10poirier if ((forbidden & NOT_IN_VIRTUALHOST) && cmd->server->is_virtual) {
fb77c505254b6e9c925e23e734463e87574f8f40kess " cannot occur within <Limit> or <LimitExcept> "
41ef8b3051855b802104193ee0a587515af60a37wrowe if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE) {
41ef8b3051855b802104193ee0a587515af60a37wrowe " cannot occur within <Directory/Location/Files> "
41ef8b3051855b802104193ee0a587515af60a37wrowe /* EXEC_ON_READ must be NOT_IN_DIR_LOC_FILE, if not, it will
41ef8b3051855b802104193ee0a587515af60a37wrowe * (deliberately) segfault below in the individual tests...
fb77c505254b6e9c925e23e734463e87574f8f40kess && ((found = find_parent(cmd->directive, "<Directory"))
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf || (found = find_parent(cmd->directive, "<DirectoryMatch"))))
41ef8b3051855b802104193ee0a587515af60a37wrowe && ((found = find_parent(cmd->directive, "<Location"))
41ef8b3051855b802104193ee0a587515af60a37wrowe || (found = find_parent(cmd->directive, "<LocationMatch"))))
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf || (found = find_parent(cmd->directive, "<FilesMatch"))))) {
41ef8b3051855b802104193ee0a587515af60a37wrowestatic const char *set_access_name(cmd_parms *cmd, void *dummy,
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick const char *arg)
41ef8b3051855b802104193ee0a587515af60a37wrowe core_server_config *conf = ap_get_module_config(sconf, &core_module);
41ef8b3051855b802104193ee0a587515af60a37wrowe const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
9c233808c898095865fcc0a2dc1cf594d0d8faf3sfstatic const char *set_define(cmd_parms *cmd, void *dummy,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess const char *optarg)
41ef8b3051855b802104193ee0a587515af60a37wrowe const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
9c233808c898095865fcc0a2dc1cf594d0d8faf3sf char **newv = (char **)apr_array_push(ap_server_config_defines);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessstatic const char *unset_define(cmd_parms *cmd, void *dummy,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess const char *optarg)
41ef8b3051855b802104193ee0a587515af60a37wrowe const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
832853bb93c1831daf24e4727c5ca0e1b1786e83lars for (i = 0; i < ap_server_config_defines->nelts; i++) {
af18698b10b429b270551ca3a5d51a75e1c9db22brianp defines[i] = apr_array_pop(ap_server_config_defines);
79c754eb51681c3389cd966753e902c429f78939trawickstatic const char *generate_error(cmd_parms *cmd, void *dummy,
79c754eb51681c3389cd966753e902c429f78939trawick const char *arg)
79c754eb51681c3389cd966753e902c429f78939trawick return "The Error directive was used with no message.";
79c754eb51681c3389cd966753e902c429f78939trawick if (*arg == '"' || *arg == '\'') { /* strip off quotes */
79c754eb51681c3389cd966753e902c429f78939trawickstatic const char *set_gprof_dir(cmd_parms *cmd, void *dummy, const char *arg)
79c754eb51681c3389cd966753e902c429f78939trawick core_server_config *conf = ap_get_module_config(sconf, &core_module);
79c754eb51681c3389cd966753e902c429f78939trawick const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
003f0c9fda6664daf5092a0e42f65ede20098153slive#endif /*GPROF*/
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *set_add_default_charset(cmd_parms *cmd,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive d->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_document_root(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(sconf, &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslive /* When ap_document_root_check is false; skip all the stuff below */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* Make it absolute, relative to ServerRoot */
f7fe99050600166042c04b8e595fb75499eed7f0geoff return "DocumentRoot must be a directory";
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen /* TODO: ap_configtestonly */
f7fe99050600166042c04b8e595fb75499eed7f0geoff if (apr_filepath_merge((char**)&conf->ap_document_root, NULL, arg,
f7fe99050600166042c04b8e595fb75499eed7f0geoff "Warning: DocumentRoot [%s] does not exist",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "DocumentRoot must be a directory";
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(void) ap_custom_response(request_rec *r, int status,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *string)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_get_module_config(r->request_config, &core_module);
fb77c505254b6e9c925e23e734463e87574f8f40kess sizeof(*conf->response_code_strings) * RESPONSE_CODES);
9b5e2c5e769dc678a1aca06df75c32022b2f1492trawick ((ap_is_url(string) || (*string == '/')) && (*string != '"')) ?
fb77c505254b6e9c925e23e734463e87574f8f40kess apr_pstrdup(r->pool, string) : apr_pstrcat(r->pool, "\"", string, NULL);
69fba5b8aa0b0dc408f649cfdaab064ce120b05bslivestatic const char *set_error_document(cmd_parms *cmd, void *conf_,
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor /* 1st parameter should be a 3 digit number, which we recognize;
b5d3d68a9f683722eac7a3ca507c3e571908dfc0rbowen * convert it into an array index
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen idx500 = ap_index_of_response(HTTP_INTERNAL_SERVER_ERROR);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if ((index_number = ap_index_of_response(error_number)) == idx500) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->pool, "Unsupported HTTP response code ",
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* Heuristic to determine second argument. */
fb109b84906e3ee61680aa289953c2f9e859354erbowen /* The entry should be ignored if it is a full URL for a 401 error */
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 else { /* Store it... */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* special case: ErrorDocument 404 default restores the
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * canned server error response
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->response_code_strings[index_number] = &errordocument_default;
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 conf->response_code_strings[index_number] = (what == MSG) ?
2bac697634d965d9d9a921a99a68b2c454c8a95dbnicholesstatic const char *set_allow_opts(cmd_parms *cmd, allow_options_t *opts,
d950cf9262224a223e2ff5c51393708071e14b94covener const char *l)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char *w, *p = (char *) l;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while ((w = apr_strtok(p, ",", &tok_state)) != NULL) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* If Includes is permitted, both Includes and
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * IncludesNOEXEC may be changed. */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (!strcasecmp(w, "RunScripts")) { /* AI backcompat. Yuck */
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf return apr_pstrcat(cmd->pool, "Illegal option ", w, NULL);
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsfstatic const char *set_override(cmd_parms *cmd, void *d_, const char *l)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf char *k, *v;
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 "Useless use of AllowOverride in line %d of %s.",
e302f38fd646764ce1a1e1c578d794aef514a9e5sf while (l[0]) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf *v++ = '\0';
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return apr_pstrcat(cmd->pool, "Illegal override option ", w, NULL);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic const char *set_options(cmd_parms *cmd, void *d_, const char *l)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf while (l[0]) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf else if (first) {
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf else if (!strcasecmp(w, "RunScripts")) { /* AI backcompat. Yuck */
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf return apr_pstrcat(cmd->pool, "Illegal option ", w, NULL);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return apr_pstrcat(cmd->pool, "Option ", w, " not allowed here", NULL);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* we ensure the invariant (d->opts_add & d->opts_remove) == 0 */
a8ee031b2224ce5473826c9d4f603681589245fawrowestatic const char *set_default_type(cmd_parms *cmd, void *d_,
a8ee031b2224ce5473826c9d4f603681589245fawrowe const char *arg)
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 * 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.
34b157732214cedcd129cd9fe7c4290757505d60minfrinstatic const char *set_etag_bits(cmd_parms *cmd, void *mconfig,
34b157732214cedcd129cd9fe7c4290757505d60minfrin const char *args_p)
003f0c9fda6664daf5092a0e42f65ede20098153slive const char *args;
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 return apr_pstrcat(cmd->pool, cmd->cmd->name, " keyword '",
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess * Make sure it's in the 'add' list and absent from the
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess * 'subtract' list.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Non-relative values wipe out any + or - values
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * accumulated so far.
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd * Any setting at all will clear the 'None' and 'Unset' bits.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_enable_mmap(cmd_parms *cmd, void *d_,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess return "parameter must be 'on' or 'off'";
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *set_enable_sendfile(cmd_parms *cmd, void *d_,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "parameter must be 'on' or 'off'";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Report a missing-'>' syntax error.
fb77c505254b6e9c925e23e734463e87574f8f40kess * Report a missing args in '<Foo >' syntax error.
b24c77ceb4cea5ffa92536e19f0aa83608960dc4fieldingAP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd,
7654193c1faf603feec999850322ad79e6c551bcnd const char *arg)
7654193c1faf603feec999850322ad79e6c551bcnd const char *errmsg;
7654193c1faf603feec999850322ad79e6c551bcnd limited_methods = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
439acee10571861c670c438038a62f90a08bf137covener char *method = ap_getword_conf(cmd->temp_pool, &limited_methods);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor /* check for builtin or module registered method number */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "TRACE cannot be controlled by <Limit>, see TraceEnable";
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener /* method has not been registered yet, but resorce restriction
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener * is always checked before method handling, so register it.
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener /* Killing two features with one function,
c3e2e664a67b1adb9b6a6b91ff161f4f562cecf6covener * if (tog == NULL) <Limit>, else <LimitExcept>
fb77c505254b6e9c925e23e734463e87574f8f40kess "> directive specifies methods already excluded",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive errmsg = ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
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
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *errmsg;
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
750d12c59545dbbac70390988de94f7e901b08f2niq if (!arg[0]) {
6b15044d54a096e6323ff1540f1a491e8de7622dsf return "<Directory ~ > block must specify a path";
6b15044d54a096e6323ff1540f1a491e8de7622dsf r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
6b15044d54a096e6323ff1540f1a491e8de7622dsf return "Regex could not be compiled";
1a0ca5f6b566a5eb77d63f466fcf78fb388a4182igalic r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
1a0ca5f6b566a5eb77d63f466fcf78fb388a4182igalic return "Regex could not be compiled";
750d12c59545dbbac70390988de94f7e901b08f2niq * Ensure that the pathname is canonical, and append the trailing /
94aba9caa9b2f7a0e95a55f51264c908b69470e2igalic apr_status_t rv = apr_filepath_merge(&newpath, NULL, cmd->path,
6b15044d54a096e6323ff1540f1a491e8de7622dsf return apr_pstrcat(cmd->pool, "<Directory \"", cmd->path,
6b15044d54a096e6323ff1540f1a491e8de7622dsf cmd->path = apr_pstrcat(cmd->pool, cmd->path, "/", NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* initialize our config and fetch it */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf = ap_set_config_vectors(cmd->server, new_dir_conf, cmd->path,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_dir_conf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->d_is_fnmatch = (apr_fnmatch_test(conf->d) != 0);
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.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodlstatic const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
6e483e0b8aa3fa574288a7452221392a03e2b9a3noodl const char *errmsg;
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);
955d7fc3e7adb6463b7243e15c04e858718e799etakashi arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
955d7fc3e7adb6463b7243e15c04e858718e799etakashi r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
955d7fc3e7adb6463b7243e15c04e858718e799etakashi return "Regex could not be compiled";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "Regex could not be compiled";
55d36f9b61520c2374ab463e77e8a62daa416398nd /* initialize our config and fetch it */
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess conf = ap_set_config_vectors(cmd->server, new_url_conf, cmd->path,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_url_conf);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf->d = apr_pstrdup(cmd->pool, cmd->path); /* No mangling, please */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
55d36f9b61520c2374ab463e77e8a62daa416398nd const char *errmsg;
55d36f9b61520c2374ab463e77e8a62daa416398nd ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
bea526116133aa3d7dabd1924bfc580b37fbf22aslive if (!arg[0]) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* Only if not an .htaccess file */
003f0c9fda6664daf5092a0e42f65ede20098153slive r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return "Regex could not be compiled";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return "Regex could not be compiled";
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin /* Ensure that the pathname is canonical, but we
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin * can't test the case/aliases without a fixed path */
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return apr_pstrcat(cmd->pool, "<Files \"", cmd->path,
3621f3acee323a877639a96d84891095eb07933aminfrin /* initialize our config and fetch it */
3621f3acee323a877639a96d84891095eb07933aminfrin conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path,
3621f3acee323a877639a96d84891095eb07933aminfrin errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
3621f3acee323a877639a96d84891095eb07933aminfrin conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
7b5535ed88e0f561b3bfb3330137bd804846afd4slivestatic const char *ifsection(cmd_parms *cmd, void *mconfig, const char *arg)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *errmsg;
7b5535ed88e0f561b3bfb3330137bd804846afd4slive ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
cf8a8738330694e60bad421fcc8361d80b0e9124minfrin const char *condition;
3621f3acee323a877639a96d84891095eb07933aminfrin const char *expr_err;
3621f3acee323a877639a96d84891095eb07933aminfrin arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
3621f3acee323a877639a96d84891095eb07933aminfrin /* Only if not an .htaccess file */
03aa31ad82759363ba1a55589e517b16308ef635minfrin /* initialize our config and fetch it */
03aa31ad82759363ba1a55589e517b16308ef635minfrin conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path,
03aa31ad82759363ba1a55589e517b16308ef635minfrin conf->condition = ap_expr_parse_cmd(cmd, condition, &expr_err, NULL);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_psprintf(cmd->pool, "Cannot parse condition clause: %s", expr_err);
fb77c505254b6e9c925e23e734463e87574f8f40kess errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic module *find_module(server_rec *s, const char *name)
891df99fdfa41fc8a486568f4d31ddf4a571258adreid /* search prelinked stuff */
59368b594c9b09b59ae58c7de26d2d5ce1c99a29takashi ap_module_symbol_t *current = ap_prelinked_module_symbols;
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick /* search dynamic stuff */
9f38f3ec3e8087985d108a24ae796962fef83644takashi APR_OPTIONAL_FN_TYPE(ap_find_loaded_module_symbol) *check_symbol =
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick APR_RETRIEVE_OPTIONAL_FN(ap_find_loaded_module_symbol);
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen * There are two phases where calling ap_find_loaded_module_symbol
98f5034c8cbf2ef025b317b3e01acae82e143b11trawick * is problematic:
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 * 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 * Therefore we use s if it is not virtual and ap_server_conf if
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor * s is virtual.
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener found = check_symbol(s->is_virtual ? ap_server_conf : s, name);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg)
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (!arg[0]) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd const char *retval;
130d299c4b2b15be45532a176604c71fdc7bea5bnd retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisdAP_DECLARE(int) ap_exists_config_define(const char *name)
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd for (i = 0; i < ap_server_config_defines->nelts; i++) {
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisdstatic const char *start_ifdefine(cmd_parms *cmd, void *dummy, const char *arg)
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd const char *endp;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd int defined;
7245e9b991db85d9d9a587fe5f4051f642ebdc3cchrisd const char *retval;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* httpd.conf commands... beginning with the <VirtualHost> business */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *virtualhost_section(cmd_parms *cmd, void *dummy,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen const char *arg)
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen const char *errmsg;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
7ef9b6763ad87846cf83c3f71467f43e349d080aerikabele arg = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
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 return "<VirtualHost> doesn't nest!";
03e0a375c2435102fb2b51e34cccff52acbfddcdnd errmsg = ap_walk_config(cmd->directive->first_child, cmd,
03e0a375c2435102fb2b51e34cccff52acbfddcdndstatic const char *set_server_alias(cmd_parms *cmd, void *dummy,
03e0a375c2435102fb2b51e34cccff52acbfddcdnd const char *arg)
03e0a375c2435102fb2b51e34cccff52acbfddcdnd return "ServerAlias only used in <VirtualHost>";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while (*arg) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive char **item, *name = ap_getword_conf(cmd->pool, &arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive item = (char **)apr_array_push(cmd->server->wild_names);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_accf_map(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(cmd->server->module_config,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowenAP_DECLARE(const char*) ap_get_server_protocol(server_rec* s)
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen core_server_config *conf = ap_get_module_config(s->module_config,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowenAP_DECLARE(void) ap_set_server_protocol(server_rec* s, const char* proto)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(s->module_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_protocol(cmd_parms *cmd, void *dummy,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *arg)
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,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_server_string_slot(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* This one's pretty generic... */
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
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *server_hostname_port(cmd_parms *cmd, void *dummy, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen cmd->server->server_hostname = apr_pstrndup(cmd->pool, part,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen return apr_pstrcat(cmd->temp_pool, "The port number \"", arg,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen "\" is outside the appropriate range "
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor cmd->server->server_hostname = apr_pstrdup(cmd->pool, part);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_signature_flag(cmd_parms *cmd, void *d_,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "ServerSignature: use one of: off | on | email";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_server_root(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen if ((apr_filepath_merge((char**)&ap_server_root, NULL, arg,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen || !ap_is_directory(cmd->temp_pool, ap_server_root)) {
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covener return "ServerRoot must be a valid directory";
611f7fd8a0a5ee4a29eeed79dfd8bf6faaa3c613covenerstatic const char *set_timeout(cmd_parms *cmd, void *dummy, const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_allow2f(cmd_parms *cmd, void *d_, int arg)
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *set_hostname_lookups(cmd_parms *cmd, void *d_,
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "parameter must be 'on', 'off', or 'double'";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_serverpath(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
d950cf9262224a223e2ff5c51393708071e14b94covenerstatic const char *set_content_md5(cmd_parms *cmd, void *d_, int arg)
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorstatic const char *set_accept_path_info(cmd_parms *cmd, void *d_, const char *arg)
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor return "AcceptPathInfo must be set to on, off or default";
d950cf9262224a223e2ff5c51393708071e14b94covenerstatic const char *set_use_canonical_name(cmd_parms *cmd, void *d_,
d950cf9262224a223e2ff5c51393708071e14b94covener const char *arg)
dc223428958ad9ff05011545bcdda000887b93e5slive return "parameter must be 'on', 'off', or 'dns'";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_use_canonical_phys_port(cmd_parms *cmd, void *d_,
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess const char *arg)
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor d->use_canonical_phys_port = USE_CANONICAL_PHYS_PORT_ON;
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd d->use_canonical_phys_port = USE_CANONICAL_PHYS_PORT_OFF;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "parameter must be 'on' or 'off'";
37742b630743e470b94618ecb3560fbd82e50b59rbowenstatic const char *include_config (cmd_parms *cmd, void *dummy,
37742b630743e470b94618ecb3560fbd82e50b59rbowen const char *name)
130d299c4b2b15be45532a176604c71fdc7bea5bnd apr_pool_userdata_get(&data, "ap_include_sentinel", cmd->pool);
130d299c4b2b15be45532a176604c71fdc7bea5bnd data = recursion = apr_palloc(cmd->pool, sizeof(*recursion));
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd apr_pool_userdata_setn(data, "ap_include_sentinel", NULL, cmd->pool);
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd return apr_psprintf(cmd->pool, "Exceeded maximum include depth of %u, "
05201775eaa6b363b8a119c8aea5db246b967591yoshiki "There appears to be a recursion.",
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd error = ap_process_fnmatch_configs(cmd->server, conffile, &conftree,
37742b630743e470b94618ecb3560fbd82e50b59rbowen /* recursion level done */
8490b2f9f6469d5089163f6dd303d9a81f8e908ctrawickstatic const char *set_loglevel(cmd_parms *cmd, void *config_, const char *arg_)
6b64034fa2a644ba291c484c0c01c7df5b8d982ckess const char *err;
030108b1816bcda3d925df65357feabdce83bc94slive /* XXX: what check is necessary here? */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
7fbd7281d06cec1918aa370214df77c572f871a9sf return "LogLevel requires level keyword or module loglevel specifier";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
1597043cec6ad37fa4154bf09b0fccdabed1a239slive return apr_psprintf(cmd->temp_pool, "Module specifier '%s' must be "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_psprintf(cmd->temp_pool, "%s:%s: %s", arg, level_str, err);
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 return apr_psprintf(cmd->temp_pool, "Cannot find module %s", arg);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_set_module_loglevel(cmd->pool, log, module->module_index, level);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_snprintf(sport, sizeof sport, "%u", (unsigned) ap_get_server_port(r));
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive " Server at <a href=\"",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(r->pool, prefix, "<address>", ap_get_server_banner(),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive " Server at ",
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
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int banner_locked = 0;
7fbd7281d06cec1918aa370214df77c572f871a9sf SrvTk_FULL, /* eg: Apache/2.0.41 (UNIX) PHP/4.2.2 FooBar/1.2b */
7fbd7281d06cec1918aa370214df77c572f871a9sfstatic enum server_token_type ap_server_tokens = SrvTk_FULL;
7fbd7281d06cec1918aa370214df77c572f871a9sfAP_DECLARE(void) ap_get_server_revision(ap_version_t *version)
7fbd7281d06cec1918aa370214df77c572f871a9sf return server_banner ? server_banner : AP_SERVER_BASEVERSION;
7fbd7281d06cec1918aa370214df77c572f871a9sfAP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *component)
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 * Tack the given component identifier to the end of
7fbd7281d06cec1918aa370214df77c572f871a9sf * the existing string.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive server_description = apr_pstrcat(pconf, server_description, " ",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * This routine adds the real server base identity to the banner string,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * and then locks out changes until the next reconfig.
d3f27ec18dfa6283e852aa98253212edafaa0e2brbowen ap_add_version_component(pconf, AP_SERVER_BASEPRODUCT);
8b052d682204371decc64f942aede5ef1da98955erikabele ap_add_version_component(pconf, AP_SERVER_BASEPRODUCT "/" AP_SERVER_MINORREVISION);
8b052d682204371decc64f942aede5ef1da98955erikabele ap_add_version_component(pconf, AP_SERVER_BASEPRODUCT "/" AP_SERVER_MAJORVERSION);
7fbd7281d06cec1918aa370214df77c572f871a9sf ap_add_version_component(pconf, AP_SERVER_BASEVERSION " (" PLATFORM ")");
7fbd7281d06cec1918aa370214df77c572f871a9sf * Lock the server_banner string if we're not displaying
fd410ae1fa431e734e6d0cd3c006002d4904466apoirier * the full set of tokens
7fbd7281d06cec1918aa370214df77c572f871a9sf server_description = AP_SERVER_BASEVERSION " (" PLATFORM ")";
7fbd7281d06cec1918aa370214df77c572f871a9sfstatic const char *set_serv_tokens(cmd_parms *cmd, void *dummy,
7fbd7281d06cec1918aa370214df77c572f871a9sf const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
7fbd7281d06cec1918aa370214df77c572f871a9sf else if (!strcasecmp(arg1, "Min") || !strcasecmp(arg1, "Minimal")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else if (!strcasecmp(arg1, "Prod") || !strcasecmp(arg1, "ProductOnly")) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_limit_req_line(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (lim < 0) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return apr_pstrcat(cmd->temp_pool, "LimitRequestLine \"", arg,
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_req_fieldsize(cmd_parms *cmd, void *dummy,
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen const char *arg)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return apr_pstrcat(cmd->temp_pool, "LimitRequestFieldsize \"", arg,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick "\" must be a non-negative integer",
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_req_fields(cmd_parms *cmd, void *dummy,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return apr_pstrcat(cmd->temp_pool, "LimitRequestFields \"", arg,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick "\" must be a non-negative integer (0 = no limit)",
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_req_body(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg)
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick if (APR_SUCCESS != apr_strtoff(&conf->limit_req_body, arg, &errp, 10)) {
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick return "LimitRequestBody argument is not parsable.";
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick return "LimitRequestBody requires a non-negative integer.";
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorstatic const char *set_limit_xml_req_body(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick const char *arg)
bf0e7f6393e91c0a7c15cb0d889a4238c973dc2etrawick return "LimitXMLRequestBody requires a non-negative integer.";
a0fed3e26656887c8458aa1081d516d08ced3c84trawickAP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r)
a0fed3e26656887c8458aa1081d516d08ced3c84trawick conf = ap_get_module_config(r->per_dir_config, &core_module);
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 "%s not supported on this platform", cmd->cmd->name);
031bbbc0d1189b07330e38d0c126820a9ab7795egryzorstatic const char *set_limit_cpu(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_unixd_set_rlimit(cmd, &conf->limit_cpu, arg, arg2, RLIMIT_CPU);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_mem(cmd_parms *cmd, void *conf_,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2 ,RLIMIT_AS);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_DATA);
a0fed3e26656887c8458aa1081d516d08ced3c84trawick ap_unixd_set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_VMEM);
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_limit_nproc(cmd_parms *cmd, void *conf_,
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick ap_unixd_set_rlimit(cmd, &conf->limit_nproc, arg, arg2, RLIMIT_NPROC);
a0fed3e26656887c8458aa1081d516d08ced3c84trawickstatic const char *set_recursion_limit(cmd_parms *cmd, void *dummy,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick core_server_config *conf = ap_get_module_config(cmd->server->module_config,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick if (limit <= 0) {
a0fed3e26656887c8458aa1081d516d08ced3c84trawick return "The recursion limit must be greater than zero.";
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 if (limit <= 0) {
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick return "The recursion limit must be greater than zero.";
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 "r->uri = %s", r->uri ? r->uri : "(unexpectedly NULL)");
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick "redirected from r->uri = %s",
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick "subrequested from r->uri = %s",
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick * check whether redirect limit is reached
2b6c7b8eb5fbc43564898aedac730df7e91da475trawickAP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r)
2b6c7b8eb5fbc43564898aedac730df7e91da475trawick core_server_config *conf = ap_get_module_config(r->server->module_config,
a0fed3e26656887c8458aa1081d516d08ced3c84trawick /* uuh, too much. */
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 /* post backtrace */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* return failure */
3386d67e54f92fdf6a3ffc5f7f8081eed6c44badslive /* uuh, too much. */
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 /* post backtrace */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd /* return failure */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* recursion state: ok */
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic const char *set_trace_enable(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char *arg1)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(cmd->server->module_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive return "TraceEnable must be one of 'on', 'off', or 'extended'";
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cndstatic int log_constant_item(const ap_errorlog_info *info, const char *arg,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive const char **sa)
13e5182a0c199ecc7a73db97b6448a544e940868slive const char *s;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * non-leading white space terminates this string to allow the next field
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * separator to be inserted
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while (*s && *s != '%' && (*s != ' ' || at_start) && d < scratch + MAX_STRING_LEN) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess if (*s != '\\') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*s != ' ') {
13e5182a0c199ecc7a73db97b6448a544e940868slive *d++ = *s++;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive switch (*s) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *d++ = '\r';
96969ed53a757bd9e0a4d7f2f499c9db5ef7899eigalic *d++ = '\n';
96969ed53a757bd9e0a4d7f2f499c9db5ef7899eigalic *d++ = '\t';
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess case '\0':
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* handle end of string */
13e5182a0c199ecc7a73db97b6448a544e940868slive *d++ = '\\';
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* copy next char verbatim */
1c5fe3e61f0f3202ae0f853740d53f3aff4c4afbslive *d++ = *s++;
13e5182a0c199ecc7a73db97b6448a544e940868slivestatic char *parse_errorlog_item(apr_pool_t *p, ap_errorlog_format_item *it,
13e5182a0c199ecc7a73db97b6448a544e940868slive const char **sa)
13e5182a0c199ecc7a73db97b6448a544e940868slive const char *s = *sa;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*s != '%') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*s == ' ') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (*s == ' ') {
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* percent-space (% ) is a field separator */
130d299c4b2b15be45532a176604c71fdc7bea5bnd /* recurse */
130d299c4b2b15be45532a176604c71fdc7bea5bnd else if (*s == '%') {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive while (*s) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive switch (*s) {
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess i = *s - '0';
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess while (apr_isdigit(*++s))
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen handler = (ap_errorlog_handler *)apr_hash_get(errorlog_hash, s, 1);
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen return apr_pstrcat(p, "Unrecognized error log format directive %",
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen return "Ran off end of error log format parsing args to some directive";
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowenstatic apr_array_header_t *parse_errorlog_string(apr_pool_t *p,
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen const char *s,
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen const char **err,
9f19223e8fb7b99f5f1cc02c8c3c2c6567793262rbowen while (s && *s) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "once-per-connection formats";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if (is_main_fmt && item->flags & AP_ERRORLOG_FLAG_REQUIRED) {
ef8e89e090461194ecadd31e8796a2c51e0531a2kess *err = "The '+' flag cannot be used in the main error log format";
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen *err = "The loglevel cannot be used as a condition in "
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "once-per-request or once-per-connection formats";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *err = "The specified loglevel modifier is out of range";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *err = "main ErrorLogFormat must contain message format string '%M'";
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic const char *set_errorlog_format(cmd_parms *cmd, void *dummy,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive core_server_config *conf = ap_get_module_config(cmd->server->module_config,
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd conf->error_log_format = parse_errorlog_string(cmd->pool, arg1,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive e = (apr_array_header_t **) apr_array_push(conf->error_log_conn);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive *e = parse_errorlog_string(cmd->pool, arg2, &err_string, 0);
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 err_string = "ErrorLogFormat type must be one of request, connection";
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE(void) ap_register_errorlog_handler(apr_pool_t *p, char *tag,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_errorlog_handler *log_struct = apr_palloc(p, sizeof(*log_struct));
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen apr_hash_set(errorlog_hash, tag, 1, (const void *)log_struct);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* Note --- ErrorDocument will now work from .htaccess files.
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess * The AllowOverride of Fileinfo allows webmasters to turn it off
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess/* Old access config file commands */
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"),
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 "
003f0c9fda6664daf5092a0e42f65ede20098153sliveAP_INIT_RAW_ARGS("<LimitExcept", ap_limit_section, (void*)1,
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"),
4cafc94e99922f00654e1779d30c2cccf5278c4fkessAP_INIT_TAKE1("GprofDir", set_gprof_dir, NULL, RSRC_CONF,
4cafc94e99922f00654e1779d30c2cccf5278c4fkess "Directory to plop gmon.out files"),
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"),
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"),
27303c8bb552a8a5fc859feb735d686fc59f59a1yoshiki "Container for directives to be conditionally applied"),
96a8ac87abbb04c2a925f7fde5eb12bf1d1f4bc3slive/* Old resource config file commands */
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"),
a8ee031b2224ce5473826c9d4f603681589245fawrowe/* Old server config file commands */
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 "\"on\" to enable, \"off\" to disable reverse DNS lookups, or \"double\" to "
a8ee031b2224ce5473826c9d4f603681589245fawrowe "enable double-reverse DNS lookups"),
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.)"),
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"),
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 "How to work out the ServerName : Port when constructing URLs"),
a8ee031b2224ce5473826c9d4f603681589245fawroweAP_INIT_TAKE1("UseCanonicalPhysicalPort", set_use_canonical_phys_port, NULL,
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 */
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,
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 "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"),
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 "
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_INIT_RAW_ARGS("Mutex", ap_set_mutex, NULL, RSRC_CONF,
003f0c9fda6664daf5092a0e42f65ede20098153slive "mutex (or \"default\") and mechanism"),
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd/* System Resource Controls */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive OR_ALL, "Soft/hard limits for max CPU usage in seconds"),
0e4c8b384f21029c01f06824ec522bb2cbec1d0enoirin OR_ALL, "Soft/hard limits for max CPU usage in seconds"),
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined (RLIMIT_AS)
ffe8ed2cd88be2c415ddef11f50394c52df9190ctrawick OR_ALL, "Soft/hard limits for max memory usage per process"),
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd OR_ALL, "Soft/hard limits for max memory usage per process"),
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen OR_ALL, "soft/hard limits for max number of processes per uid"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive OR_ALL, "soft/hard limits for max number of processes per uid"),
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* internal recursion stopper */
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE12("LimitInternalRecursion", set_recursion_limit, NULL, RSRC_CONF,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "maximum recursion depth of internal redirects and subrequests"),
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"),
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"),
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'"),
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 * 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.
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"),
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE1("EnableExceptionHook", ap_mpm_set_exception_hook, NULL, RSRC_CONF,
e08ad1a326852610a7930269638a43657fc50d06sctemme "Controls whether exception hook may be called after a crash"),
e08ad1a326852610a7930269638a43657fc50d06sctemmeAP_INIT_TAKE1("TraceEnable", set_trace_enable, NULL, RSRC_CONF,
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor "'on' (default), 'off' or 'extended' to trace request body content"),
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim/*****************************************************************
e08ad1a326852610a7930269638a43657fc50d06sctemme * Core handlers for various phases of server operation...
80c4526970a11f37c0f8e3b82afdf03902dac3f3sliveAP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r)
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen core_server_config *conf = ap_get_module_config(sconf, &core_module);
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen /* XXX this seems too specific, this should probably become
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen * some general-case test
226aaa3e29f938600cd1b9dfb6774588d831d036rbowen if (!r->uri || ((r->uri[0] != '/') && strcmp(r->uri, "*"))) {
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && !strncmp(r->uri, r->server->path, r->server->pathlen)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* skip all leading /'s (e.g. http://localhost///foo)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * so we are looking at only the relative path.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive if ((rv = apr_filepath_merge(&r->filename, conf->ap_document_root, path,
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 /* skip all leading /'s (e.g. http://localhost///foo)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * so we are looking at only the relative path.
58e56a1d61ae176cc5ecb7c4863881736947d8b8rbowen if ((rv = apr_filepath_merge(&r->filename, conf->ap_document_root, path,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/*****************************************************************
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * Test the filesystem name through directory_walk and file_walk
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive (core_dir_config *)ap_get_module_config(r->per_dir_config,
23b36269d124e7a6aaa5221891f7ae2ef3eeb158jerenkrantz /* Check for overrides with ForceType / SetHandler
7b5535ed88e0f561b3bfb3330137bd804846afd4slive if (conf->mime_type && strcmp(conf->mime_type, "none"))
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.
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).
530eba85dbd41b8a0fa5255d3648d1440199a661slive d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive && r->output_filters->frec->ftype != AP_FTYPE_RESOURCE;
9e59849752ebadf803f76453fe3b64e2cee8d190rbowen ap_allow_standard_methods(r, MERGE_ALLOW, M_GET, M_OPTIONS, M_POST, -1);
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.
23b36269d124e7a6aaa5221891f7ae2ef3eeb158jerenkrantz if ((errstatus = ap_discard_request_body(r)) != OK) {
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor if (r->method_number == M_GET || r->method_number == M_POST) {
a21fb2799923b1c25a351f09e690bd46806f2fa2jim /* Don't try to serve a dir. Some OSs do weird things with
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * raw I/O on a dir.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* default to reject */
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen "File does not exist: %s",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive apr_pstrcat(r->pool, r->filename, r->path_info, NULL));
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 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. */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive req_cfg = ap_get_module_config(r->request_config, &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* The flag hasn't been set for this request. Punt. */
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess "This resource does not accept the %s method.",
a7f40ca49262952d6dd69d021cf5b0c2b452ae4cnd if ((status = apr_file_open(&fd, r->filename, APR_READ | APR_BINARY
db1b819ff8966e3c6a5ca03c59a8ae06c2cecc9frbowen apr_table_setn(r->headers_out, "Accept-Ranges", "bytes");
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive e = apr_brigade_insert_file(bb, fd, 0, r->finfo.size, r->pool);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* no way to know what type of error occurred */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "default_handler: ap_pass_brigade returned %i",
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive else { /* unusual method (not GET or POST) */
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 && (r->the_request[1] == 0x2 || r->the_request[1] == 0x3)) {
130d299c4b2b15be45532a176604c71fdc7bea5bnd "Invalid method in request %s - possible attempt to establish SSL connection on non-SSL port", r->the_request);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive/* Optional function coming from mod_logio, used for logging of output
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;
fa71303e53e7ef460728446b8290d05ed0895136trawick/* Insist that at least one module will undertake to provide system
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * security by dropping startup privileges.
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jortonstatic int sys_privileges = 0;
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic int core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
b91096bcdd71fcbb37c9905f6cf79e930ae349b1jortonstatic int core_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
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);
f59a2b72270d63d121d6a1a01d85fb87d8a8bb45rbowen "Server MUST relinquish startup privileges before "
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe "accepting connections. Please ensure mod_unixd "
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe "or other system security module is loaded.");
031bbbc0d1189b07330e38d0c126820a9ab7795egryzor while (*filters && (filter = ap_getword(r->pool, &filters, ';'))) {
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe while (*filters && (filter = ap_getword(r->pool, &filters, ';'))) {
b00fe3c3354db01001b8eddfd9b88441380f837dwrowe apr_pool_cleanup_register(apr_hook_global_pool, NULL, reset_request_notes,
fb77c505254b6e9c925e23e734463e87574f8f40kessAP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num)
313bb560bc5c323cfd40c9cad7335b4b8e060aedkess /* Alloc the config struct and the array of request notes in
3c6c63407f1855ddfc45ac69b69a2a9bf15135e6rbowen * a single block for efficiency
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));
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen /* ### temporarily enable script delivery as the default */
ffe8ed2cd88be2c415ddef11f50394c52df9190ctrawick core_request_config *main_req_cfg = (core_request_config *)
3c6c63407f1855ddfc45ac69b69a2a9bf15135e6rbowen ap_get_module_config(r->main->request_config, &core_module);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive req_cfg->bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive ap_set_module_config(r->request_config, &core_module, req_cfg);
313bb560bc5c323cfd40c9cad7335b4b8e060aedkessstatic int core_create_proxy_req(request_rec *r, request_rec *pr)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slivestatic conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim (void)ap_update_child_status(c->sbh, SERVER_BUSY_READ, (request_rec *)NULL);
d56970df0a3d627ea0bc8867a9d336cfe67da7b2nd /* Got a connection structure, so initialize what fields we can
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim * (the rest are zeroed out by pcalloc).
88d86cfadffe2275a3dfb67a4d7bdc018630b661rbowen if ((rv = apr_socket_addr_get(&c->local_addr, APR_LOCAL, csd))
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim "apr_socket_addr_get(APR_LOCAL)");
a38b5f73e7f0f3b8726fb47d27b145f37036ead0jim if ((rv = apr_socket_addr_get(&c->remote_addr, APR_REMOTE, csd))
9cfaf3cf0b6a838ae98bb174660c6220734855f0nd "apr_socket_addr_get(APR_REMOTE)");
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);
4e8794dab6bbd15eb0bb016c7a4efb8b0572d558nd c->cs->c = c;
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.)
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive /* expected cause is that the client disconnected already,
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive * hence the debug level
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "apr_socket_opt_set(APR_TCP_NODELAY)");
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.
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive rv = apr_socket_timeout_set(csd, c->base_server->timeout);
a23acbbd61b9565caecea9931b6bcdf0b6228cbbslive /* expected cause is that the client disconnected already */
80c4526970a11f37c0f8e3b82afdf03902dac3f3slive "apr_socket_timeout_set");
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);
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.
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 ap_hook_pre_mpm(ap_create_scoreboard, NULL, NULL, APR_HOOK_MIDDLE);
a23acbbd61b9565caecea9931b6bcdf0b6228cbbslive /* register the core's insert_filter hook and register core-provided
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_hook_insert_filter(core_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
130d299c4b2b15be45532a176604c71fdc7bea5bnd ap_register_input_filter("CORE_IN", ap_core_input_filter,
4cf1c07a88ef51e11570c775507cd7d2c3e35a97slive ap_register_output_filter("CONTENT_LENGTH", ap_content_length_filter,
4cf1c07a88ef51e11570c775507cd7d2c3e35a97slive ap_register_output_filter("CORE", ap_core_output_filter,
ffec3e56ff5331a2d732ec07e9d107303fed43f4covener ap_register_output_filter("SUBREQ_CORE", ap_sub_req_output_filter,
18ee8bb3db5cc3b04291f89301bd5d14dc271066lgentis ap_register_output_filter("OLD_WRITE", ap_old_write_filter,
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 */