mod_cgi.c revision 1a9f3fd327fd87101580ee3c9924ef3210d490bf
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
4b311579b2c8aebac85fb7cb8ac89e6c37b4bc1asf * are met:
50c04f297d76a57ead2fa6b73845f7563b1fc788sf * 1. Redistributions of source code must retain the above copyright
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * notice, this list of conditions and the following disclaimer.
d9b843d090f14405079b4a61a493316cd3f1e5b9minfrin * 2. Redistributions in binary form must reproduce the above copyright
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * notice, this list of conditions and the following disclaimer in
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * the documentation and/or other materials provided with the
909ce17e2bd0faef7b1c294f2307f009793fd493nd * distribution.
0ce5630695a7aa568811a9dd0aceedd685f040dend * 3. The end-user documentation included with the redistribution,
a29610af88e278144045bfa1bc63b4a1a4b5ff14trawick * if any, must include the following acknowledgment:
42af92a661a06b3cebc88d585aad75064a309d51nd * "This product includes software developed by the
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes * Apache Software Foundation (http://www.apache.org/)."
6fe26506780e73be2a412d758af77fafdf03291and * 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
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * permission, please contact apache@apache.org.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * 5. Products derived from this software may not be called "Apache",
78f97ce162b66a0dbfd7af4dcd9984f162569b04minfrin * nor may "Apache" appear in their name, without prior written
0734f81384d5f2528bb119f89d135043a280d5b2minfrin * permission of the Apache Software Foundation.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
7906201913b68fe78b9d6a22ab33bf21d82c490eminfrin * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
05ede5110427cb9dc071cc671d5aaba5d3b88c79nd * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2f39535ac2206b346dcfbcaf271e3addc901f520rbowen * 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
d6ce05b6521a82cc93da69f7c2116c4a5bc54f8cjim * SUCH DAMAGE.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * ====================================================================
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * This software consists of voluntary contributions made by many
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * individuals on behalf of the Apache Software Foundation. For more
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * information on the Apache Software Foundation, please see
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin * Portions of this software are based upon public domain software
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * originally written at the National Center for Supercomputing Applications,
1e367a83311e5243e04d68857d007d04765a48f9chrisd * University of Illinois, Urbana-Champaign.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * http_script: keeps all script-related ramblings together.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * Compliant to CGI/1.1 spec
2704de98885368683621b01c8f8f4e4b01557611takashi * Adapted by rst from original NCSA code by Rob McCool
1e367a83311e5243e04d68857d007d04765a48f9chrisd * 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
c819c19c2f1ffbf3a3f12a4070cc6c3f4ea2a6f2sf * they fail.
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
f195a136dcd90148b116fdae8ce95b41ba92b87eminfrin * in ScriptAliased directories, which means we need to know if this
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend * request came through ScriptAlias or not... so the Alias module
1de1266f0ea387d6373be8415745dfd2ab876341jim * leaves a note for us.
856894d144a15ef1671032a17965bd00b430d311minfrin const char *t = apr_table_get(r->notes, "alias-forced-type");
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend/* Configuration stuff */
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fendtypedef struct {
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend const char *logname;
0ce5630695a7aa568811a9dd0aceedd685f040dendstatic void *create_cgi_config(apr_pool_t *p, server_rec *s)
316f02e3836836c82e19019ff23f90a7ebc65289nilgun (cgi_server_conf *) apr_pcalloc(p, sizeof(cgi_server_conf));
return NULL;
const char *arg)
return NULL;
const char *arg)
return NULL;
{NULL}
return ret;
apr_close(f);
return ret;
char *newline;
if (newline) {
return ret;
&& *dbuf) {
apr_close(f);
return ret;
const char *command,
const char * const argv[],
const char * const *env;
#ifdef DEBUG_CGI
#ifdef OS2
#ifdef DEBUG_CGI
ap_add_cgi_vars(r);
#ifdef DEBUG_CGI
for (i = 0; env[i]; ++i)
#ifdef RLIMIT_CPU
#ifdef RLIMIT_NPROC
if (!script_in)
return APR_EBADF;
if (!*script_out)
return APR_EBADF;
if (!*script_err)
return APR_EBADF;
return (rc);
apr_pool_t *p)
++numwords;
ap_unescape_url(w);
return APR_SUCCESS;
apr_pool_t *p)
#ifdef WIN32
const char *argv0;
argv0++;
#ifdef WIN32
r->filename);
return APR_EBADF;
return APR_SUCCESS;
const char *argv0;
const char *command;
const char **argv;
ap_bucket *b;
apr_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 =
bytes_written = 0;
const char *location;
int ret;
return OK;
return HTTP_MOVED_TEMPORARILY;
if (!r->header_only) {
b = ap_bucket_create_eos();
b = ap_bucket_create_eos();
{NULL}