mod_cgi.c revision 15cdcf089057a76a4dbda4d7f22e1ab69ebe051a
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend/* ====================================================================
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Redistribution and use in source and binary forms, with or without
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * modification, are permitted provided that the following conditions
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 1. Redistributions of source code must retain the above copyright
b4a00883f358625923365ca1560c96edec172a52sf * notice, this list of conditions and the following disclaimer.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 2. Redistributions in binary form must reproduce the above copyright
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * notice, this list of conditions and the following disclaimer in
d9b843d090f14405079b4a61a493316cd3f1e5b9minfrin * the documentation and/or other materials provided with the
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * distribution.
909ce17e2bd0faef7b1c294f2307f009793fd493nd * 3. All advertising materials mentioning features or use of this
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * software must display the following acknowledgment:
0ce5630695a7aa568811a9dd0aceedd685f040dend * "This product includes software developed by the Apache Group
a29610af88e278144045bfa1bc63b4a1a4b5ff14trawick * for use in the Apache HTTP server project (http://www.apache.org/)."
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * 4. The names "Apache Server" and "Apache Group" must not be used to
6fe26506780e73be2a412d758af77fafdf03291and * endorse or promote products derived from this software without
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * prior written permission. For written permission, please contact
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * apache@apache.org.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 5. Products derived from this software may not be called "Apache"
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * nor may "Apache" appear in their names without prior written
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * permission of the Apache Group.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 6. Redistributions of any form whatsoever must retain the following
78f97ce162b66a0dbfd7af4dcd9984f162569b04minfrin * acknowledgment:
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * "This product includes software developed by the Apache Group
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * for use in the Apache HTTP server project (http://www.apache.org/)."
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrin * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
05ede5110427cb9dc071cc671d5aaba5d3b88c79nd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2f39535ac2206b346dcfbcaf271e3addc901f520rbowen * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
d6ce05b6521a82cc93da69f7c2116c4a5bc54f8cjim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * OF THE POSSIBILITY OF SUCH DAMAGE.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ====================================================================
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * This software consists of voluntary contributions made by many
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * individuals on behalf of the Apache Group and was originally based
03a4ff9ac4c9b8009249010e7c53bb86ff05915and * on public domain software written at the National Center for
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Supercomputing Applications, University of Illinois, Urbana-Champaign.
1e367a83311e5243e04d68857d007d04765a48f9chrisd * For more information on the Apache Group and the Apache HTTP server
1e367a83311e5243e04d68857d007d04765a48f9chrisd * project, please see <http://www.apache.org/>.
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.
4126704c4950bfd46d32ad54e3b106ac6d868a73sf/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * in ScriptAliased directories, which means we need to know if this
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd * request came through ScriptAlias or not... so the Alias module
ebdfe3e677aaa92fe2df702295eac81a97a4610frbowen * leaves a note for us.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend const char *t = ap_table_get(r->notes, "alias-forced-type");
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin/* Configuration stuff */
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fendtypedef struct {
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fendstatic void *create_cgi_config(ap_context_t *p, server_rec *s)
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend (cgi_server_conf *) ap_pcalloc(p, sizeof(cgi_server_conf));
0ce5630695a7aa568811a9dd0aceedd685f040dendstatic void *merge_cgi_config(ap_context_t *p, void *basev, void *overridesv)
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend cgi_server_conf *base = (cgi_server_conf *) basev, *overrides = (cgi_server_conf *) overridesv;
return NULL;
return NULL;
return NULL;
{NULL}
ap_file_t *f;
return ret;
ap_close(f);
return ret;
ap_file_t *f;
#ifdef WIN32
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)
#ifndef WIN32
if (script_in) {
if (!iol)
return APR_EBADF;
if (script_out) {
if (!iol)
return APR_EBADF;
if (script_err) {
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_context_t *p;
return DECLINED;
argv0++;
char *newfile;
return retval;
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
else if (run_cgi_child(&script_out, &script_in, &script_err, command, &argv, r, p) != APR_SUCCESS) {
return HTTP_INTERNAL_SERVER_ERROR;
if (ap_should_client_block(r)) {
dbpos = 0;
while ((len_read =
const char *location;
int ret;
#ifdef CHARSET_EBCDIC
ap_checkconv(r);
return OK;
return REDIRECT;
if (!r->header_only) {
{NULL}