core.c revision 7b6ba9c468f26bdb3492d5e8cb79628a3b04e8c8
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder/* Copyright 2001-2004 The Apache Software Foundation
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * Licensed under the Apache License, Version 2.0 (the "License");
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * you may not use this file except in compliance with the License.
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * You may obtain a copy of the License at
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * http://www.apache.org/licenses/LICENSE-2.0
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * Unless required by applicable law or agreed to in writing, software
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * distributed under the License is distributed on an "AS IS" BASIS,
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * See the License for the specific language governing permissions and
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder * limitations under the License.
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder#include "apr_thread_proc.h" /* for RLIMIT stuff */
1aa11f4e4b984f2a6d6ce9700cbe82283c8d196aChristian Maeder#include "http_protocol.h" /* For index_of_response(). Grump. */
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder#include "http_main.h" /* For the default_handler below... */
4bbd808612c2580ae6e0495a155997a6bb47ecf3Christian Maeder#include "mod_so.h" /* for ap_find_loaded_module_symbol */
4bbd808612c2580ae6e0495a155997a6bb47ecf3Christian Maeder/* LimitRequestBody handling */
4bbd808612c2580ae6e0495a155997a6bb47ecf3Christian Maeder#define AP_LIMIT_REQ_BODY_UNSET ((apr_off_t) -1)
4bbd808612c2580ae6e0495a155997a6bb47ecf3Christian Maeder#define AP_DEFAULT_LIMIT_REQ_BODY ((apr_off_t) 0)
4bbd808612c2580ae6e0495a155997a6bb47ecf3Christian Maeder/* LimitXMLRequestBody handling */
4bbd808612c2580ae6e0495a155997a6bb47ecf3Christian Maeder#define AP_DEFAULT_LIMIT_XML_BODY ((size_t)1000000)
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder/* maximum include nesting level */
e935c1f2e814bb143017bb25b32ff7a406299d37Christian MaederAP_IMPLEMENT_HOOK_RUN_ALL(int, get_mgmt_items,
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder (apr_pool_t *p, const char *val, apr_hash_t *ht),
bff4b3f816be4c1e1d8ded76f1d5af786839e1a9Christian Maeder/* Server core module... This module provides support for really basic
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder * server operations, including options and commands which control the
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder * operation of other modules. Consider this the bureaucracy module.
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder * The core module also defines handlers, etc., do handle just enough
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder * to allow a server with the core module ONLY to actually serve documents
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder * (though it slaps DefaultType on all of 'em); this was useful in testing,
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder * but may not be worth preserving.
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder * This file could almost be mod_core.c, except for the stuff which affects
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder * the http_conf_globals.
e935c1f2e814bb143017bb25b32ff7a406299d37Christian Maeder/* Handles for core filters */
e935c1f2e814bb143017bb25b32ff7a406299d37Christian MaederAP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
e935c1f2e814bb143017bb25b32ff7a406299d37Christian MaederAP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
e935c1f2e814bb143017bb25b32ff7a406299d37Christian MaederAP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
e935c1f2e814bb143017bb25b32ff7a406299d37Christian MaederAP_DECLARE_DATA ap_filter_rec_t *ap_net_time_filter_handle;
static char errordocument_default;
| OPT_MULTI;
for (i = 0; i < METHODS; ++i) {
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
return (void *)conf;
const void *key,
const void *overlay_val,
const void *base_val,
const void *data)
while (overlay_info) {
while (base_info) {
ap_filter_rec_t *f;
int found = 0;
f = cur;
f = f->next;
if (!found) {
cur = f;
return cur;
for (i = 0; i < RESPONSE_CODES; ++i) {
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
for (i = 0; i < METHODS; ++i) {
NULL);
return (void*)conf;
#ifdef GPROF
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);
&core_module);
&core_module);
&core_module);
&core_module);
&core_module);
&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;
&core_module);
#if APR_HAVE_IPV6
return plain_server_name;
core_dir_config *d =
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;
#ifdef GPROF
return err;
return NULL;
return err;
return NULL;
const char *arg)
return err;
arg);
return NULL;
const char *string)
int idx;
return err;
* http_protocol.c relies on to distinguish between
return NULL;
char *tok_state;
if (first) {
p = NULL;
first = 0;
return NULL;
return err;
return NULL;
char action;
action = *(w++);
else if (first) {
first = 0;
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 err;
return NULL;
const char *arg)
return err;
return NULL;
for (i = 0; i < METHODS; ++i) {
return NULL;
require_line *r;
if (!c->ap_requires) {
return NULL;
void *dummy,
const char *arg)
const char *limited_methods;
const char *errmsg;
return err;
if (!limited_methods[0]) {
while (limited_methods[0]) {
int methnum;
return errmsg;
#ifdef WIN32
#define USE_ICASE 0
const char *errmsg;
return err;
if (!arg[0]) {
if (!arg) {
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;
if (not) {
arg++;
if (!arg[0]) {
if (!found) {
if (!found) {
if (check_symbol) {
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;
const char *arg)
return err;
return NULL;
const char *portstr;
int port;
return err;
if (portstr) {
portstr++;
port = 0;
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;
return NULL;
const char *arg)
return err;
return NULL;
const char *name)
unsigned *recursion;
void *data;
if (data) {
*recursion = 0;
*recursion = 0;
if (!conffile) {
*recursion = 0;
if (error) {
*recursion = 0;
return error;
if (*recursion) {
--*recursion;
return NULL;
char *str;
return err;
return NULL;
&core_module);
const char *word1)
return NULL;
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)
char *errp;
return err;
return NULL;
const char *arg)
return err;
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 *filter_name;
if (old) {
while (*arg &&
if (old) {
if (!new) {
return NULL;
const char *ctype;
&core_module);
if (ctype) {
while (ct_filter) {
#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
* #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
#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE
#ifdef AP_MPM_WANT_SET_STACKSIZE
{ 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
? 0 : APR_SENDFILE_ENABLED)
return HTTP_FORBIDDEN;
ap_set_etag(r);
return errstatus;
if (bld_content_md5) {
c->bucket_alloc);
#if APR_HAS_MMAP
(void)apr_bucket_file_enable_mmap(e, 0);
return HTTP_NOT_IMPLEMENTED;
return ap_send_http_options(r);
return HTTP_METHOD_NOT_ALLOWED;
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) {
if (!r->prev) {
return OK;
!= APR_SUCCESS) {
return NULL;
!= APR_SUCCESS) {
return NULL;
net->c = c;
return DONE;