mod_cgi.c revision ea94c7eb3ab932fa14a2e5d787ff276553880d13
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
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * are met:
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 1. Redistributions of source code must retain the above copyright
d9b843d090f14405079b4a61a493316cd3f1e5b9minfrin * notice, this list of conditions and the following disclaimer.
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * 2. Redistributions in binary form must reproduce the above copyright
909ce17e2bd0faef7b1c294f2307f009793fd493nd * notice, this list of conditions and the following disclaimer in
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * the documentation and/or other materials provided with the
0ce5630695a7aa568811a9dd0aceedd685f040dend * distribution.
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * 3. The end-user documentation included with the redistribution,
6fe26506780e73be2a412d758af77fafdf03291and * if any, must include the following acknowledgment:
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * "This product includes software developed by the
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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
43f6cc6aa3312619633538b8978619a48c0ce52eminfrin * not be used to endorse or promote products derived from this
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * software without prior written permission. For written
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * permission, please contact apache@apache.org.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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.
05ede5110427cb9dc071cc671d5aaba5d3b88c79nd * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd * 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
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
d6ce05b6521a82cc93da69f7c2116c4a5bc54f8cjim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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.
03a4ff9ac4c9b8009249010e7c53bb86ff05915and * ====================================================================
1e367a83311e5243e04d68857d007d04765a48f9chrisd * This software consists of voluntary contributions made by many
1e367a83311e5243e04d68857d007d04765a48f9chrisd * individuals on behalf of the Apache Software Foundation. For more
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * information on the Apache Software Foundation, please see
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Portions of this software are based upon public domain software
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * originally written at the National Center for Supercomputing Applications,
2704de98885368683621b01c8f8f4e4b01557611takashi * University of Illinois, Urbana-Champaign.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * http_script: keeps all script-related ramblings together.
d2b809e5d72658bff23819d8b77f20e4939af541nd * Compliant to CGI/1.1 spec
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Adapted by rst from original NCSA code by Rob McCool
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Apache adds some new env vars; REDIRECT_URL and REDIRECT_QUERY_STRING for
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * custom error responses, and DOCUMENT_ROOT because we found it useful.
27d778df0b517e1578f907d2e51eb961cd8ee5fbjim * It also adds SERVER_ADMIN - useful for scripts to know who to mail when
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * they fail.
0ce5630695a7aa568811a9dd0aceedd685f040dend/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * in ScriptAliased directories, which means we need to know if this
10eed2803538d660048f6e733602e82a75ef6885noodl * request came through ScriptAlias or not... so the Alias module
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * leaves a note for us.
03c25fb6f628ac81f2ecb637d1e7502dcee783f3nd const char *t = ap_table_get(r->notes, "alias-forced-type");
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend/* Configuration stuff */
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fendtypedef struct {
char *logname;
long logbytes;
int bufbytes;
cgi_server_conf *c =
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;
#ifdef CHARSET_EBCDIC
ap_checkconv(r);
return OK;
return REDIRECT;
if (!r->header_only) {
{NULL}