mod_cgi.c revision 8c515be8b2e0effe6071f5ec92a8882a5e6944d7
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend/* ====================================================================
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi * The Apache Software License, Version 1.1
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Copyright (c) 2000 The Apache Software Foundation. All rights
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * reserved.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Redistribution and use in source and binary forms, with or without
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * modification, are permitted provided that the following conditions
b4a00883f358625923365ca1560c96edec172a52sf * are met:
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 1. Redistributions of source code must retain the above copyright
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * notice, this list of conditions and the following disclaimer.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 2. Redistributions in binary form must reproduce the above copyright
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * notice, this list of conditions and the following disclaimer in
909ce17e2bd0faef7b1c294f2307f009793fd493nd * the documentation and/or other materials provided with the
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * distribution.
a29610af88e278144045bfa1bc63b4a1a4b5ff14trawick * 3. The end-user documentation included with the redistribution,
42af92a661a06b3cebc88d585aad75064a309d51nd * if any, must include the following acknowledgment:
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * "This product includes software developed by the
6fe26506780e73be2a412d758af77fafdf03291and * Apache Software Foundation (http://www.apache.org/)."
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Alternately, this acknowledgment may appear in the software itself,
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * if and wherever such third-party acknowledgments normally appear.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 4. The names "Apache" and "Apache Software Foundation" must
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * not be used to endorse or promote products derived from this
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * software without prior written permission. For written
43f6cc6aa3312619633538b8978619a48c0ce52eminfrin * permission, please contact apache@apache.org.
78f97ce162b66a0dbfd7af4dcd9984f162569b04minfrin * 5. Products derived from this software may not be called "Apache",
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * nor may "Apache" appear in their name, without prior written
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * permission of the Apache Software Foundation.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrin * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
05ede5110427cb9dc071cc671d5aaba5d3b88c79nd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2f39535ac2206b346dcfbcaf271e3addc901f520rbowen * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
d6ce05b6521a82cc93da69f7c2116c4a5bc54f8cjim * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * SUCH DAMAGE.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ====================================================================
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * This software consists of voluntary contributions made by many
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * individuals on behalf of the Apache Software Foundation. For more
03a4ff9ac4c9b8009249010e7c53bb86ff05915and * information on the Apache Software Foundation, please see
1e367a83311e5243e04d68857d007d04765a48f9chrisd * Portions of this software are based upon public domain software
1e367a83311e5243e04d68857d007d04765a48f9chrisd * originally written at the National Center for Supercomputing Applications,
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * University of Illinois, Urbana-Champaign.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * http_script: keeps all script-related ramblings together.
2704de98885368683621b01c8f8f4e4b01557611takashi * Compliant to CGI/1.1 spec
1e367a83311e5243e04d68857d007d04765a48f9chrisd * Adapted by rst from original NCSA code by Rob McCool
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Apache adds some new env vars; REDIRECT_URL and REDIRECT_QUERY_STRING for
c819c19c2f1ffbf3a3f12a4070cc6c3f4ea2a6f2sf * custom error responses, and DOCUMENT_ROOT because we found it useful.
d2b809e5d72658bff23819d8b77f20e4939af541nd * It also adds SERVER_ADMIN - useful for scripts to know who to mail when
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * they fail.
5332c9934b1c0136e9cd4815fe7d70b79d83fddcsf/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl * in ScriptAliased directories, which means we need to know if this
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * request came through ScriptAlias or not... so the Alias module
79b024b81f6bb3c44dce77a7552191daf8b522d2jim * leaves a note for us.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend const char *t = ap_table_get(r->notes, "alias-forced-type");
856894d144a15ef1671032a17965bd00b430d311minfrin/* Configuration stuff */
0ce5630695a7aa568811a9dd0aceedd685f040dendtypedef struct {
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fendstatic void *create_cgi_config(ap_pool_t *p, server_rec *s)
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend (cgi_server_conf *) ap_pcalloc(p, sizeof(cgi_server_conf));
0ce5630695a7aa568811a9dd0aceedd685f040dendstatic void *merge_cgi_config(ap_pool_t *p, void *basev, void *overridesv)
return NULL;
return NULL;
return NULL;
{NULL}
return ret;
ap_close(f);
return ret;
char *newline;
if (newline) {
return ret;
&& *dbuf) {
ap_close(f);
return ret;
char **env;
#ifdef DEBUG_CGI
#ifdef OS2
#ifdef DEBUG_CGI
ap_add_cgi_vars(r);
#ifdef DEBUG_CGI
for (i = 0; env[i]; ++i)
if (!iol)
return APR_EBADF;
if (!iol)
return APR_EBADF;
if (!iol)
return APR_EBADF;
return (rc);
++numwords;
ap_unescape_url(w);
return APR_SUCCESS;
#ifdef WIN32
*c = NULL;
r->filename);
return APR_EBADF;
return APR_SUCCESS;
char *command;
ap_pool_t *p;
return DECLINED;
argv0++;
char *newfile;
return retval;
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
if (ap_should_client_block(r)) {
dbpos = 0;
while ((len_read =
const char *location;
int ret;
return OK;
return REDIRECT;
if (!r->header_only) {
{NULL}