mod_cgi.c revision 750ec6495c0f3f2786f0655420fe604a1a91725b
97a9a944b5887e91042b019776c41d5dd74557aferikabele/* ====================================================================
97a9a944b5887e91042b019776c41d5dd74557aferikabele * The Apache Software License, Version 1.1
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * Copyright (c) 2000 The Apache Software Foundation. All rights
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive * reserved.
356cf74f7c5d5d2ff4dae567ebeb8dc23e8bcd21nd * Redistribution and use in source and binary forms, with or without
d9acf35ddaf5792bb76f8b0cc47b26cd51482abaslive * modification, are permitted provided that the following conditions
d9acf35ddaf5792bb76f8b0cc47b26cd51482abaslive * 1. Redistributions of source code must retain the above copyright
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * notice, this list of conditions and the following disclaimer.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * 2. Redistributions in binary form must reproduce the above copyright
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * notice, this list of conditions and the following disclaimer in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * the documentation and/or other materials provided with the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * distribution.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * 3. The end-user documentation included with the redistribution,
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * if any, must include the following acknowledgment:
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * "This product includes software developed by the
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * Apache Software Foundation (http://www.apache.org/)."
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * Alternately, this acknowledgment may appear in the software itself,
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * if and wherever such third-party acknowledgments normally appear.
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * 4. The names "Apache" and "Apache Software Foundation" must
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * not be used to endorse or promote products derived from this
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * software without prior written permission. For written
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * permission, please contact apache@apache.org.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * 5. Products derived from this software may not be called "Apache",
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * nor may "Apache" appear in their name, without prior written
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * permission of the Apache Software Foundation.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
97a9a944b5887e91042b019776c41d5dd74557aferikabele * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
97a9a944b5887e91042b019776c41d5dd74557aferikabele * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
97a9a944b5887e91042b019776c41d5dd74557aferikabele * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3a6531f1fd50efd78381e5800802a1449096781eslive * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * SUCH DAMAGE.
97a9a944b5887e91042b019776c41d5dd74557aferikabele * ====================================================================
97a9a944b5887e91042b019776c41d5dd74557aferikabele * This software consists of voluntary contributions made by many
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * individuals on behalf of the Apache Software Foundation. For more
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * information on the Apache Software Foundation, please see
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * Portions of this software are based upon public domain software
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * originally written at the National Center for Supercomputing Applications,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * University of Illinois, Urbana-Champaign.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * http_script: keeps all script-related ramblings together.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * Compliant to CGI/1.1 spec
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * Adapted by rst from original NCSA code by Rob McCool
97a9a944b5887e91042b019776c41d5dd74557aferikabele * Apache adds some new env vars; REDIRECT_URL and REDIRECT_QUERY_STRING for
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * custom error responses, and DOCUMENT_ROOT because we found it useful.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * It also adds SERVER_ADMIN - useful for scripts to know who to mail when
97a9a944b5887e91042b019776c41d5dd74557aferikabele * they fail.
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic APR_OPTIONAL_FN_TYPE(ap_register_include_handler) *cgi_pfn_reg_with_ssi;
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic APR_OPTIONAL_FN_TYPE(ap_ssi_get_tag_and_value) *cgi_pfn_gtv;
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic APR_OPTIONAL_FN_TYPE(ap_ssi_parse_string) *cgi_pfn_ps;
06ba4a61654b3763ad65f52283832ebf058fdf1cslivetypedef struct {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * in ScriptAliased directories, which means we need to know if this
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * request came through ScriptAlias or not... so the Alias module
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * leaves a note for us.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char *t = apr_table_get(r->notes, "alias-forced-type");
06ba4a61654b3763ad65f52283832ebf058fdf1cslive/* Configuration stuff */
06ba4a61654b3763ad65f52283832ebf058fdf1cslivetypedef struct {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char *logname;
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic void *create_cgi_config(apr_pool_t *p, server_rec *s)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (cgi_server_conf *) apr_pcalloc(p, sizeof(cgi_server_conf));
97a9a944b5887e91042b019776c41d5dd74557aferikabelestatic void *merge_cgi_config(apr_pool_t *p, void *basev, void *overridesv)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive cgi_server_conf *base = (cgi_server_conf *) basev, *overrides = (cgi_server_conf *) overridesv;
a817d8e293a7f9c369af84ba98ba57eaf3544f94slivestatic const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic const char *set_scriptlog_length(cmd_parms *cmd, void *dummy,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char *arg)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char *arg)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
06ba4a61654b3763ad65f52283832ebf058fdf1csliveAP_INIT_TAKE1("ScriptLog", set_scriptlog, NULL, RSRC_CONF,
97a9a944b5887e91042b019776c41d5dd74557aferikabele "the name of a log for script debugging info"),
06ba4a61654b3763ad65f52283832ebf058fdf1csliveAP_INIT_TAKE1("ScriptLogLength", set_scriptlog_length, NULL, RSRC_CONF,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "the maximum length (in bytes) of the script debug log"),
06ba4a61654b3763ad65f52283832ebf058fdf1csliveAP_INIT_TAKE1("ScriptLogBuffer", set_scriptlog_buffer, NULL, RSRC_CONF,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "the maximum size (in bytes) to record of a POST request"),
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic int log_scripterror(request_rec *r, cgi_server_conf * conf, int ret,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive int log_flags = rv ? APLOG_ERR : APLOG_NOERRNO | APLOG_ERR;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ((apr_stat(&finfo, ap_server_root_relative(r->pool, conf->logname),
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (apr_file_open(&f, ap_server_root_relative(r->pool, conf->logname),
06ba4a61654b3763ad65f52283832ebf058fdf1cslive APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* "%% [Wed Jun 19 10:53:21 1996] GET /cgi-bin/printenv HTTP/1.0" */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_file_printf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive r->args ? "?" : "", r->args ? r->args : "", r->protocol);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive/* Soak up stderr from a script and redirect it to the error log.
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic void log_script_err(request_rec *r, apr_file_t *script_err)
f70d7fc7f4398e5dfbbc562c638ddcbbd2ae8b82yoshiki while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err) == 0) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic int log_script(request_rec *r, cgi_server_conf * conf, int ret,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_table_entry_t *hdrs = (apr_table_entry_t *) hdrs_arr->elts;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ((apr_stat(&finfo, ap_server_root_relative(r->pool, conf->logname),
06ba4a61654b3763ad65f52283832ebf058fdf1cslive (apr_file_open(&f, ap_server_root_relative(r->pool, conf->logname),
06ba4a61654b3763ad65f52283832ebf058fdf1cslive APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* Soak up script output */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == 0)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* "%% [Wed Jun 19 10:53:21 1996] GET /cgi-bin/printenv HTTP/1.0" */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_file_printf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive r->args ? "?" : "", r->args ? r->args : "", r->protocol);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_file_printf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if ((r->method_number == M_POST || r->method_number == M_PUT)
97a9a944b5887e91042b019776c41d5dd74557aferikabele apr_file_printf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == 0) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_in) == 0)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err) == 0) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err) == 0)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive/* This is the special environment used for running the "exec cmd="
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * variety of SSI directives.
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic void add_ssi_vars(request_rec *r, ap_filter_t *next)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_table_setn(e, "PATH_INFO", ap_escape_shell_cmd(r->pool, r->path_info));
06ba4a61654b3763ad65f52283832ebf058fdf1cslive pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info), r, next);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_pstrcat(r->pool, pa_req->filename, pa_req->path_info, NULL));
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_table_setn(e, "QUERY_STRING_UNESCAPED", ap_escape_shell_cmd(r->pool, arg_copy));
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic apr_status_t run_cgi_child(apr_file_t **script_out,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char *command,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char * const argv[],
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char * const *env;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined (RLIMIT_AS)
06ba4a61654b3763ad65f52283832ebf058fdf1cslive conf = (core_dir_config *) ap_get_module_config(r->per_dir_config, &core_module);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* Under OS/2 need to use device con. */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive fprintf(dbg, "Attempting to exec %s as %sCGI child (argv0 = %s)\n",
97a9a944b5887e91042b019776c41d5dd74557aferikabele else /* SSIs want a controlled environment and a special path. */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive env = (const char * const *)ap_create_environment(p, r->subprocess_env);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive for (i = 0; env[i]; ++i)
97a9a944b5887e91042b019776c41d5dd74557aferikabele /* Transmute ourselves into the script.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * NB only ISINDEX scripts get decoded arguments.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if (((rc = apr_procattr_create(&procattr, p)) != APR_SUCCESS) ||
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ap_make_dirstr_parent(r->pool, r->filename))) != APR_SUCCESS) ||
97a9a944b5887e91042b019776c41d5dd74557aferikabele ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU, conf->limit_cpu)) != APR_SUCCESS) ||
97a9a944b5887e91042b019776c41d5dd74557aferikabele#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
97a9a944b5887e91042b019776c41d5dd74557aferikabele ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_MEM, conf->limit_mem)) != APR_SUCCESS) ||
97a9a944b5887e91042b019776c41d5dd74557aferikabele ((rc = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC, conf->limit_nproc)) != APR_SUCCESS) ||
97a9a944b5887e91042b019776c41d5dd74557aferikabele ((rc = apr_procattr_cmdtype_set(procattr, e_info->cmd_type)) != APR_SUCCESS)) {
97a9a944b5887e91042b019776c41d5dd74557aferikabele /* Something bad happened, tell the world. */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "couldn't set child process attributes: %s", r->filename);
97a9a944b5887e91042b019776c41d5dd74557aferikabele SPLIT_AND_PASS_PRETAG_BUCKETS(*(e_info->bb), e_info->ctx, e_info->next);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive rc = ap_os_create_privileged_process(r, procnew, command, argv, env, procattr, p);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* Bad things happened. Everyone should have cleaned up. */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive "couldn't create child process: %d: %s", rc, r->filename);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_pool_note_subprocess(p, procnew, kill_after_timeout);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_file_pipe_timeout_set(*script_in, (int)(r->server->timeout * APR_USEC_PER_SEC));
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_file_pipe_timeout_set(*script_out, (int)(r->server->timeout * APR_USEC_PER_SEC));
06ba4a61654b3763ad65f52283832ebf058fdf1cslive apr_file_pipe_timeout_set(*script_err, (int)(r->server->timeout * APR_USEC_PER_SEC));
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic apr_status_t build_argv_list(const char ***argv, request_rec *r,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* count the number of keywords */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* Everything is - 1 to account for the first parameter which is the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * program name. We didn't used to have to do this, but APR wants it.
06ba4a61654b3763ad65f52283832ebf058fdf1cslive numwords = APACHE_ARG_MAX - 1; /* Truncate args to prevent overrun */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive *argv = apr_palloc(p, (numwords + 2) * sizeof(char *));
06ba4a61654b3763ad65f52283832ebf058fdf1cslivestatic apr_status_t build_command_line(const char **cmd, request_rec *r,
97a9a944b5887e91042b019776c41d5dd74557aferikabele const char *argv0;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* Allow suexec's "/" check to succeed */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive fileType = ap_get_win32_interpreter(r, &interpreter, &arguments);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
d9acf35ddaf5792bb76f8b0cc47b26cd51482abaslive "%s is not executable; ensure interpreted scripts have "
d9acf35ddaf5792bb76f8b0cc47b26cd51482abaslive "\"#!\" first line",
97a9a944b5887e91042b019776c41d5dd74557aferikabele * Build the command string to pass to ap_os_create_privileged_process()
06ba4a61654b3763ad65f52283832ebf058fdf1cslive quoted_filename = apr_pstrcat(p, "\"", r->filename, "\"", NULL);
97a9a944b5887e91042b019776c41d5dd74557aferikabele *cmd = apr_pstrcat(p, interpreter, " ", quoted_filename, " ",
97a9a944b5887e91042b019776c41d5dd74557aferikabele *cmd = apr_pstrcat(p, interpreter, " ", quoted_filename, " ", NULL);
d9acf35ddaf5792bb76f8b0cc47b26cd51482abaslive *cmd = apr_pstrcat(p, quoted_filename, " ", arguments, NULL);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char *argv0;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char *command;
06ba4a61654b3763ad65f52283832ebf058fdf1cslive const char **argv;
97a9a944b5887e91042b019776c41d5dd74557aferikabele apr_file_t *script_out = NULL, *script_in = NULL, *script_err = NULL;
97a9a944b5887e91042b019776c41d5dd74557aferikabele int is_included = !strcmp(r->protocol, "INCLUDED");
97a9a944b5887e91042b019776c41d5dd74557aferikabele if(strcmp(r->handler,CGI_MAGIC_TYPE) && strcmp(r->handler,"cgi-script"))
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* 99 out of 100 CGI scripts, this is all they support */
308abf52d418c00c19624cd4445d3b562b7eae81rbowen conf = ap_get_module_config(r->server->module_config, &cgi_module);
308abf52d418c00c19624cd4445d3b562b7eae81rbowen if (!(ap_allow_options(r) & OPT_EXECCGI) && !is_scriptaliased(r))
97a9a944b5887e91042b019776c41d5dd74557aferikabele return log_scripterror(r, conf, HTTP_FORBIDDEN, 0,
308abf52d418c00c19624cd4445d3b562b7eae81rbowen "Options ExecCGI is off in this directory");
97a9a944b5887e91042b019776c41d5dd74557aferikabele return log_scripterror(r, conf, HTTP_FORBIDDEN, 0,
97a9a944b5887e91042b019776c41d5dd74557aferikabele "attempt to include NPH CGI script");
97a9a944b5887e91042b019776c41d5dd74557aferikabele /* XXX: This is wrong. As an option, perhaps, but not by default...
117c1f888a14e73cdd821dc6c23eb0411144a41cnd * we are back to the same argument that a url should be a unique
97a9a944b5887e91042b019776c41d5dd74557aferikabele * entity until the sysadmin overrides that behavior.
97a9a944b5887e91042b019776c41d5dd74557aferikabele * Allow for cgi files without the .EXE extension on them under OS/2
06ba4a61654b3763ad65f52283832ebf058fdf1cslive newfile = apr_pstrcat(r->pool, r->filename, ".EXE", NULL);
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if (((rv = apr_stat(&finfo, newfile, APR_FINFO_TYPE, r->pool))
308abf52d418c00c19624cd4445d3b562b7eae81rbowen "script not found or unable to stat");
308abf52d418c00c19624cd4445d3b562b7eae81rbowen "script not found or unable to stat");
97a9a944b5887e91042b019776c41d5dd74557aferikabele return log_scripterror(r, conf, HTTP_FORBIDDEN, 0,
117c1f888a14e73cdd821dc6c23eb0411144a41cnd "attempt to invoke directory as script");
97a9a944b5887e91042b019776c41d5dd74557aferikabele if (!ap_suexec_enabled) {
97a9a944b5887e91042b019776c41d5dd74557aferikabele if (!ap_can_exec(&r->finfo))
97a9a944b5887e91042b019776c41d5dd74557aferikabele return log_scripterror(r, conf, HTTP_FORBIDDEN, 0,
97a9a944b5887e91042b019776c41d5dd74557aferikabele "file permissions deny server execution");
97a9a944b5887e91042b019776c41d5dd74557aferikabele if ((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
d9acf35ddaf5792bb76f8b0cc47b26cd51482abaslive /* build the command line */
d9acf35ddaf5792bb76f8b0cc47b26cd51482abaslive if ((rv = build_command_line(&command, r, p)) != APR_SUCCESS) {
97a9a944b5887e91042b019776c41d5dd74557aferikabele /* build the argument list */
97a9a944b5887e91042b019776c41d5dd74557aferikabele else if ((rv = build_argv_list(&argv, r, p)) != APR_SUCCESS) {
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* run the script in its own process */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive if ((rv = run_cgi_child(&script_out, &script_in, &script_err,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive /* Transfer any put/post args, CERN style...
06ba4a61654b3763ad65f52283832ebf058fdf1cslive * Note that we already ignore SIGPIPE in the core server.
while ((len_read =
bytes_written = 0;
const char *location;
int ret;
return OK;
return HTTP_MOVED_TEMPORARILY;
if (!r->header_only) {
b = apr_bucket_eos_create();
b = apr_bucket_eos_create();
int rr_status;
const char **argv;
apr_bucket *b;
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;