mod_cgi.c revision b08aede24851a9e00d75883c2012e51ad9a92466
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend/* ====================================================================
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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 * 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
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * notice, this list of conditions and the following disclaimer in
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * the documentation and/or other materials provided with the
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * distribution.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 3. All advertising materials mentioning features or use of this
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * software must display the following 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 * 4. The names "Apache Server" and "Apache Group" must not be used to
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * on public domain software written at the National Center for
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Supercomputing Applications, University of Illinois, Urbana-Champaign.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * For more information on the Apache Group and the Apache HTTP server
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * project, please see <http://www.apache.org/>.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * http_script: keeps all script-related ramblings together.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 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.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * It also adds SERVER_ADMIN - useful for scripts to know who to mail when
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * they fail.
#include "http_conf_globals.h"
char *logname;
long logbytes;
int bufbytes;
cgi_server_conf *c =
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 (!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;
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}