core.c revision 0119f1301a880cf39c0aad0fa2a77240af964691
f743002678eb67b99bbc29fee116b65d9530fec0wrowe/* Licensed to the Apache Software Foundation (ASF) under one or more
80833bb9a1bf25dcf19e814438a4b311d2e1f4cffuankg * contributor license agreements. See the NOTICE file distributed with
5c43d2fb853f84497b5ece2d414ef9484aa87e5fsf * this work for additional information regarding copyright ownership.
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf * The ASF licenses this file to You under the Apache License, Version 2.0
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf * (the "License"); you may not use this file except in compliance with
4576c1a9ef54cd1e5555ee07d016a7f559f80338sf * the License. You may obtain a copy of the License at
d58a822aff1dfda25384d3d009f88f1883c95436kbrand * Unless required by applicable law or agreed to in writing, software
d58a822aff1dfda25384d3d009f88f1883c95436kbrand * distributed under the License is distributed on an "AS IS" BASIS,
d58a822aff1dfda25384d3d009f88f1883c95436kbrand * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
e02ff627c1e63137247e20493f6ef44b3bb1a095sf * See the License for the specific language governing permissions and
e02ff627c1e63137247e20493f6ef44b3bb1a095sf * limitations under the License.
2a7beea91d46beb41f043a84eaad060047ee04aafabien#include "http_protocol.h" /* For index_of_response(). Grump. */
9e430d18dde58791589bd699416c8319560dd067jim#include "http_main.h" /* For the default_handler below... */
fc1459657a1fde206a847f9028930725d715f8b4trawick#include "mod_so.h" /* for ap_find_loaded_module_symbol */
85eacfc96a04547ef25aabbc06440039715084c2jorton#if defined(RLIMIT_CPU) || defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) || defined (RLIMIT_NPROC)
68ba377fc3b124baa759662077c48077ebadb186minfrin/* LimitRequestBody handling */
f4ca9f6f002fece336168a16355434ca966f96a9trawick/* LimitXMLRequestBody handling */
78f94f1d06c4e6828ce04d618221e0fcecb57849humbedooh/* maximum include nesting level */
74e7a30182af5e68f14ccb8d57918b22b982db8bhumbedooh/* Server core module... This module provides support for really basic
74e7a30182af5e68f14ccb8d57918b22b982db8bhumbedooh * server operations, including options and commands which control the
74e7a30182af5e68f14ccb8d57918b22b982db8bhumbedooh * operation of other modules. Consider this the bureaucracy module.
10961a2f60207cb873d889bb28b1f0ef707a4311humbedooh * The core module also defines handlers, etc., to handle just enough
10961a2f60207cb873d889bb28b1f0ef707a4311humbedooh * to allow a server with the core module ONLY to actually serve documents.
0448378b899e8df0c060360f17c0af692adf17bchumbedooh * This file could almost be mod_core.c, except for the stuff which affects
0448378b899e8df0c060360f17c0af692adf17bchumbedooh * the http_conf_globals.
60a765cccbd3f3b5997b65b0034220c79f78369etrawick/* Handles for core filters */
e7ca863b04ee2a7aea7738cadbf51ce5e6c5245dhumbedoohAP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
e7ca863b04ee2a7aea7738cadbf51ce5e6c5245dhumbedoohAP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
e7ca863b04ee2a7aea7738cadbf51ce5e6c5245dhumbedoohAP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
e7ca863b04ee2a7aea7738cadbf51ce5e6c5245dhumbedoohAP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;
91814c869ca39ce45dfe147307d2a831cac6ecbehumbedooh/* Provide ap_document_root_check storage and default value = true */
79c5787b92ac5f0e1cc82393816c77a006399316trawick/* magic pointer for ErrorDocument xxx "default" */
c967bf3bc89e8aa60dbd30d9da388e448ddc1cc4trawickstatic void *create_core_dir_config(apr_pool_t *a, char *dir)
79c5787b92ac5f0e1cc82393816c77a006399316trawick conf = (core_dir_config *)apr_pcalloc(a, sizeof(core_dir_config));
12b987b969f03ef98d9175a53d849ab62f5684fecovener /* conf->r and conf->d[_*] are initialized by dirsection() or left NULL */
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton conf->override_opts = OPT_UNSET | OPT_ALL | OPT_SYM_OWNER | OPT_MULTI;
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jorton conf->use_canonical_phys_port = USE_CANONICAL_PHYS_PORT_UNSET;
53e9b27aba029b18be814df40bcf6f0428771d1efuankg#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin conf->sec_file = apr_array_make(a, 2, sizeof(ap_conf_vector_t *));
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin conf->add_default_charset = ADD_DEFAULT_CHARSET_UNSET;
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin conf->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung /* Overriding all negotiation
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick * Flag for use of inodes in ETags.
cfa64348224b66dd1c9979b809406c4d15b1c137fielding return (void *)conf;
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajimstatic void *merge_core_dir_configs(apr_pool_t *a, void *basev, void *newv)
== OPT_INCLUDES)) {
for (i = 0; i < RESPONSE_CODES; ++i) {
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
return (void*)conf;
#ifndef ACCEPT_FILTER_NAME
#ifdef __FreeBSD_version
if (!is_virtual) {
return (void *)conf;
return conf;
&core_module);
&core_module);
struct reorder_sort_rec {
int orig_index;
int nelts;
if (!nelts) {
for (i = 0; i < nelts; ++i) {
for (i = 0; i < nelts; ++i) {
&core_module);
if (authn_ap_auth_type) {
return authn_ap_auth_type(r);
return NULL;
if (authn_ap_auth_name) {
return authn_ap_auth_name(r);
return NULL;
access control interacts with authentication/authorization
if (access_compat_ap_satisfies) {
return access_compat_ap_satisfies(r);
return SATISFY_NOSPEC;
&core_module);
&core_module);
&core_module);
return NULL;
return NULL;
while (sa) {
int hostname_lookups;
int ignored_str_is_ip;
*str_is_ip = 0;
if (dir_config) {
== APR_SUCCESS) {
return NULL;
return NULL;
if (ident_lookup) {
return ident_lookup(r);
return NULL;
core_dir_config *d;
const char *retval;
&core_module);
switch (d->use_canonical_name) {
case USE_CANONICAL_NAME_ON:
case USE_CANONICAL_NAME_DNS:
case USE_CANONICAL_NAME_OFF:
case USE_CANONICAL_NAME_UNSET:
return retval;
#if APR_HAVE_IPV6
return plain_server_name;
core_dir_config *d =
switch (d->use_canonical_name) {
case USE_CANONICAL_NAME_OFF:
case USE_CANONICAL_NAME_DNS:
case USE_CANONICAL_NAME_UNSET:
ap_default_port(r);
ap_default_port(r);
case USE_CANONICAL_NAME_ON:
ap_default_port(r);
ap_default_port(r);
return port;
request_rec *r)
core_dir_config *d =
return AP_DEFAULT_LIMIT_REQ_BODY;
return d->limit_req_body;
* Commands... this module handles almost all of the NCSA httpd.conf
* commands, but most of the old srm.conf is in the the modules.
const char *what)
return dirp;
return NULL;
unsigned forbidden)
return NULL;
return NULL;
const char *arg)
return err;
return NULL;
const char *optarg)
return err;
return NULL;
const char *optarg)
char **defines;
return err;
return NULL;
#ifdef GPROF
return err;
return NULL;
return NULL;
const char *arg)
return err;
if (!ap_document_root_check) {
return NULL;
arg);
return NULL;
const char *string)
int idx;
* http_protocol.c relies on to distinguish between
return NULL;
char *tok_state;
if (first) {
p = NULL;
first = 0;
return NULL;
return NULL;
char action;
action = *(w++);
else if (first) {
first = 0;
return NULL;
const char *arg)
return NULL;
const char *args_p)
char action;
char *token;
const char *args;
int valid;
int first;
int explicit;
explicit = 0;
token++;
if (first) {
first = 0;
valid = 0;
valid = 0;
if (! valid) {
NULL);
if (explicit) {
return NULL;
const char *arg)
return NULL;
const char *arg)
return NULL;
void *dummy,
const char *arg)
const char *limited_methods;
const char *errmsg;
if (!limited_methods[0]) {
while (limited_methods[0]) {
int methnum;
NULL);
return errmsg;
#ifdef WIN32
#define USE_ICASE 0
const char *errmsg;
return err;
if (!arg[0]) {
char *newpath;
return errmsg;
conf->r = r;
return NULL;
const char *errmsg;
return err;
if (!arg[0]) {
return errmsg;
conf->r = r;
return NULL;
const char *errmsg;
return err;
if (!arg[0]) {
if (!old_path) {
char *newpath;
return errmsg;
conf->r = r;
return NULL;
const char *errmsg;
const char *condition;
int expr_err = 0;
return err;
if (!arg[0]) {
if (!old_path) {
if (expr_err) {
return errmsg;
return NULL;
if (!found) {
if (!found) {
if (check_symbol) {
return found;
if (not) {
arg++;
if (!arg[0]) {
const char *retval;
return retval;
char **defines;
const char *endp;
int not = 0;
arg++;
if (!arg[0]) {
const char *retval;
return retval;
/* httpd.conf commands... beginning with the <VirtualHost> business */
const char *arg)
const char *errmsg;
return err;
if (!arg[0]) {
if (errmsg) {
return errmsg;
s->lookup_defaults);
return errmsg;
const char *arg)
while (*arg) {
return NULL;
&core_module);
char* proto;
char* accf;
return err;
return NULL;
&core_module);
&core_module);
const char *arg)
&core_module);
char* proto;
return err;
return NULL;
const char *arg)
return err;
return NULL;
* ServerName www.example.com
* ServerName www.example.com:80
* ServerName https://www.example.com:443
char *scheme;
int port;
return err;
if (part) {
if (portstr) {
portstr++;
port = 0;
return NULL;
const char *arg)
return NULL;
const char *arg)
return err;
return NULL;
return err;
return NULL;
return NULL;
const char *arg)
return NULL;
const char *arg)
return err;
return NULL;
return NULL;
return NULL;
const char *arg)
return NULL;
const char *arg)
return NULL;
const char *name)
unsigned *recursion;
void *data;
if (data) {
*recursion = 0;
*recursion = 0;
if (!conffile) {
*recursion = 0;
optional);
if (error) {
*recursion = 0;
return error;
if (*recursion) {
--*recursion;
return NULL;
char *level_str;
int level;
const char *err;
return err;
return err;
return NULL;
if (!*level_str) {
return NULL;
&core_module);
static int banner_locked = 0;
enum server_token_type {
banner_locked = 0;
return APR_SUCCESS;
if (! banner_locked) {
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)
char *errp;
return NULL;
const char *arg)
return NULL;
return AP_DEFAULT_LIMIT_XML_BODY;
#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;
&core_module);
if (limit <= 0) {
if (arg2) {
if (limit <= 0) {
return NULL;
&core_module);
log_backtrace(r);
log_backtrace(r);
const char *arg1)
&core_module);
return NULL;
const char **sa)
char *d = scratch;
s = *sa;
at_start = 0;
*sa = s;
return NULL;
const char **sa)
const char *s = *sa;
*sa = ++s;
*sa = ++s;
return NULL;
while (apr_isdigit(*++s))
*sa = ++s;
return NULL;
if (!handler) {
dummy[0] = *s;
*sa = ++s;
return NULL;
const char **err,
int is_main_fmt)
sizeof(ap_errorlog_format_item));
char *res;
int seen_msg_fmt = 0;
if (res) {
return NULL;
if (!is_main_fmt) {
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
&core_module);
if (!arg2) {
sizeof(apr_array_header_t *));
if (*arg2) {
apr_array_header_t **e;
sizeof(apr_array_header_t *));
if (*arg2) {
apr_array_header_t **e;
return err_string;
int flags)
#ifdef GPROF
"Set to on or off for PATH_INFO to be accepted by handlers, or default for the per-handler preference"),
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
/* scoreboard.c directives */
{ NULL }
if (r->proxyreq) {
return HTTP_FORBIDDEN;
return HTTP_BAD_REQUEST;
/* skip all leading /'s (e.g. http://localhost///foo)
++path;
!= APR_SUCCESS) {
return HTTP_FORBIDDEN;
/* skip all leading /'s (e.g. http://localhost///foo)
++path;
!= APR_SUCCESS) {
return HTTP_FORBIDDEN;
return OK;
int access_status;
return access_status;
return access_status;
return OK;
&core_module);
return OK;
apr_bucket *e;
core_dir_config *d;
int errstatus;
int bld_content_md5;
&core_module);
return errstatus;
return HTTP_NOT_FOUND;
return HTTP_NOT_FOUND;
return HTTP_NOT_FOUND;
r->method);
return HTTP_METHOD_NOT_ALLOWED;
#if APR_HAS_SENDFILE
return HTTP_FORBIDDEN;
ap_set_etag(r);
if (bld_content_md5) {
#if APR_HAS_MMAP
(void)apr_bucket_file_enable_mmap(e, 0);
|| c->aborted) {
return OK;
status);
return HTTP_INTERNAL_SERVER_ERROR;
if (r->the_request
"Invalid method in request %s - possible attempt to establish SSL connection on non-SSL port", r->the_request);
return HTTP_NOT_IMPLEMENTED;
return ap_send_http_options(r);
return HTTP_METHOD_NOT_ALLOWED;
static int sys_privileges = 0;
return sys_privileges;
return APR_SUCCESS;
if (!sys_privileges) {
return !OK;
return OK;
&core_module);
if (filters) {
if (filters) {
return APR_SUCCESS;
return num_request_notes++;
return NULL;
if (!req_cfg) {
return NULL;
sizeof(void *) * num_request_notes);
if (r->main) {
return OK;
!= APR_SUCCESS) {
return NULL;
!= APR_SUCCESS) {
return NULL;
c->cs->c = c;
c->clogging_input_filters = 0;
net->c = c;
return DONE;