http_core.c revision a368d1ad6bc200b13dda026a14fa4ad8f82716cb
842ae4bd224140319ae7feec1872b93dfd491143fielding/* ====================================================================
842ae4bd224140319ae7feec1872b93dfd491143fielding * The Apache Software License, Version 1.1
842ae4bd224140319ae7feec1872b93dfd491143fielding * Copyright (c) 2000 The Apache Software Foundation. All rights
842ae4bd224140319ae7feec1872b93dfd491143fielding * reserved.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Redistribution and use in source and binary forms, with or without
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * modification, are permitted provided that the following conditions
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 1. Redistributions of source code must retain the above copyright
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * notice, this list of conditions and the following disclaimer.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 2. Redistributions in binary form must reproduce the above copyright
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * notice, this list of conditions and the following disclaimer in
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the documentation and/or other materials provided with the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * distribution.
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh * 3. The end-user documentation included with the redistribution,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * if any, must include the following acknowledgment:
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh * "This product includes software developed by the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Apache Software Foundation (http://www.apache.org/)."
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Alternately, this acknowledgment may appear in the software itself,
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein * if and wherever such third-party acknowledgments normally appear.
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein * 4. The names "Apache" and "Apache Software Foundation" must
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein * not be used to endorse or promote products derived from this
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein * software without prior written permission. For written
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * permission, please contact apache@apache.org.
573394373c777e1624a481160f3d02f8fb09f3ffrjung * 5. Products derived from this software may not be called "Apache",
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * nor may "Apache" appear in their name, without prior written
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * permission of the Apache Software Foundation.
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1b21d7b3d97def358b2e923655edeb16613a1c31gstein * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * SUCH DAMAGE.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * ====================================================================
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * This software consists of voluntary contributions made by many
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * individuals on behalf of the Apache Software Foundation. For more
cf8fe49d9d89cfa4b62cb2b1376ca6f25b81b362trawick * information on the Apache Software Foundation, please see
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf * Portions of this software are based upon public domain software
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf * originally written at the National Center for Supercomputing Applications,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * University of Illinois, Urbana-Champaign.
cb9e6e5c78f5a1690214e9548250fc6af1fc73b5wrowe#include "http_protocol.h" /* For index_of_response(). Grump. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_main.h" /* For the default_handler below... */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Make sure we don't write less than 4096 bytes at any one time.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Allow Apache to use ap_mmap */
8a3228198adb03e6996f7738c361a612777ecab6aaron/* mmap support for static files based on ideas from John Heidemann's
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * patch against 1.0.5. See
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * <http://www.isi.edu/~johnh/SOFTWARE/APACHE/index.html>.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Files have to be at least this big before they're mmap()d. This is to deal
8a3228198adb03e6996f7738c361a612777ecab6aaron * with systems where the expense of doing an mmap() and an munmap() outweighs
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the benefit for small files. It shouldn't be set lower than 1.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding #endif /* SUNOS4 */
8a3228198adb03e6996f7738c361a612777ecab6aaron#endif /* MMAP_THRESHOLD */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif /* USE_MMAP_FILES */
8a3228198adb03e6996f7738c361a612777ecab6aaron/* LimitXMLRequestBody handling */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Server core module... This module provides support for really basic
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * server operations, including options and commands which control the
8a3228198adb03e6996f7738c361a612777ecab6aaron * operation of other modules. Consider this the bureaucracy module.
8a3228198adb03e6996f7738c361a612777ecab6aaron * The core module also defines handlers, etc., do handle just enough
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * to allow a server with the core module ONLY to actually serve documents
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * (though it slaps DefaultType on all of 'em); this was useful in testing,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * but may not be worth preserving.
8a3228198adb03e6996f7738c361a612777ecab6aaron * This file could almost be mod_core.c, except for the stuff which affects
8a3228198adb03e6996f7738c361a612777ecab6aaron * the http_conf_globals.
8a3228198adb03e6996f7738c361a612777ecab6aaronstatic void *create_core_dir_config(apr_pool_t *a, char *dir)
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf conf = (core_dir_config *)apr_pcalloc(a, sizeof(core_dir_config));
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conf->d_is_fnmatch = conf->d ? (apr_is_fnmatch(conf->d) != 0) : 0;
649c9dd342a580016d29c2866de88a4609eb6457wrowe conf->d_components = conf->d ? ap_count_dirs(conf->d) : 0;
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick conf->use_canonical_name = USE_CANONICAL_NAME_UNSET;
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick conf->do_rfc1413 = DEFAULT_RFC1413 | 2; /* set bit 1 to indicate default */
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe conf->script_interpreter_source = INTERPRETER_SOURCE_UNSET;
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton conf->add_default_charset = ADD_DEFAULT_CHARSET_UNSET;
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton conf->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton conf->filters = apr_make_array(a, 2, sizeof(void *));
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton conf->input_filters = apr_make_array(a, 2, sizeof(void *));
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton return (void *)conf;
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jortonstatic void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick conf = (core_dir_config *)apr_palloc(a, sizeof(core_dir_config));
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick memcpy((char *)conf, (const char *)base, sizeof(core_dir_config));
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe memcpy(conf->response_code_strings, base->response_code_strings,
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe sizeof(*conf->response_code_strings) * RESPONSE_CODES);
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick /* there was no explicit setting of new->opts, so we merge
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe * preserve the invariant (opts_add & opts_remove) == 0
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick conf->opts_add = (conf->opts_add & ~new->opts_remove) | new->opts_add;
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick conf->opts_remove = (conf->opts_remove & ~new->opts_add)
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick conf->opts = (conf->opts & ~conf->opts_remove) | conf->opts_add;
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick if ((base->opts & OPT_INCNOEXEC) && (new->opts & OPT_INCLUDES)) {
d7b781abdcdc6fc4d4fcd513d5babd3c42dff43dwrowe conf->opts = (conf->opts & ~OPT_INCNOEXEC) | OPT_INCLUDES;
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick /* otherwise we just copy, because an explicit opts setting
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick * overrides all earlier +/- modifiers
b3edf21d591bfd0e64bbec0dda73c0e41d7ecdb6wrowe sizeof(*conf->response_code_strings) * RESPONSE_CODES);
b3edf21d591bfd0e64bbec0dda73c0e41d7ecdb6wrowe memcpy(conf->response_code_strings, new->response_code_strings,
b3edf21d591bfd0e64bbec0dda73c0e41d7ecdb6wrowe sizeof(*conf->response_code_strings) * RESPONSE_CODES);
b3edf21d591bfd0e64bbec0dda73c0e41d7ecdb6wrowe for (i = 0; i < RESPONSE_CODES; ++i) {
649c9dd342a580016d29c2866de88a4609eb6457wrowe if (new->use_canonical_name != USE_CANONICAL_NAME_UNSET) {
649c9dd342a580016d29c2866de88a4609eb6457wrowe#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
399cf0e5e061b49593817421b94305889fa6bc1fjorton conf->sec = apr_append_arrays(a, base->sec, new->sec);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding if (new->script_interpreter_source != INTERPRETER_SOURCE_UNSET) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conf->script_interpreter_source = new->script_interpreter_source;
5a6a87d8920e385b1ed14177d74ab9786f3acddfwrowe if (new->add_default_charset != ADD_DEFAULT_CHARSET_UNSET) {
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh conf->add_default_charset_name = new->add_default_charset_name;
76185d819b745e953dd2cd636fbdd515c333e4a4trawick conf->filters = apr_append_arrays(a, base->filters, new->filters);
ff0436077dc959b17a6f87825e4a106d211224c1wrowe conf->input_filters = apr_append_arrays(a, base->input_filters,
fa4e5ac791dd1c84df616b28d4ee9751efe9c64frbb return (void*)conf;
1ccd992d37d62c8cb2056126f2234f64ec189bfddougmstatic void *create_core_server_config(apr_pool_t *a, server_rec *s)
ff0436077dc959b17a6f87825e4a106d211224c1wrowe conf = (core_server_config *)apr_pcalloc(a, sizeof(core_server_config));
8a3228198adb03e6996f7738c361a612777ecab6aaron conf->access_name = is_virtual ? NULL : DEFAULT_ACCESS_FNAME;
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh conf->ap_document_root = is_virtual ? NULL : DOCUMENT_LOCATION;
d521bfef0e1a65993d5e302628ac68a2c91a195ftrawick conf->sec_url = apr_make_array(a, 40, sizeof(void *));
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick return (void *)conf;
2cfdca5be0c69f65b43a888d6d3da846489b8fa5rbbstatic void *merge_core_server_configs(apr_pool_t *p, void *basev, void *virtv)
8a3228198adb03e6996f7738c361a612777ecab6aaron core_server_config *virt = (core_server_config *)virtv;
399cf0e5e061b49593817421b94305889fa6bc1fjorton conf = (core_server_config *)apr_pcalloc(p, sizeof(core_server_config));
053847fad1e0bfc79d75dd6aec040b78c4d9189erjung conf->sec = apr_append_arrays(p, base->sec, virt->sec);
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe conf->sec_url = apr_append_arrays(p, base->sec_url, virt->sec_url);
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe/* Add per-directory configuration entry (for <directory> section);
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe * these are part of the core server config.
7117ace448072813fa6eb7180ef206fc2e8fcfc7wroweCORE_EXPORT(void) ap_add_per_dir_conf(server_rec *s, void *dir_config)
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe core_server_config *sconf = ap_get_module_config(s->module_config,
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe void **new_space = (void **)apr_push_array(sconf->sec);
399cf0e5e061b49593817421b94305889fa6bc1fjortonCORE_EXPORT(void) ap_add_per_url_conf(server_rec *s, void *url_config)
053847fad1e0bfc79d75dd6aec040b78c4d9189erjung core_server_config *sconf = ap_get_module_config(s->module_config,
19702a9985f3b2f794d22be9102d9d4fbf6bebe7rjung void **new_space = (void **)apr_push_array(sconf->sec_url);
053847fad1e0bfc79d75dd6aec040b78c4d9189erjungCORE_EXPORT(void) ap_add_file_conf(core_dir_config *conf, void *url_config)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding void **new_space = (void **)apr_push_array(conf->sec);
8a3228198adb03e6996f7738c361a612777ecab6aaron/* core_reorder_directories reorders the directory sections such that the
8a3228198adb03e6996f7738c361a612777ecab6aaron * 1-component sections come first, then the 2-component, and so on, finally
8a3228198adb03e6996f7738c361a612777ecab6aaron * followed by the "special" sections. A section is "special" if it's a regex,
8a3228198adb03e6996f7738c361a612777ecab6aaron * or if it doesn't start with / -- consider proxy: matching. All movements
8a3228198adb03e6996f7738c361a612777ecab6aaron * are in-order to preserve the ordering of the sections from the config files.
8a3228198adb03e6996f7738c361a612777ecab6aaron * See directory_walk().
8a3228198adb03e6996f7738c361a612777ecab6aaron || ((entry_core)->d[0] != '/' && (entry_core)->d[1] != ':'))
8a3228198adb03e6996f7738c361a612777ecab6aaron/* XXX: Fairly certain this is correct... '/' must prefix the path
8a3228198adb03e6996f7738c361a612777ecab6aaron * or else in the case xyz:/ or abc/xyz:/, '/' must follow the ':'.
8a3228198adb03e6996f7738c361a612777ecab6aaron * If there is no leading '/' or embedded ':/', then we are special.
85c435ceda98eab940615e4466d9c5955252e745wrowe ((entry_core)->r != NULL || (entry_core)->d[0] != '/')
92eed7d377d8be7cd8e48d1299412fc8c742b7f5jorton/* We need to do a stable sort, qsort isn't stable. So to make it stable
32c4bc04f89b16521718145dc731f750144d7b38wrowe * we'll be maintaining the original index into the list, and using it
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh * as the minor key during sorting. The major key is the number of
053847fad1e0bfc79d75dd6aec040b78c4d9189erjung * components (where a "special" section has infinite components).
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstatic int reorder_sorter(const void *va, const void *vb)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding core_a = (core_dir_config *)ap_get_module_config(a->elt, &core_module);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding core_b = (core_dir_config *)ap_get_module_config(b->elt, &core_module);
649c9dd342a580016d29c2866de88a4609eb6457wrowe /* we know they're both not special */
649c9dd342a580016d29c2866de88a4609eb6457wrowe else if (core_a->d_components > core_b->d_components) {
649c9dd342a580016d29c2866de88a4609eb6457wrowe /* Either they're both special, or they're both not special and have the
649c9dd342a580016d29c2866de88a4609eb6457wrowe * same number of components. In any event, we now have to compare
649c9dd342a580016d29c2866de88a4609eb6457wrowe * the minor key. */
85c435ceda98eab940615e4466d9c5955252e745wrowevoid ap_core_reorder_directories(apr_pool_t *p, server_rec *s)
ab43b4a17b2ac31ccb1cf280be8c42a8a314cecbjorton sconf = ap_get_module_config(s->module_config, &core_module);
649c9dd342a580016d29c2866de88a4609eb6457wrowe /* we have to allocate tmp space to do a stable sort */
649c9dd342a580016d29c2866de88a4609eb6457wrowe sortbin = apr_palloc(tmp, sec->nelts * sizeof(*sortbin));
649c9dd342a580016d29c2866de88a4609eb6457wrowe for (i = 0; i < nelts; ++i) {
188dff19ac1e71ffd25752d1a4f8d71f9f563305wrowe qsort(sortbin, nelts, sizeof(*sortbin), reorder_sorter);
188dff19ac1e71ffd25752d1a4f8d71f9f563305wrowe /* and now copy back to the original array */
188dff19ac1e71ffd25752d1a4f8d71f9f563305wrowe for (i = 0; i < nelts; ++i) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/*****************************************************************
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * There are some elements of the core config structures in which
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * other modules have a legitimate interest (this is ugly, but necessary
0f57a69cc84c59eacda1179763ae42ca88f1a577wrowe * to preserve NCSA back-compatibility). So, we have a bunch of accessors
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
8a3228198adb03e6996f7738c361a612777ecab6aaron conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
8a3228198adb03e6996f7738c361a612777ecab6aaron conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAPI_EXPORT(const char *) ap_document_root(request_rec *r) /* Don't use this! */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf conf = (core_server_config *)ap_get_module_config(r->server->module_config,
e302f38fd646764ce1a1e1c578d794aef514a9e5sfAPI_EXPORT(const apr_array_header_t *) ap_requires(request_rec *r)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf/* Should probably just get rid of this... the only code that cares is
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * part of the core anyway (and in fact, it isn't publicised to other
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * modules).
e302f38fd646764ce1a1e1c578d794aef514a9e5sfchar *ap_response_code_string(request_rec *r, int error_index)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* already done */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (conn->remote_host == NULL || conn->remote_host[0] == '\0') {
8a3228198adb03e6996f7738c361a612777ecab6aaron /* single reverse failed, so don't bother */
e302f38fd646764ce1a1e1c578d794aef514a9e5sfAPI_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* If we haven't checked the host name, and we want to */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf ((core_dir_config *)ap_get_module_config(dir_config, &core_module))
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* the default */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr), AF_INET);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf conn->remote_host = apr_pstrdup(conn->pool, (void *)hptr->h_name);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* if failed, set it to the NULL string to indicate error */
8a3228198adb03e6996f7738c361a612777ecab6aaron * Return the desired information; either the remote DNS name, if found,
8a3228198adb03e6996f7738c361a612777ecab6aaron * or either NULL (if the hostname was requested) or the IP address
8a3228198adb03e6996f7738c361a612777ecab6aaron * (if any identifier was requested).
8a3228198adb03e6996f7738c361a612777ecab6aaron if (conn->remote_host != NULL && conn->remote_host[0] != '\0') {
8a3228198adb03e6996f7738c361a612777ecab6aaron if (type == REMOTE_HOST || type == REMOTE_DOUBLE_REV) {
50e421c0e069853bb724f3d816cef543e447c844jortonAPI_EXPORT(const char *) ap_get_remote_logname(request_rec *r)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf/* If we haven't checked the identity, and we want to */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf dir_conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf/* There are two options regarding what the "name" of a server is. The
b32d756dae79045a9bc90e0d0b85582f6f28eaf3sf * "canonical" name as defined by ServerName and Port, or the "client's
b32d756dae79045a9bc90e0d0b85582f6f28eaf3sf * name" as supplied by a possible Host: header or full URI. We never
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * trust the port passed in the client's headers, we always use the
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * port of the actual socket.
b32d756dae79045a9bc90e0d0b85582f6f28eaf3sf * The DNS option to UseCanonicalName causes this routine to do a
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * reverse lookup on the local IP address of the connectiona and use
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * that for the ServerName. This makes its value more reliable while
b32d756dae79045a9bc90e0d0b85582f6f28eaf3sf * at the same time allowing Demon's magic virtual hosting to work.
b32d756dae79045a9bc90e0d0b85582f6f28eaf3sf * The assumption is that DNS lookups are sufficiently quick...
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * -- fanf 1998-10-03
e302f38fd646764ce1a1e1c578d794aef514a9e5sfAPI_EXPORT(const char *) ap_get_server_name(request_rec *r)
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf return r->hostname ? r->hostname : r->server->server_hostname;
9228509ac5da8374df4a5d50b7da139e7b31f8a3sf hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr),
4497075b5e08b0c8ee89425a1758258ae80550fcsf /* default */
4497075b5e08b0c8ee89425a1758258ae80550fcsfAPI_EXPORT(unsigned) ap_get_server_port(const request_rec *r)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf port = r->server->port ? r->server->port : ap_default_port(r);
4497075b5e08b0c8ee89425a1758258ae80550fcsf return r->hostname ? ntohs(r->connection->local_addr.sin_port)
4497075b5e08b0c8ee89425a1758258ae80550fcsf /* default */
4497075b5e08b0c8ee89425a1758258ae80550fcsfAPI_EXPORT(char *) ap_construct_url(apr_pool_t *p, const char *uri,
4497075b5e08b0c8ee89425a1758258ae80550fcsf return apr_pstrcat(p, ap_http_method(r), "://", host, uri, NULL);
4497075b5e08b0c8ee89425a1758258ae80550fcsf return apr_psprintf(p, "%s://%s:%u%s", ap_http_method(r), host, port, uri);
4497075b5e08b0c8ee89425a1758258ae80550fcsfAPI_EXPORT(unsigned long) ap_get_limit_req_body(const request_rec *r)
4497075b5e08b0c8ee89425a1758258ae80550fcsf (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic apr_status_t get_win32_registry_default_value(apr_pool_t *p, HKEY hkey,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* Read to NULL buffer to determine value size */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf result = RegQueryValueEx(hkeyOpen, "", 0, &type, NULL, &size);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if ((size < 2) || (type != REG_SZ && type != REG_EXPAND_SZ)) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* Read value based on size query above */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf result = RegQueryValueEx(hkeyOpen, "", 0, &type, *value, &size);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* TODO: This might look fine, but we need to provide some warning
b32d756dae79045a9bc90e0d0b85582f6f28eaf3sf * somewhere that some environment variables may -not- be translated,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * seeing as we may have chopped the environment table down somewhat.
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if ((result == ERROR_SUCCESS) && (type == REG_EXPAND_SZ))
ce4dc40a4e87991087488f70d96d3447d7557294sfstatic char* get_interpreter_from_win32_registry(apr_pool_t *p, const char* ext,
ce4dc40a4e87991087488f70d96d3447d7557294sf * Future optimization:
ce4dc40a4e87991087488f70d96d3447d7557294sf * When the registry is successfully searched, store the strings for
ce4dc40a4e87991087488f70d96d3447d7557294sf * interpreter and arguments in an ext hash to speed up subsequent look-ups
ce4dc40a4e87991087488f70d96d3447d7557294sf /* Open the key associated with the script filetype extension */
ce4dc40a4e87991087488f70d96d3447d7557294sf result = RegOpenKeyEx(HKEY_CLASSES_ROOT, ext, 0, KEY_QUERY_VALUE,
ce4dc40a4e87991087488f70d96d3447d7557294sf /* Retrieve the name of the script filetype extension */
ce4dc40a4e87991087488f70d96d3447d7557294sf result = RegQueryValueEx(hkeyType, "", NULL, &type, typeName, &size);
ce4dc40a4e87991087488f70d96d3447d7557294sf if (result == ERROR_SUCCESS && type == REG_SZ && typeName[0]) {
ce4dc40a4e87991087488f70d96d3447d7557294sf /* Open the key associated with the script filetype extension */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* Open the key for the script command path by:
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * 1) the 'named' filetype key for ExecCGI/Command
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * 2) the extension's type key for ExecCGI/Command
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * and if the strict arg is false, then continue trying:
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * 3) the 'named' filetype key for Open/Command
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * 4) the extension's type key for Open/Command
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * The canonical way shell command entries are entered in the Win32
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * registry is as follows:
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * shell [options] "%1" [args]
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * shell - full path name to interpreter or shell to run.
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * E.g., c:\usr\local\ntreskit\perl\bin\perl.exe
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * options - optional switches
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * E.g., \C
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * "%1" - Place holder for file to run the shell against.
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * Typically quoted.
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * options - additional arguments
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * E.g., /silent
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * If we find a %1 or a quoted %1, lop off the remainder to arguments.
1939c6929d01cf9be05ed767714c6012edc5c035sf *s = '\0';
e302f38fd646764ce1a1e1c578d794aef514a9e5sf *s = '\0';
e302f38fd646764ce1a1e1c578d794aef514a9e5sfAPI_EXPORT (file_type_e) ap_get_win32_interpreter(const request_rec *r,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* Find the file extension */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (ext && (!strcasecmp(ext,".bat") || !strcasecmp(ext,".cmd")))
e302f38fd646764ce1a1e1c578d794aef514a9e5sf *interpreter = apr_pstrcat(r->pool, "\"", comspec, "\" /c ", NULL);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf "\tCOMSPEC variable is missing from the environment.", ext);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* If the file has an extension and it is not .com and not .exe and
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * we've been instructed to search the registry, then do it!
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (ext && strcasecmp(ext,".exe") && strcasecmp(ext,".com") &&
e302f38fd646764ce1a1e1c578d794aef514a9e5sf (d->script_interpreter_source == INTERPRETER_SOURCE_REGISTRY ||
e698258fd17a7f9d51cb2b35e96f8f0b48ec23c8nd d->script_interpreter_source == INTERPRETER_SOURCE_REGISTRY_STRICT)) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* Check the registry */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf *interpreter = get_interpreter_from_win32_registry(r->pool, ext,
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf else if (d->script_interpreter_source == INTERPRETER_SOURCE_REGISTRY_STRICT) {
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server,
b5c4b00201fdc3ed11c6cc05cf3f9a7912ac0cfbsf "ScriptInterpreterSource config directive set to \"registry-strict\"." APR_EOL_STR
e302f38fd646764ce1a1e1c578d794aef514a9e5sf ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf "ScriptInterpreterSource config directive set to \"registry\"." APR_EOL_STR
e302f38fd646764ce1a1e1c578d794aef514a9e5sf "\tInterpreter not found for files of type '%s', "
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* Need to peek into the file figure out what it really is... */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf hFile = CreateFile(r->filename, GENERIC_READ, FILE_SHARE_READ, NULL,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf bResult = ReadFile(hFile, (void*) &buffer, sizeof(buffer) - 1,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Script or executable, that is the question... */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm /* Assuming file is a script since it starts with a shebang */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* Not a script, is it an executable? */
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if ((nBytesRead >= sizeof(IMAGE_DOS_HEADER)) && (hdr->e_magic == IMAGE_DOS_SIGNATURE)) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf/*****************************************************************
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * Commands... this module handles almost all of the NCSA httpd.conf
e302f38fd646764ce1a1e1c578d794aef514a9e5sf * commands, but most of the old srm.conf is in the the modules.
e302f38fd646764ce1a1e1c578d794aef514a9e5sf/* returns a parent if it matches the given directive */
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic const ap_directive_t * find_parent(const ap_directive_t *dirp,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf const char *what)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf /* ### it would be nice to have atom-ized directives */
e302f38fd646764ce1a1e1c578d794aef514a9e5sfAPI_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if ((forbidden & NOT_IN_VIRTUALHOST) && cmd->server->is_virtual) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE
e302f38fd646764ce1a1e1c578d794aef514a9e5sf " cannot occur within <Directory/Location/Files> "
e302f38fd646764ce1a1e1c578d794aef514a9e5sf || (found = find_parent(cmd->directive, "<DirectoryMatch"))))
e302f38fd646764ce1a1e1c578d794aef514a9e5sf || (found = find_parent(cmd->directive, "<LocationMatch"))))
e302f38fd646764ce1a1e1c578d794aef514a9e5sf || (found = find_parent(cmd->directive, "<FilesMatch"))))) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic const char *set_access_name(cmd_parms *cmd, void *dummy,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf const char *arg)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf core_server_config *conf = ap_get_module_config(sconf, &core_module);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic const char *set_gprof_dir(cmd_parms *cmd, void *dummy, char *arg)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf core_server_config *conf = ap_get_module_config(sconf, &core_module);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf#endif /*GPROF*/
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic const char *set_add_default_charset(cmd_parms *cmd,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf d->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic const char *set_document_root(cmd_parms *cmd, void *dummy,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf const char *arg)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf core_server_config *conf = ap_get_module_config(sconf, &core_module);
e302f38fd646764ce1a1e1c578d794aef514a9e5sf if (/* TODO: ap_configtestonly && ap_docrootcheck && */ !ap_is_directory(arg)) {
e302f38fd646764ce1a1e1c578d794aef514a9e5sf ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
e302f38fd646764ce1a1e1c578d794aef514a9e5sf "Warning: DocumentRoot [%s] does not exist",
e302f38fd646764ce1a1e1c578d794aef514a9e5sf return "DocumentRoot must be a directory";
e302f38fd646764ce1a1e1c578d794aef514a9e5sfAPI_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string)
e302f38fd646764ce1a1e1c578d794aef514a9e5sf ((ap_is_url(string) || (*string == '/')) && (*string != '"')) ?
e302f38fd646764ce1a1e1c578d794aef514a9e5sf apr_pstrdup(r->pool, string) : apr_pstrcat(r->pool, "\"", string, NULL);
e302f38fd646764ce1a1e1c578d794aef514a9e5sfstatic const char *set_error_document(cmd_parms *cmd, void *conf_,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
3597d6b10c88c252f156fe8061b659a38dea38c2rbb /* 1st parameter should be a 3 digit number, which we recognize;
3597d6b10c88c252f156fe8061b659a38dea38c2rbb * convert it into an array index
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf idx500 = ap_index_of_response(HTTP_INTERNAL_SERVER_ERROR);
3597d6b10c88c252f156fe8061b659a38dea38c2rbb else if ((index_number = ap_index_of_response(error_number)) == idx500) {
d37a236a4b64d0aeb4a8bbfd3978503af8c82765sf return apr_pstrcat(cmd->pool, "Unsupported HTTP response code ",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Heuristic to determine second argument. */
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh /* The entry should be ignored if it is a full URL for a 401 error */
2b13bc45632d72cdf50ac42149e4fc8bc0d05bf2stoddard ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, cmd->server,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding "cannot use a full URL in a 401 ErrorDocument "
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding "directive --- ignoring!");
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding else { /* Store it... */
2b13bc45632d72cdf50ac42149e4fc8bc0d05bf2stoddard sizeof(*conf->response_code_strings) * RESPONSE_CODES);
8a3228198adb03e6996f7738c361a612777ecab6aaron /* hack. Prefix a " if it is a msg; as that is what
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh * http_protocol.c relies on to distinguish between
8a3228198adb03e6996f7738c361a612777ecab6aaron * a msg and a (local) path.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conf->response_code_strings[index_number] = (what == MSG) ?
7538cfc9bcb1132e87011484b826c0d8bff9cc73sfstatic const char *set_override(cmd_parms *cmd, void *d_, const char *l)
7538cfc9bcb1132e87011484b826c0d8bff9cc73sf const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
e34223f72e630187c4d8ac7c22da5096c833eb20trawick while (l[0]) {
bd27541a0c96caa881f17a490e23cdd220d480c8poirier return apr_pstrcat(cmd->pool, "Illegal override option ", w, NULL);
bd27541a0c96caa881f17a490e23cdd220d480c8poirierstatic const char *set_options(cmd_parms *cmd, void *d_, const char *l)
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm while (l[0]) {
32c4bc04f89b16521718145dc731f750144d7b38wrowe else if (first) {
8a3228198adb03e6996f7738c361a612777ecab6aaron else if (!strcasecmp(w, "RunScripts")) { /* AI backcompat. Yuck */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding return apr_pstrcat(cmd->pool, "Illegal option ", w, NULL);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* we ensure the invariant (d->opts_add & d->opts_remove) == 0 */
e8f95a682820a599fe41b22977010636be5c2717jimstatic const char *satisfy(cmd_parms *cmd, void *c_, const char *arg)
2de7ee14d4925c754a2d3a52d91350b895257df9jerenkrantz return "Satisfy either 'any' or 'all'.";
e3754dae9df2783c2cd88fa8d46bd0a0765e9820trawickstatic const char *require(cmd_parms *cmd, void *c_, const char *arg)
e3754dae9df2783c2cd88fa8d46bd0a0765e9820trawick c->ap_requires = apr_make_array(cmd->pool, 2, sizeof(require_line));
2de7ee14d4925c754a2d3a52d91350b895257df9jerenkrantz r = (require_line *)apr_push_array(c->ap_requires);
8a3228198adb03e6996f7738c361a612777ecab6aaronCORE_EXPORT_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy,
8a3228198adb03e6996f7738c361a612777ecab6aaron const char *arg) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *limited_methods = ap_getword(cmd->pool, &arg, '>');
066877f1a045103acfdd376d48cdd473c33f409bdougm const char *errmsg;
2b484455736f4c30447aa852764f53282cbeb5ddrbb const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char *method = ap_getword_conf(cmd->pool, &limited_methods);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding return "TRACE cannot be controlled by <Limit>";
10a4cdd68ef1ca0e54af296fe1d08ac00150c90bwrowe register int i, j, k;
053847fad1e0bfc79d75dd6aec040b78c4d9189erjung * Deal with <Limit> by adding the method to the list.
2cfdca5be0c69f65b43a888d6d3da846489b8fa5rbb sizeof(char *));
5a6a87d8920e385b1ed14177d74ab9786f3acddfwrowe xmethod = (char **) apr_push_array(cmd->limited_xmethods);
8a3228198adb03e6996f7738c361a612777ecab6aaron * <LimitExcept>, so remove any/all occurrences of the method
f3a0be90718c1fa5da1bf25e38974d2db3ef8a30jorton * in the extension array.
2cfdca5be0c69f65b43a888d6d3da846489b8fa5rbb for (j = i, k = i + 1;
8a3228198adb03e6996f7738c361a612777ecab6aaron ++j, ++k) {
76185d819b745e953dd2cd636fbdd515c333e4a4trawick /* Killing two features with one function,
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh * if (tog == NULL) <Limit>, else <LimitExcept>
38cf7a307a8067b5b476403b9fec0bc6d7849cd2jorton errmsg = ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
2cfdca5be0c69f65b43a888d6d3da846489b8fa5rbb/* We use this in <DirectoryMatch> and <FilesMatch>, to ensure that
76185d819b745e953dd2cd636fbdd515c333e4a4trawick * people don't get bitten by wrong-cased regex matches
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Report a missing-'>' syntax error.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstatic const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
7f1290cbf118bf3d34aecc68cff2e5bd0a23e126rbb const char *errmsg;
053847fad1e0bfc79d75dd6aec040b78c4d9189erjung void *new_dir_conf = ap_create_per_dir_config(cmd->pool);
8a3228198adb03e6996f7738c361a612777ecab6aaron r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
ffb048955d9939c0ab6ff99c2efc412d8e7a191dwrowe r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
7f1290cbf118bf3d34aecc68cff2e5bd0a23e126rbb /* Treat 'default' path / as an inalienable root */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Treat UNC path // as an inalienable root */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Ensure that the pathname is canonical */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding cmd->path = ap_os_canonical_filename(cmd->pool, cmd->path);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* initialize our config and fetch it */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conf = (core_dir_config *)ap_set_config_vectors(cmd, new_dir_conf,
2a7d0035b5594ddc0907a9cc545e14ae5140c541manoj errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_dir_conf);
c54189c4d2d06d8b374940b32acf20287effff07wrowe return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstatic const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm const char *errmsg;
8a3228198adb03e6996f7738c361a612777ecab6aaron void *new_url_conf = ap_create_per_dir_config(cmd->pool);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe /* initialize our config and fetch it */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conf = (core_dir_config *)ap_set_config_vectors(cmd, new_url_conf,
2cfdca5be0c69f65b43a888d6d3da846489b8fa5rbb errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_url_conf);
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh conf->d = apr_pstrdup(cmd->pool, cmd->path); /* No mangling, please */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowestatic const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
7117ace448072813fa6eb7180ef206fc2e8fcfc7wrowe const char *errmsg;
44c44a736f11c7785e87b8c4744b3867ad7d8f0bwrowe void *new_file_conf = ap_create_per_dir_config(cmd->pool);
44c44a736f11c7785e87b8c4744b3867ad7d8f0bwrowe const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_LOCATION);
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sf /* Only if not an .htaccess file */
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sf r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sf r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sf /* Ensure that the pathname is canonical */
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sf cmd->path = ap_os_canonical_filename(cmd->pool, cmd->path);
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sf /* initialize our config and fetch it */
aa51f4b9e1f954f9c04d2728a0d7be01719fe0a1sf conf = (core_dir_config *)ap_set_config_vectors(cmd, new_file_conf,
2261031aa94be82d7e6b1b8c367afc1b282317f5ianh errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
return NULL;
if (not) {
arg++;
const char *retval;
return retval;
char **defines;
const char *endp;
int not = 0;
arg++;
const char *retval;
return retval;
/* httpd.conf commands... beginning with the <VirtualHost> business */
const char *arg)
const char *errmsg;
return err;
if (errmsg) {
return errmsg;
s->lookup_defaults);
return errmsg;
const char *arg)
while (*arg) {
return NULL;
char **newfilter;
return NULL;
char **newfilter;
return NULL;
const char *arg)
return err;
return NULL;
return err;
return NULL;
const char *arg)
return err;
return NULL;
int port;
return err;
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
return err;
return NULL;
return err;
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
return err;
return NULL;
return err;
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
return err;
return NULL;
return err;
return NULL;
const char *arg)
return err;
return NULL;
const char *name)
return NULL;
char *str;
return err;
return NULL;
&core_module);
const char *word1)
return NULL;
return err;
static int version_locked = 0;
enum server_token_type {
version_locked = 0;
return APR_SUCCESS;
if (! version_locked) {
const char *arg)
return err;
return NULL;
const char *arg)
int lim;
return err;
if (lim < 0) {
return NULL;
const char *arg)
int lim;
return err;
if (lim < 0) {
NULL);
return NULL;
const char *arg)
int lim;
return err;
if (lim < 0) {
NULL);
return NULL;
const char *arg)
return err;
* Instead we have an idiotic define in httpd.h that prevents
return NULL;
const char *arg)
return err;
return NULL;
return AP_DEFAULT_LIMIT_XML_BODY;
#ifdef WIN32
char *arg)
return NULL;
#if !defined (RLIMIT_CPU) || !(defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)) || !defined (RLIMIT_NPROC)
return NULL;
#ifdef RLIMIT_CPU
return NULL;
#if defined(RLIMIT_AS)
return NULL;
#ifdef RLIMIT_NPROC
return NULL;
apr_ssize_t i = 0;
*nbytes = 0;
bytes_written += n;
return rv;
if (n < cnt) {
return APR_SUCCESS;
apr_int32_t i;
*nbytes = 0;
sendlen = 0;
sendlen = 0;
return rv;
#ifdef GPROF
#ifdef _OSD_POSIX
#ifdef WIN32
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
{ NULL }
if (r->proxyreq) {
return HTTP_FORBIDDEN;
return HTTP_BAD_REQUEST;
NULL);
NULL);
return OK;
core_dir_config *d =
#ifdef USE_MMAP_FILES
int bld_content_md5 =
return errstatus;
return HTTP_NOT_IMPLEMENTED;
return ap_send_http_options(r);
return HTTP_METHOD_NOT_ALLOWED;
: r->filename);
return HTTP_NOT_FOUND;
return HTTP_METHOD_NOT_ALLOWED;
return HTTP_FORBIDDEN;
ap_set_etag(r);
return errstatus;
#ifdef USE_MMAP_FILES
if (bld_content_md5) {
#ifdef APACHE_XLATE
if (!r->header_only) {
if (!rangestatus) {
return HTTP_INTERNAL_SERVER_ERROR;
#ifdef USE_MMAP_FILES
unsigned char *addr;
if (bld_content_md5) {
if (!r->header_only) {
if (!rangestatus) {
return OK;
typedef struct BUFFER_FILTER_CTX {
AP_BRIGADE_FOREACH(e, b) {
if (destroy_me) {
AP_BUCKET_IS_PIPE(e)) {
const char *str;
apr_ssize_t n;
return rv;
AP_BUCKET_REMOVE(e);
destroy_me = e;
insert_before = e;
if (destroy_me) {
if (pass_the_brigade) {
if (insert_first) {
AP_BRIGADE_INSERT_HEAD(b, e);
else if (insert_before) {
return rv;
if (ctx) {
if (insert_before) {
return APR_SUCCESS;
ap_bucket *e;
AP_BRIGADE_FOREACH(e, b) {
if (AP_BUCKET_IS_EOS(e)) {
eos = e;
const char *data;
return rv;
if (len > 0) {
if (bytes > 0) {
AP_BRIGADE_INSERT_HEAD(b, e);
AP_BRIGADE_INSERT_TAIL(b, e);
return rv;
return APR_SUCCESS;
ap_bucket *e;
AP_BRIGADE_INSERT_TAIL(b, e);
return APR_SUCCESS;
return APR_EOF;
typedef struct CORE_OUTPUT_FILTER_CTX {
ap_bucket *e;
conn_rec *c = f->c;
if (ctx->b) {
b = ctx->b;
AP_BRIGADE_INSERT_HEAD(b, e);
AP_BRIGADE_FOREACH(e, b) {
if (AP_BUCKET_IS_EOS(e)) {
else if (AP_BUCKET_IS_FILE(e)) {
const char *str;
apr_ssize_t n;
nbytes += n;
if (!fd) {
nvec++;
return APR_SUCCESS;
if (fd) {
#if APR_HAS_SENDFILE
if (nvec) {
if (nvec_trailers) {
#if APR_HAS_SENDFILE
if (!c->keepalive) {
&nbytes,
flags);
#if APR_HAS_SENDFILE
if (more)
return rv;
nvec = 0;
nvec_trailers = 0;
b = more;
return APR_SUCCESS;
{ return DEFAULT_HTTP_PORT; }
&core_module);
static void register_hooks(void)