core.c revision a91a59d0b0ceed7cd5621fe8757eda5ff6a043a8
c79e39ad568d9af854765f64049534044ef6c034nd/* Licensed to the Apache Software Foundation (ASF) under one or more
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi * contributor license agreements. See the NOTICE file distributed with
c79e39ad568d9af854765f64049534044ef6c034nd * this work for additional information regarding copyright ownership.
d3e250aab242db84d14060985b5db675a731d548nd * The ASF licenses this file to You under the Apache License, Version 2.0
c79e39ad568d9af854765f64049534044ef6c034nd * (the "License"); you may not use this file except in compliance with
c79e39ad568d9af854765f64049534044ef6c034nd * the License. You may obtain a copy of the License at
c79e39ad568d9af854765f64049534044ef6c034nd * Unless required by applicable law or agreed to in writing, software
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem * distributed under the License is distributed on an "AS IS" BASIS,
b9bf3918f6eaf7747bcbfbd02792bcbe4a052784nilgun * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
c79e39ad568d9af854765f64049534044ef6c034nd * See the License for the specific language governing permissions and
c79e39ad568d9af854765f64049534044ef6c034nd * limitations under the License.
#include "apr.h"
#include "apr_strings.h"
#include "apr_lib.h"
#include "apr_fnmatch.h"
#include "apr_hash.h"
#include "apr_hooks.h"
#define APR_WANT_IOVEC
#define APR_WANT_STRFUNC
#define APR_WANT_MEMFUNC
#include "apr_want.h"
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_request.h"
#include "http_vhost.h"
#include "http_log.h"
#include "util_md5.h"
#include "http_connection.h"
#include "apr_buckets.h"
#include "util_filter.h"
#include "util_ebcdic.h"
#include "util_mutex.h"
#include "mpm.h"
#include "mpm_common.h"
#include "scoreboard.h"
#include "mod_core.h"
#include "mod_proxy.h"
#include "ap_listen.h"
#if defined(RLIMIT_CPU) || defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) || defined (RLIMIT_NPROC)
#include "unixd.h"
#ifndef AP_MAX_INCLUDE_DEPTH
* This file could almost be mod_core.c, except for the stuff which affects
static char errordocument_default;
| OPT_MULTI;
#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
NULL);
return (void*)conf;
#ifdef GPROF
#ifdef APR_TCP_DEFER_ACCEPT
#ifndef ACCEPT_FILTER_NAME
#ifdef __FreeBSD_version
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);
&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)
char **newv;
return err;
return NULL;
#ifdef GPROF
return err;
return NULL;
return NULL;
const char *arg)
return err;
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 *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]) {
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;
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 (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;
&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;
if (error) {
*recursion = 0;
return error;
if (*recursion) {
--*recursion;
return NULL;
char *str;
return err;
return NULL;
&core_module);
static int banner_locked = 0;
enum server_token_type {
banner_locked = 0;
return APR_SUCCESS;
if (! banner_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 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 *filter_name;
if (old) {
while (*arg &&
if (old) {
if (!new) {
return NULL;
const char *ctype;
&core_module);
if (ctype) {
while (ct_filter) {
const char *arg1)
&core_module);
return NULL;
#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);
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;
return HTTP_NOT_IMPLEMENTED;
return ap_send_http_options(r);
return HTTP_METHOD_NOT_ALLOWED;
static int sys_privileges = 0;
return sys_privileges;
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;