request.c revision f08810eff40a2bddd2bc0103453c4ae775ea62be
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin/* ====================================================================
902bfaac7e88afebb6684fe1f2414ae2efbc7edfChristian Maeder * The Apache Software License, Version 1.1
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin * Redistribution and use in source and binary forms, with or without
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin * modification, are permitted provided that the following conditions
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin * 1. Redistributions of source code must retain the above copyright
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * notice, this list of conditions and the following disclaimer.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * 2. Redistributions in binary form must reproduce the above copyright
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * notice, this list of conditions and the following disclaimer in
902bfaac7e88afebb6684fe1f2414ae2efbc7edfChristian Maeder * the documentation and/or other materials provided with the
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin * distribution.
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin * 3. The end-user documentation included with the redistribution,
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin * if any, must include the following acknowledgment:
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin * "This product includes software developed by the
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * Apache Software Foundation (http://www.apache.org/)."
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * Alternately, this acknowledgment may appear in the software itself,
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * if and wherever such third-party acknowledgments normally appear.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * 4. The names "Apache" and "Apache Software Foundation" must
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * not be used to endorse or promote products derived from this
902bfaac7e88afebb6684fe1f2414ae2efbc7edfChristian Maeder * software without prior written permission. For written
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * permission, please contact apache@apache.org.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * 5. Products derived from this software may not be called "Apache",
902bfaac7e88afebb6684fe1f2414ae2efbc7edfChristian Maeder * nor may "Apache" appear in their name, without prior written
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * permission of the Apache Software Foundation.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
902bfaac7e88afebb6684fe1f2414ae2efbc7edfChristian Maeder * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
902bfaac7e88afebb6684fe1f2414ae2efbc7edfChristian Maeder * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
81c09542d31779a407196fbd710aa8e69a815522Georgel Calin * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * SUCH DAMAGE.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * ====================================================================
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * This software consists of voluntary contributions made by many
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * individuals on behalf of the Apache Software Foundation. For more
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * information on the Apache Software Foundation, please see
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * Portions of this software are based upon public domain software
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * originally written at the National Center for Supercomputing Applications,
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * University of Illinois, Urbana-Champaign.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * http_request.c: functions to get and process requests
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * Rob McCool 3/21/93
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * Thoroughly revamped by rst for Apache. NB this file reads
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * best from the bottom up.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel CalinAP_IMPLEMENT_HOOK_RUN_FIRST(int,translate_name,
902bfaac7e88afebb6684fe1f2414ae2efbc7edfChristian MaederAP_IMPLEMENT_HOOK_RUN_FIRST(int,map_to_storage,
05d4bb01e11ad19f2efb41a3efec59a7784c9942Christian MaederAP_IMPLEMENT_HOOK_RUN_FIRST(int,check_user_id,
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel CalinAP_IMPLEMENT_HOOK_VOID(insert_filter, (request_rec *r), (r))
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calinstatic int decl_die(int status, char *phase, request_rec *r)
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_CRIT, 0, r,
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin "configuration error: couldn't %s: %s", phase, r->uri);
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin/* This is the master logic for processing requests. Do NOT duplicate
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * this logic elsewhere, or the security model will be broken by future
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * API changes. Each phase must be individually optimized to pick up
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * redundant/duplicate calls by subrequests, and redirects.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel CalinAP_DECLARE(int) ap_process_request_internal(request_rec *r)
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin /* Ignore embedded %2F's in path for proxy requests */
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin access_status = ap_unescape_url(r->parsed_uri.path);
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin ap_getparents(r->uri); /* OK --- shrinking transformations... */
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin /* All file subrequests are a huge pain... they cannot bubble through the
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin * next several steps. Only file subrequests are allowed an empty uri,
05d4bb01e11ad19f2efb41a3efec59a7784c9942Christian Maeder * otherwise let translate_name kill the request.
3d13c5135e7bab987599acf23afe9c59df49b06fGeorgel Calin if ((access_status = ap_run_translate_name(r))) {
902bfaac7e88afebb6684fe1f2414ae2efbc7edfChristian Maeder return decl_die(access_status, "translate", r);
return access_status;
if (!file_req) {
return access_status;
return access_status;
switch (ap_satisfies(r)) {
case SATISFY_ALL:
case SATISFY_NOSPEC:
if (ap_some_auth_required(r)) {
|| !ap_auth_type(r)) {
|| !ap_auth_type(r)) {
case SATISFY_ANY:
|| !ap_auth_type(r)) {
if (!ap_some_auth_required(r)) {
|| !ap_auth_type(r)) {
|| !ap_auth_type(r)) {
* in mod-proxy for r->proxyreq && r->parsed_uri.scheme
* && !strcmp(r->parsed_uri.scheme, "http")
return access_status;
return OK;
* Directive order in the httpd.conf file and its Includes significantly
typedef struct walk_walked_t {
typedef struct walk_cache_t {
} walk_cache_t;
void **note;
if (!note) {
return NULL;
void **inherit_note;
if ((r->main
&& *inherit_note)
|| (r->prev
&& *inherit_note)) {
sizeof(*cache));
return cache;
return OK;
r->filename);
return HTTP_FORBIDDEN;
int res;
const char *savename;
return HTTP_FORBIDDEN;
p)) != APR_SUCCESS) {
return HTTP_FORBIDDEN;
if (savename) {
return OK;
!= APR_SUCCESS) {
return HTTP_FORBIDDEN;
!= APR_SUCCESS) {
return HTTP_FORBIDDEN;
return HTTP_FORBIDDEN;
if (savename) {
return OK;
&core_module);
char *entry_dir;
r->uri);
return OK;
!= APR_SUCCESS) {
return OK;
/* some OSs will return APR_SUCCESS/APR_REG if we stat
* Otherwise (as is the case with most dir_merged/file_merged requests)
return OK;
return OK;
int sec_idx;
char *save_path_info;
char *buf;
#ifdef CASE_BLIND_FILESYSTEM
r->path_info,
!= APR_SUCCESS) {
return HTTP_INTERNAL_SERVER_ERROR;
#ifdef CASE_BLIND_FILESYSTEM
canonical_len = 0;
while (canonical_len
(const char **)&r->path_info,
r->pool);
(const char **)&r->path_info,
canonical_len = 0;
(const char **)&r->path_info,
0, r->pool);
return HTTP_INTERNAL_SERVER_ERROR;
sec_idx = 0;
int res;
char *seg_name;
char *delim;
int temp_slash=0;
if (matches) {
++last_walk;
--matches;
goto minimerge;
matches = 0;
if (now_merged) {
* See core.c::merge_core_dir_configs() for explanation.
if (!this_dir) {
if (res) {
return res;
if (htaccess_conf) {
if (matches) {
++last_walk;
--matches;
goto minimerge2;
matches = 0;
if (now_merged) {
* See core.c::merge_core_dir_configs() for explanation.
&core_module);
if (this_dir) {
if (temp_slash) {
if (delim) {
++seg_name;
if (!*seg_name) {
#ifdef CASE_BLIND_FILESYSTEM
++seg;
return res;
r->filename);
r->filename);
++seg;
if (save_path_info) {
if (!entry_core->r) {
if (matches) {
++last_walk;
--matches;
goto minimerge;
matches = 0;
if (now_merged) {
if (matches) {
x * APR_DIR test. But if you accessed /symlink/index.html, for example,
if (now_merged) {
r->per_dir_config,
return OK;
&core_module);
const char *entry_uri;
if (!num_sec) {
return OK;
/* Location and LocationMatch differ on their behaviour w.r.t. multiple
* Otherwise (as is the case with most dir_merged/file_merged requests)
return OK;
return OK;
if (entry_core->r
if (matches) {
++last_walk;
--matches;
matches = 0;
if (now_merged) {
if (matches) {
if (now_merged) {
r->per_dir_config,
return OK;
&core_module);
const char *test_file;
return OK;
if (!num_sec) {
return OK;
return OK;
return OK;
int sec_idx;
if (entry_core->r
if (matches) {
++last_walk;
--matches;
matches = 0;
if (now_merged) {
if (matches) {
if (now_merged) {
r->per_dir_config,
return OK;
if (next_filter) {
return rnew;
if (APR_BUCKET_IS_EOS(e)) {
return APR_SUCCESS;
if (!reqs_arr) {
const char *new_file,
const request_rec *r,
int res;
char *udir;
return rnew;
const request_rec *r,
const request_rec *r,
int subtype,
int res;
char *fdir;
char *udir;
!= OK) {
return rnew;
return rnew;
const request_rec *r,
int res;
char *fdir;
return rnew;
return rnew;
return retval;