mod_cgi.c revision 0c94dfa6040c524600c964bff626db0c69342d9d
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering/* ====================================================================
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * Redistribution and use in source and binary forms, with or without
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * modification, are permitted provided that the following conditions
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * 1. Redistributions of source code must retain the above copyright
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * notice, this list of conditions and the following disclaimer.
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering * 2. Redistributions in binary form must reproduce the above copyright
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * notice, this list of conditions and the following disclaimer in
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * the documentation and/or other materials provided with the
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * distribution.
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * 3. All advertising materials mentioning features or use of this
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering * software must display the following acknowledgment:
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * "This product includes software developed by the Apache Group
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering * for use in the Apache HTTP server project (http://www.apache.org/)."
151b190e79e64824552e01849352ca8f6ac7dedbLennart Poettering * 4. The names "Apache Server" and "Apache Group" must not be used to
d3fae78fe86f1dfcdb07fd613ccbb3adf547a617Josh Triplett * endorse or promote products derived from this software without
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * prior written permission. For written permission, please contact
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * apache@apache.org.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * 5. Products derived from this software may not be called "Apache"
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * nor may "Apache" appear in their names without prior written
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * permission of the Apache Group.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * 6. Redistributions of any form whatsoever must retain the following
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * acknowledgment:
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * "This product includes software developed by the Apache Group
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * for use in the Apache HTTP server project (http://www.apache.org/)."
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * OF THE POSSIBILITY OF SUCH DAMAGE.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * ====================================================================
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * This software consists of voluntary contributions made by many
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * individuals on behalf of the Apache Group and was originally based
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * on public domain software written at the National Center for
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Supercomputing Applications, University of Illinois, Urbana-Champaign.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * For more information on the Apache Group and the Apache HTTP server
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * project, please see <http://www.apache.org/>.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * http_script: keeps all script-related ramblings together.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Compliant to CGI/1.1 spec
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Adapted by rst from original NCSA code by Rob McCool
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * Apache adds some new env vars; REDIRECT_URL and REDIRECT_QUERY_STRING for
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * custom error responses, and DOCUMENT_ROOT because we found it useful.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * It also adds SERVER_ADMIN - useful for scripts to know who to mail when
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekmodule MODULE_VAR_EXPORT cgi_module;
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * in ScriptAliased directories, which means we need to know if this
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * request came through ScriptAlias or not... so the Alias module
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek * leaves a note for us.
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmekstatic int is_scriptaliased(request_rec *r)
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek const char *t = ap_table_get(r->notes, "alias-forced-type");
798d3a524ea57aaf40cb53858aaa45ec702f012dZbigniew Jędrzejewski-Szmek return t && (!strcasecmp(t, "cgi-script"));
char *logname;
long logbytes;
int bufbytes;
cgi_server_conf *c =
return NULL;
return NULL;
return NULL;
{NULL}
return ret;
ap_close(f);
return ret;
#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)
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_context_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}