core.c revision ac06e54654494445fd3d39e90bd23b436b4f84cc
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* ====================================================================
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The Apache Software License, Version 1.1
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * reserved.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Redistribution and use in source and binary forms, with or without
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * modification, are permitted provided that the following conditions
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * are met:
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 1. Redistributions of source code must retain the above copyright
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * notice, this list of conditions and the following disclaimer.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 2. Redistributions in binary form must reproduce the above copyright
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * notice, this list of conditions and the following disclaimer in
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the documentation and/or other materials provided with the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * distribution.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 3. The end-user documentation included with the redistribution,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * if any, must include the following acknowledgment:
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * "This product includes software developed by the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Apache Software Foundation (http://www.apache.org/)."
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Alternately, this acknowledgment may appear in the software itself,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * if and wherever such third-party acknowledgments normally appear.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 4. The names "Apache" and "Apache Software Foundation" must
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * not be used to endorse or promote products derived from this
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * software without prior written permission. For written
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * permission, please contact apache@apache.org.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 5. Products derived from this software may not be called "Apache",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * nor may "Apache" appear in their name, without prior written
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * permission of the Apache Software Foundation.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * SUCH DAMAGE.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * ====================================================================
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * This software consists of voluntary contributions made by many
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * individuals on behalf of the Apache Software Foundation. For more
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * information on the Apache Software Foundation, please see
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Portions of this software are based upon public domain software
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * originally written at the National Center for Supercomputing Applications,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * University of Illinois, Urbana-Champaign.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb#include "http_protocol.h" /* For index_of_response(). Grump. */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb#include "http_main.h" /* For the default_handler below... */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* LimitXMLRequestBody handling */
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe/* Server core module... This module provides support for really basic
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe * server operations, including options and commands which control the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * operation of other modules. Consider this the bureaucracy module.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The core module also defines handlers, etc., do handle just enough
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * to allow a server with the core module ONLY to actually serve documents
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * (though it slaps DefaultType on all of 'em); this was useful in testing,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * but may not be worth preserving.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * This file could almost be mod_core.c, except for the stuff which affects
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the http_conf_globals.
c3e342e5b0b9fea6617ee16d2da02c3ef2108126dougmstatic void *create_core_dir_config(apr_pool_t *a, char *dir)
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe conf = (core_dir_config *)apr_pcalloc(a, sizeof(core_dir_config));
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* conf->r and conf->d[_*] are initialized in */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe conf->do_rfc1413 = DEFAULT_RFC1413 | 2; /* set bit 1 to indicate default */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe conf->sec_file = apr_array_make(a, 2, sizeof(ap_conf_vector_t *));
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe conf->script_interpreter_source = INTERPRETER_SOURCE_UNSET;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe conf->add_default_charset = ADD_DEFAULT_CHARSET_UNSET;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe conf->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe conf->output_filters = apr_array_make(a, 2, sizeof(void *));
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe conf->input_filters = apr_array_make(a, 2, sizeof(void *));
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe return (void *)conf;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowestatic void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe conf = (core_dir_config *)apr_palloc(a, sizeof(core_dir_config));
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe memcpy((char *)conf, (const char *)base, sizeof(core_dir_config));
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe memcpy(conf->response_code_strings, base->response_code_strings,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe sizeof(*conf->response_code_strings) * RESPONSE_CODES);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* there was no explicit setting of new->opts, so we merge
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * preserve the invariant (opts_add & opts_remove) == 0
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe conf->opts_add = (conf->opts_add & ~new->opts_remove) | new->opts_add;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe conf->opts_remove = (conf->opts_remove & ~new->opts_add)
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe conf->opts = (conf->opts & ~conf->opts_remove) | conf->opts_add;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if ((base->opts & OPT_INCNOEXEC) && (new->opts & OPT_INCLUDES)) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe conf->opts = (conf->opts & ~OPT_INCNOEXEC) | OPT_INCLUDES;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe /* otherwise we just copy, because an explicit opts setting
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * overrides all earlier +/- modifiers
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe sizeof(*conf->response_code_strings) * RESPONSE_CODES);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe memcpy(conf->response_code_strings, new->response_code_strings,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe sizeof(*conf->response_code_strings) * RESPONSE_CODES);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe for (i = 0; i < RESPONSE_CODES; ++i) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (new->use_canonical_name != USE_CANONICAL_NAME_UNSET) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->sec_file = apr_array_append(a, base->sec_file, new->sec_file);
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (new->script_interpreter_source != INTERPRETER_SOURCE_UNSET) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->script_interpreter_source = new->script_interpreter_source;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (new->add_default_charset != ADD_DEFAULT_CHARSET_UNSET) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->add_default_charset_name = new->add_default_charset_name;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->output_filters = apr_array_append(a, base->output_filters,
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->input_filters = apr_array_append(a, base->input_filters,
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe return (void*)conf;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowestatic void *create_core_server_config(apr_pool_t *a, server_rec *s)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf = (core_server_config *)apr_pcalloc(a, sizeof(core_server_config));
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->access_name = is_virtual ? NULL : DEFAULT_ACCESS_FNAME;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->ap_document_root = is_virtual ? NULL : DOCUMENT_LOCATION;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->sec_dir = apr_array_make(a, 40, sizeof(ap_conf_vector_t *));
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe conf->sec_url = apr_array_make(a, 40, sizeof(ap_conf_vector_t *));
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe return (void *)conf;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowestatic void *merge_core_server_configs(apr_pool_t *p, void *basev, void *virtv)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe core_server_config *base = (core_server_config *)basev;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe core_server_config *virt = (core_server_config *)virtv;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_server_config *)apr_pcalloc(p, sizeof(core_server_config));
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf->sec_dir = apr_array_append(p, base->sec_dir, virt->sec_dir);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf->sec_url = apr_array_append(p, base->sec_url, virt->sec_url);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* Add per-directory configuration entry (for <directory> section);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * these are part of the core server config.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb core_server_config *sconf = ap_get_module_config(s->module_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb void **new_space = (void **)apr_array_push(sconf->sec_dir);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb core_server_config *sconf = ap_get_module_config(s->module_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb void **new_space = (void **)apr_array_push(sconf->sec_url);
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwroweAP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config)
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe void **new_space = (void **)apr_array_push(conf->sec_file);
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe/* We need to do a stable sort, qsort isn't stable. So to make it stable
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * we'll be maintaining the original index into the list, and using it
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * as the minor key during sorting. The major key is the number of
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * components (where the root component is zero).
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowestatic int reorder_sorter(const void *va, const void *vb)
2f1949bb0e3c209db94c8d521cba7380b9d11421trawick else if (core_a->d_components > core_b->d_components) {
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* They have the same number of components, we now have to compare
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * the minor key to maintain the original order.
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowevoid ap_core_reorder_directories(apr_pool_t *p, server_rec *s)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb sconf = ap_get_module_config(s->module_config, &core_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* we have to allocate tmp space to do a stable sort */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb sortbin = apr_palloc(tmp, sec_dir->nelts * sizeof(*sortbin));
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb for (i = 0; i < nelts; ++i) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb qsort(sortbin, nelts, sizeof(*sortbin), reorder_sorter);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* and now copy back to the original array */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb for (i = 0; i < nelts; ++i) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/*****************************************************************
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * There are some elements of the core config structures in which
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * other modules have a legitimate interest (this is ugly, but necessary
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * to preserve NCSA back-compatibility). So, we have a bunch of accessors
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(const char *) ap_document_root(request_rec *r) /* Don't use this! */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_server_config *)ap_get_module_config(r->server->module_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(const apr_array_header_t *) ap_requires(request_rec *r)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* Should probably just get rid of this... the only code that cares is
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * part of the core anyway (and in fact, it isn't publicised to other
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * modules).
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbchar *ap_response_code_string(request_rec *r, int error_index)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic APR_INLINE void do_double_reverse (conn_rec *conn)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* already done */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (conn->remote_host == NULL || conn->remote_host[0] == '\0') {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* single reverse failed, so don't bother */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb rv = apr_sockaddr_info_get(&sa, conn->remote_host, APR_UNSPEC, 0, 0, conn->pool);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* match IPv4-mapped IPv6 addresses with IPv4 A record */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (conn->remote_addr->sa.sin.sin_family == APR_INET6 &&
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb IN6_IS_ADDR_V4MAPPED((struct in6_addr *)conn->remote_addr->ipaddr_ptr) &&
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb !memcmp(&((struct in6_addr *)conn->remote_addr->ipaddr_ptr)->s6_addr[12],
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* If we haven't checked the host name, and we want to */
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe ((core_dir_config *)ap_get_module_config(dir_config, &core_module))
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* the default */
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe apr_socket_addr_get(&remote_addr, APR_REMOTE, conn->client_socket);
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe if (apr_getnameinfo(&conn->remote_host, remote_addr, 0) == APR_SUCCESS) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* if failed, set it to the NULL string to indicate error */
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe * Return the desired information; either the remote DNS name, if found,
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe * or either NULL (if the hostname was requested) or the IP address
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe * (if any identifier was requested).
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe if (conn->remote_host != NULL && conn->remote_host[0] != '\0') {
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe if (type == REMOTE_HOST || type == REMOTE_DOUBLE_REV) {
6fed20de38221f6f8a60c0ab1d907f1173c443f4wroweAP_DECLARE(const char *) ap_get_remote_logname(request_rec *r)
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe/* If we haven't checked the identity, and we want to */
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe dir_conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
6fed20de38221f6f8a60c0ab1d907f1173c443f4wrowe/* There are two options regarding what the "name" of a server is. The
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * "canonical" name as defined by ServerName and Port, or the "client's
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * name" as supplied by a possible Host: header or full URI. We never
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * trust the port passed in the client's headers, we always use the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * port of the actual socket.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The DNS option to UseCanonicalName causes this routine to do a
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * reverse lookup on the local IP address of the connection and use
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * that for the ServerName. This makes its value more reliable while
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * at the same time allowing Demon's magic virtual hosting to work.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * The assumption is that DNS lookups are sufficiently quick...
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * -- fanf 1998-10-03
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(const char *) ap_get_server_name(request_rec *r)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return r->hostname ? r->hostname : r->server->server_hostname;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb apr_socket_addr_get(&local_addr, APR_LOCAL, conn->client_socket);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (apr_getnameinfo(&conn->local_host, local_addr, 0) != APR_SUCCESS)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conn->local_host = apr_pstrdup(conn->pool, r->server->server_hostname);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* default */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r)
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb port = r->server->port ? r->server->port : ap_default_port(r);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb apr_socket_addr_get(&localsa, APR_LOCAL, r->connection->client_socket);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* default */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return apr_pstrcat(p, ap_http_method(r), "://", host, uri, NULL);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return apr_psprintf(p, "%s://%s:%u%s", ap_http_method(r), host, port, uri);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(unsigned long) ap_get_limit_req_body(const request_rec *r)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic apr_status_t get_win32_registry_default_value(apr_pool_t *p, HKEY hkey,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Read to NULL buffer to determine value size */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb result = RegQueryValueEx(hkeyOpen, "", 0, &type, NULL, &size);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((size < 2) || (type != REG_SZ && type != REG_EXPAND_SZ)) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Read value based on size query above */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb result = RegQueryValueEx(hkeyOpen, "", 0, &type, *value, &size);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* TODO: This might look fine, but we need to provide some warning
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * somewhere that some environment variables may -not- be translated,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * seeing as we may have chopped the environment table down somewhat.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ((result == ERROR_SUCCESS) && (type == REG_EXPAND_SZ))
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic char* get_interpreter_from_win32_registry(apr_pool_t *p, const char* ext,
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe * Future optimization:
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe * When the registry is successfully searched, store the strings for
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe * interpreter and arguments in an ext hash to speed up subsequent look-ups
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Open the key associated with the script filetype extension */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb result = RegOpenKeyEx(HKEY_CLASSES_ROOT, ext, 0, KEY_QUERY_VALUE,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Retrieve the name of the script filetype extension */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb result = RegQueryValueEx(hkeyType, "", NULL, &type, typeName, &size);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (result == ERROR_SUCCESS && type == REG_SZ && typeName[0]) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Open the key associated with the script filetype extension */
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe /* Open the key for the script command path by:
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * 1) the 'named' filetype key for ExecCGI/Command
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * 2) the extension's type key for ExecCGI/Command
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * and if the strict arg is false, then continue trying:
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 3) the 'named' filetype key for Open/Command
8aefbd756763807188d2e3ce336a8680e4893066wrowe * 4) the extension's type key for Open/Command
8aefbd756763807188d2e3ce336a8680e4893066wrowe result = get_win32_registry_default_value(p, hkeyName,
8aefbd756763807188d2e3ce336a8680e4893066wrowe result = get_win32_registry_default_value(p, hkeyType,
8aefbd756763807188d2e3ce336a8680e4893066wrowe if (!strict && cmdOfName && (result != ERROR_SUCCESS)) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe result = get_win32_registry_default_value(p, hkeyName,
8aefbd756763807188d2e3ce336a8680e4893066wrowe result = get_win32_registry_default_value(p, hkeyType,
8aefbd756763807188d2e3ce336a8680e4893066wrowe * The canonical way shell command entries are entered in the Win32
8aefbd756763807188d2e3ce336a8680e4893066wrowe * registry is as follows:
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * shell [options] "%1" [args]
8aa5ca8ff2a4d8e56f62ea3d461e2799136da085trawick * shell - full path name to interpreter or shell to run.
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * E.g., c:\usr\local\ntreskit\perl\bin\perl.exe
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * options - optional switches
8aefbd756763807188d2e3ce336a8680e4893066wrowe * "%1" - Place holder for file to run the shell against.
a8d11d78181478da6a672f7fbc58b8d523351f49wrowe * Typically quoted.
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * options - additional arguments
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe * E.g., /silent
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe * If we find a %1 or a quoted %1, lop off the remainder to arguments.
8aefbd756763807188d2e3ce336a8680e4893066wroweAP_DECLARE (file_type_e) ap_get_win32_interpreter(const request_rec *r,
8aefbd756763807188d2e3ce336a8680e4893066wrowe d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe /* Find the file extension */
8aefbd756763807188d2e3ce336a8680e4893066wrowe if (ext && (!strcasecmp(ext,".bat") || !strcasecmp(ext,".cmd")))
8aefbd756763807188d2e3ce336a8680e4893066wrowe *interpreter = apr_pstrcat(r->pool, "\"", comspec, "\" /c ", NULL);
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server,
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe "Failed to start a '%s' file as a script." APR_EOL_STR
8aefbd756763807188d2e3ce336a8680e4893066wrowe "\tCOMSPEC variable is missing from the environment.", ext);
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe /* If the file has an extension and it is not .com and not .exe and
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe * we've been instructed to search the registry, then do it!
8aefbd756763807188d2e3ce336a8680e4893066wrowe if (ext && strcasecmp(ext,".exe") && strcasecmp(ext,".com") &&
8aefbd756763807188d2e3ce336a8680e4893066wrowe (d->script_interpreter_source == INTERPRETER_SOURCE_REGISTRY ||
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe d->script_interpreter_source == INTERPRETER_SOURCE_REGISTRY_STRICT)) {
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe /* Check the registry */
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe *interpreter = get_interpreter_from_win32_registry(r->pool, ext,
a8d11d78181478da6a672f7fbc58b8d523351f49wrowe else if (d->script_interpreter_source == INTERPRETER_SOURCE_REGISTRY_STRICT) {
4fca95918a9c0ae93593806544b425d0adc2fcc3wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server,
8aefbd756763807188d2e3ce336a8680e4893066wrowe "ScriptInterpreterSource config directive set to \"registry-strict\"." APR_EOL_STR
8aefbd756763807188d2e3ce336a8680e4893066wrowe "\tInterpreter not found for files of type '%s'.", ext);
8aefbd756763807188d2e3ce336a8680e4893066wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server,
8aefbd756763807188d2e3ce336a8680e4893066wrowe "ScriptInterpreterSource config directive set to \"registry\"." APR_EOL_STR
8aefbd756763807188d2e3ce336a8680e4893066wrowe "\tInterpreter not found for files of type '%s', "
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Need to peek into the file figure out what it really is... */
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* This is wrong for Unicode FS ... should move to APR */
8aefbd756763807188d2e3ce336a8680e4893066wrowe hFile = CreateFile(r->filename, GENERIC_READ, FILE_SHARE_READ, NULL,
8aefbd756763807188d2e3ce336a8680e4893066wrowe bResult = ReadFile(hFile, (void*) &buffer, sizeof(buffer) - 1,
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ap_log_rerror(APLOG_MARK, APLOG_ERR, GetLastError(), r,
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Script or executable, that is the question... */
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Assuming file is a script since it starts with a shebang */
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Not a script, is it an executable? */
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((nBytesRead >= sizeof(IMAGE_DOS_HEADER)) && (hdr->e_magic == IMAGE_DOS_SIGNATURE)) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe/*****************************************************************
8aefbd756763807188d2e3ce336a8680e4893066wrowe * Commands... this module handles almost all of the NCSA httpd.conf
8aefbd756763807188d2e3ce336a8680e4893066wrowe * commands, but most of the old srm.conf is in the the modules.
8aefbd756763807188d2e3ce336a8680e4893066wrowe/* returns a parent if it matches the given directive */
8aefbd756763807188d2e3ce336a8680e4893066wrowestatic const ap_directive_t * find_parent(const ap_directive_t *dirp,
8aefbd756763807188d2e3ce336a8680e4893066wrowe const char *what)
b29f87f4b6c6886a04dccc296177a7033f70dfedtrawick /* ### it would be nice to have atom-ized directives */
8aefbd756763807188d2e3ce336a8680e4893066wroweAP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((forbidden & NOT_IN_VIRTUALHOST) && cmd->server->is_virtual) {
8aefbd756763807188d2e3ce336a8680e4893066wrowe if ((forbidden & NOT_IN_LIMIT) && cmd->limited != -1) {
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE
8aefbd756763807188d2e3ce336a8680e4893066wrowe " cannot occur within <Directory/Location/Files> "
8aefbd756763807188d2e3ce336a8680e4893066wrowe && ((found = find_parent(cmd->directive, "<Directory"))
8aefbd756763807188d2e3ce336a8680e4893066wrowe || (found = find_parent(cmd->directive, "<DirectoryMatch"))))
8aefbd756763807188d2e3ce336a8680e4893066wrowe && ((found = find_parent(cmd->directive, "<Location"))
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe || (found = find_parent(cmd->directive, "<LocationMatch"))))
8aefbd756763807188d2e3ce336a8680e4893066wrowe || (found = find_parent(cmd->directive, "<FilesMatch"))))) {
8aefbd756763807188d2e3ce336a8680e4893066wrowestatic const char *set_access_name(cmd_parms *cmd, void *dummy,
8aefbd756763807188d2e3ce336a8680e4893066wrowe const char *arg)
8aefbd756763807188d2e3ce336a8680e4893066wrowe core_server_config *conf = ap_get_module_config(sconf, &core_module);
8aefbd756763807188d2e3ce336a8680e4893066wrowestatic const char *set_gprof_dir(cmd_parms *cmd, void *dummy, const char *arg)
8aefbd756763807188d2e3ce336a8680e4893066wrowe core_server_config *conf = ap_get_module_config(sconf, &core_module);
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowe#endif /*GPROF*/
ac06e54654494445fd3d39e90bd23b436b4f84ccwrowestatic const char *set_add_default_charset(cmd_parms *cmd,
8aefbd756763807188d2e3ce336a8680e4893066wrowe const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
8aefbd756763807188d2e3ce336a8680e4893066wrowe d->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
8aefbd756763807188d2e3ce336a8680e4893066wrowestatic const char *set_document_root(cmd_parms *cmd, void *dummy,
8aefbd756763807188d2e3ce336a8680e4893066wrowe const char *arg)
0540a0b469147b52e858587270dba31c2aaa9e09wrowe core_server_config *conf = ap_get_module_config(sconf, &core_module);
0540a0b469147b52e858587270dba31c2aaa9e09wrowe /* TODO: ap_configtestonly && ap_docrootcheck && */
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe /* XXX Shouldn't this be relative to ServerRoot ??? */
0540a0b469147b52e858587270dba31c2aaa9e09wrowe if (apr_filepath_merge((char**)&conf->ap_document_root, NULL, arg,
0540a0b469147b52e858587270dba31c2aaa9e09wrowe ap_log_perror(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, cmd->pool,
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe "Warning: DocumentRoot [%s] does not exist",
8aefbd756763807188d2e3ce336a8680e4893066wrowe return "DocumentRoot must be a directory";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(void) ap_custom_response(request_rec *r, int status, char *string)
948096a99010fccf648814fecf38f75c689172d7wrowe ap_get_module_config(r->per_dir_config, &core_module);
948096a99010fccf648814fecf38f75c689172d7wrowe ((ap_is_url(string) || (*string == '/')) && (*string != '"')) ?
948096a99010fccf648814fecf38f75c689172d7wrowe apr_pstrdup(r->pool, string) : apr_pstrcat(r->pool, "\"", string, NULL);
948096a99010fccf648814fecf38f75c689172d7wrowestatic const char *set_error_document(cmd_parms *cmd, void *conf_,
948096a99010fccf648814fecf38f75c689172d7wrowe const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
948096a99010fccf648814fecf38f75c689172d7wrowe /* 1st parameter should be a 3 digit number, which we recognize;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * convert it into an array index
948096a99010fccf648814fecf38f75c689172d7wrowe idx500 = ap_index_of_response(HTTP_INTERNAL_SERVER_ERROR);
948096a99010fccf648814fecf38f75c689172d7wrowe else if ((index_number = ap_index_of_response(error_number)) == idx500) {
948096a99010fccf648814fecf38f75c689172d7wrowe return apr_pstrcat(cmd->pool, "Unsupported HTTP response code ",
948096a99010fccf648814fecf38f75c689172d7wrowe /* Heuristic to determine second argument. */
948096a99010fccf648814fecf38f75c689172d7wrowe /* The entry should be ignored if it is a full URL for a 401 error */
948096a99010fccf648814fecf38f75c689172d7wrowe ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, cmd->server,
053497224246c4dbef9af594cacf5c00ed271e6cwrowe "cannot use a full URL in a 401 ErrorDocument "
0540a0b469147b52e858587270dba31c2aaa9e09wrowe "directive --- ignoring!");
0540a0b469147b52e858587270dba31c2aaa9e09wrowe else { /* Store it... */
aa047239dedf0d26e8efecfade32e7337f35df19wrowe sizeof(*conf->response_code_strings) * RESPONSE_CODES);
053497224246c4dbef9af594cacf5c00ed271e6cwrowe /* hack. Prefix a " if it is a msg; as that is what
053497224246c4dbef9af594cacf5c00ed271e6cwrowe * http_protocol.c relies on to distinguish between
053497224246c4dbef9af594cacf5c00ed271e6cwrowe * a msg and a (local) path.
053497224246c4dbef9af594cacf5c00ed271e6cwrowe conf->response_code_strings[index_number] = (what == MSG) ?
aa047239dedf0d26e8efecfade32e7337f35df19wrowestatic const char *set_override(cmd_parms *cmd, void *d_, const char *l)
948096a99010fccf648814fecf38f75c689172d7wrowe const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
948096a99010fccf648814fecf38f75c689172d7wrowe while (l[0]) {
948096a99010fccf648814fecf38f75c689172d7wrowe return apr_pstrcat(cmd->pool, "Illegal override option ", w, NULL);
053497224246c4dbef9af594cacf5c00ed271e6cwrowestatic const char *set_options(cmd_parms *cmd, void *d_, const char *l)
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe while (l[0]) {
aa047239dedf0d26e8efecfade32e7337f35df19wrowe else if (first) {
aa047239dedf0d26e8efecfade32e7337f35df19wrowe else if (!strcasecmp(w, "RunScripts")) { /* AI backcompat. Yuck */
0540a0b469147b52e858587270dba31c2aaa9e09wrowe return apr_pstrcat(cmd->pool, "Illegal option ", w, NULL);
aa047239dedf0d26e8efecfade32e7337f35df19wrowe /* we ensure the invariant (d->opts_add & d->opts_remove) == 0 */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *satisfy(cmd_parms *cmd, void *c_, const char *arg)
aa047239dedf0d26e8efecfade32e7337f35df19wrowe return "Satisfy either 'any' or 'all'.";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *require(cmd_parms *cmd, void *c_, const char *arg)
aa047239dedf0d26e8efecfade32e7337f35df19wrowe c->ap_requires = apr_array_make(cmd->pool, 2, sizeof(require_line));
aa047239dedf0d26e8efecfade32e7337f35df19wroweAP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy,
aa047239dedf0d26e8efecfade32e7337f35df19wrowe const char *arg) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *limited_methods = ap_getword(cmd->pool, &arg, '>');
aa047239dedf0d26e8efecfade32e7337f35df19wrowe const char *errmsg;
0540a0b469147b52e858587270dba31c2aaa9e09wrowe const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
aa047239dedf0d26e8efecfade32e7337f35df19wrowe char *method = ap_getword_conf(cmd->pool, &limited_methods);
aa047239dedf0d26e8efecfade32e7337f35df19wrowe /* check for builtin or module registered method number */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return "TRACE cannot be controlled by <Limit>";
aa047239dedf0d26e8efecfade32e7337f35df19wrowe /* method has not been registered yet, but resorce restriction
dc8692c6c0ca616a09aa12dad005f2ef23baa1a0wrowe * is always checked before method handling, so register it.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Killing two features with one function,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * if (tog == NULL) <Limit>, else <LimitExcept>
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb errmsg = ap_walk_config(cmd->directive->first_child, cmd, cmd->context);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* We use this in <DirectoryMatch> and <FilesMatch>, to ensure that
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * people don't get bitten by wrong-cased regex matches
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Report a missing-'>' syntax error.
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowestatic const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe const char *errmsg;
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool);
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe return "<DirectoryMatch > block must specify a path";
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe return "<Directory > block must specify a path";
e68544ae924174ca227ede8e2e722cefa00ea0d3wrowe return "<Directory ~ > block must specify a path";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
68b29bcadd6c46aecdc9fe14c93555a2238ad2aagregames /* Ensure that the pathname is canonical */
68b29bcadd6c46aecdc9fe14c93555a2238ad2aagregames APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS) {
68b29bcadd6c46aecdc9fe14c93555a2238ad2aagregames return apr_pstrcat(cmd->pool, "<Directory \"", cmd->path,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* initialize our config and fetch it */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = ap_set_config_vectors(cmd->server, new_dir_conf, cmd->path,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_dir_conf);
48d2edbfb84e5559b5da0f8d614ccab805cc67a8rbb /* Make this explicit - the "/" root has 0 elements, that is, we
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * will always merge it, and it will always sort and merge first.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * All others are sorted and tested by the number of slashes.
b67fb549910fa0faf4cdd8aeaf9aeab51d4b6a92wrowe return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
b45c1c292ff1fa635004ae81fa691f8cb3cdda85rbbstatic const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *errmsg;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool);
117026201e6d8fe7d82416b8a7324830f5a87292wrowe /* initialize our config and fetch it */
117026201e6d8fe7d82416b8a7324830f5a87292wrowe conf = ap_set_config_vectors(cmd->server, new_url_conf, cmd->path,
117026201e6d8fe7d82416b8a7324830f5a87292wrowe errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_url_conf);
117026201e6d8fe7d82416b8a7324830f5a87292wrowe conf->d = apr_pstrdup(cmd->pool, cmd->path); /* No mangling, please */
117026201e6d8fe7d82416b8a7324830f5a87292wrowe return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
e7505ba54ac56ae30e4e250f912f3dbaf92ca45fwrowestatic const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
e7505ba54ac56ae30e4e250f912f3dbaf92ca45fwrowe const char *errmsg;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
efa1a34b0a7785fc72863eff175b0cfc1ecb0e38wrowe const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_LOCATION);
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Only if not an .htaccess file */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
117026201e6d8fe7d82416b8a7324830f5a87292wrowe r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
1067418d9ed9ed9daeb3ca4f74e72db810c49833wrowe /* Ensure that the pathname is canonical, but we
1067418d9ed9ed9daeb3ca4f74e72db810c49833wrowe * can't test the case/aliases without a fixed path */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* initialize our config and fetch it */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path,
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowe return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
5bb29f57ae0184d2b3c1cdf35132f8ceb011f882wrowestatic const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg)
0540a0b469147b52e858587270dba31c2aaa9e09wrowe const char *retval;
0540a0b469147b52e858587270dba31c2aaa9e09wrowe retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,
0540a0b469147b52e858587270dba31c2aaa9e09wroweAP_DECLARE(int) ap_exists_config_define(const char *name)
5b3abd2fecc712f08ad728114aa77137b9f67716wrowe for (i = 0; i < ap_server_config_defines->nelts; i++) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *start_ifdefine(cmd_parms *cmd, void *dummy, const char *arg)
58097d7d8d1a394092374b9f6ddf76b7993724a4rbb const char *endp;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb int defined;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *retval;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* httpd.conf commands... beginning with the <VirtualHost> business */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbstatic const char *virtualhost_section(cmd_parms *cmd, void *dummy,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *arg)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *errmsg;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
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;
int port;
return err;
return NULL;
const char *arg)
return err;
return NULL;
const char *arg)
return err;
return NULL;
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;
*nbytes = 0;
bytes_written += n;
return rv;
*nbytes += n;
if (n < cnt) {
return APR_SUCCESS;
#if APR_HAS_SENDFILE
#ifdef AP_DEBUG
flags);
tmplen = 0;
file_bytes_left = 0;
file_offset = 0;
tmplen = 0;
apr_int32_t i;
*nbytes = 0;
sendlen = 0;
return rv;
#ifdef GPROF
#ifdef _OSD_POSIX
#ifdef WIN32
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
* #defined them in mpm.h.
#ifdef AP_MPM_WANT_SET_PIDFILE
#ifdef AP_MPM_WANT_SET_SCOREBOARD
#ifdef AP_MPM_WANT_SET_LOCKFILE
#ifdef AP_MPM_WANT_SET_MAX_REQUESTS
#ifdef AP_MPM_WANT_SET_COREDUMPDIR
{ NULL }
if (r->proxyreq) {
return HTTP_FORBIDDEN;
return HTTP_BAD_REQUEST;
!= APR_SUCCESS) {
return HTTP_FORBIDDEN;
!= APR_SUCCESS) {
return HTTP_FORBIDDEN;
return OK;
int access_status;
return access_status;
return access_status;
return OK;
apr_bucket *e;
core_dir_config *d;
int errstatus;
int bld_content_md5;
return DECLINED;
&core_module);
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;
if (bld_content_md5) {
apr_bucket_copy(e, &e);
e = apr_bucket_eos_create();
static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_off_t *readbytes)
apr_bucket *e;
APR_BRIGADE_INSERT_TAIL(b, e);
return APR_SUCCESS;
return APR_EOF;
typedef struct CORE_OUTPUT_FILTER_CTX {
conn_rec *c = f->c;
if (ctx->b) {
b = ctx->b;
apr_bucket *e;
APR_BRIGADE_FOREACH(e, b) {
last_e = e;
else if (APR_BUCKET_IS_FILE(e)
if (fd) {
const char *str;
apr_size_t n;
if (!fd) {
nvec++;
nbytes += n;
const char *str;
apr_size_t n;
return rv;
return APR_SUCCESS;
if (fd) {
#if APR_HAS_SENDFILE
if (nvec) {
if (nvec_trailers) {
#if APR_HAS_SENDFILE
if (!c->keepalive) {
if (more)
return rv;
b = more;
return APR_SUCCESS;
&core_module);
if (r->main) {
return OK;