|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/*
|
|
Packit |
90a5c9 |
* http_script: keeps all script-related ramblings together.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Compliant to CGI/1.1 spec
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Adapted by rst from original NCSA code by Rob McCool
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* This modules uses a httpd core function (ap_add_common_vars) to add some new env vars,
|
|
Packit |
90a5c9 |
* like REDIRECT_URL and REDIRECT_QUERY_STRING for custom error responses and DOCUMENT_ROOT.
|
|
Packit |
90a5c9 |
* It also adds SERVER_ADMIN - useful for scripts to know who to mail when they fail.
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "apr.h"
|
|
Packit |
90a5c9 |
#include "apr_strings.h"
|
|
Packit |
90a5c9 |
#include "apr_thread_proc.h" /* for RLIMIT stuff */
|
|
Packit |
90a5c9 |
#include "apr_optional.h"
|
|
Packit |
90a5c9 |
#include "apr_buckets.h"
|
|
Packit |
90a5c9 |
#include "apr_lib.h"
|
|
Packit |
90a5c9 |
#include "apr_poll.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define APR_WANT_STRFUNC
|
|
Packit |
90a5c9 |
#define APR_WANT_MEMFUNC
|
|
Packit |
90a5c9 |
#include "apr_want.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "util_filter.h"
|
|
Packit |
90a5c9 |
#include "ap_config.h"
|
|
Packit |
90a5c9 |
#include "httpd.h"
|
|
Packit |
90a5c9 |
#include "http_config.h"
|
|
Packit |
90a5c9 |
#include "http_request.h"
|
|
Packit |
90a5c9 |
#include "http_core.h"
|
|
Packit |
90a5c9 |
#include "http_protocol.h"
|
|
Packit |
90a5c9 |
#include "http_main.h"
|
|
Packit |
90a5c9 |
#include "http_log.h"
|
|
Packit |
90a5c9 |
#include "util_script.h"
|
|
Packit |
90a5c9 |
#include "ap_mpm.h"
|
|
Packit |
90a5c9 |
#include "mod_core.h"
|
|
Packit |
90a5c9 |
#include "mod_cgi.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#if APR_HAVE_STRUCT_RLIMIT
|
|
Packit |
90a5c9 |
#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
|
|
Packit |
90a5c9 |
#define AP_CGI_USE_RLIMIT
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
module AP_MODULE_DECLARE_DATA cgi_module;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static APR_OPTIONAL_FN_TYPE(ap_register_include_handler) *cgi_pfn_reg_with_ssi;
|
|
Packit |
90a5c9 |
static APR_OPTIONAL_FN_TYPE(ap_ssi_get_tag_and_value) *cgi_pfn_gtv;
|
|
Packit |
90a5c9 |
static APR_OPTIONAL_FN_TYPE(ap_ssi_parse_string) *cgi_pfn_ps;
|
|
Packit |
90a5c9 |
static APR_OPTIONAL_FN_TYPE(ap_cgi_build_command) *cgi_build_command;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Read and discard the data in the brigade produced by a CGI script */
|
|
Packit |
90a5c9 |
static void discard_script_output(apr_bucket_brigade *bb);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
|
|
Packit |
90a5c9 |
* in ScriptAliased directories, which means we need to know if this
|
|
Packit |
90a5c9 |
* request came through ScriptAlias or not... so the Alias module
|
|
Packit |
90a5c9 |
* leaves a note for us.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static int is_scriptaliased(request_rec *r)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
const char *t = apr_table_get(r->notes, "alias-forced-type");
|
|
Packit |
90a5c9 |
return t && (!strcasecmp(t, "cgi-script"));
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Configuration stuff */
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define DEFAULT_LOGBYTES 10385760
|
|
Packit |
90a5c9 |
#define DEFAULT_BUFBYTES 1024
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct {
|
|
Packit |
90a5c9 |
const char *logname;
|
|
Packit |
90a5c9 |
long logbytes;
|
|
Packit |
90a5c9 |
apr_size_t bufbytes;
|
|
Packit |
90a5c9 |
} cgi_server_conf;
|
|
Packit |
90a5c9 |
|
|
Packit |
a7938f |
typedef struct {
|
|
Packit |
a7938f |
apr_interval_time_t timeout;
|
|
Packit |
a7938f |
} cgi_dirconf;
|
|
Packit |
a7938f |
|
|
Packit |
90a5c9 |
static void *create_cgi_config(apr_pool_t *p, server_rec *s)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
cgi_server_conf *c =
|
|
Packit |
90a5c9 |
(cgi_server_conf *) apr_pcalloc(p, sizeof(cgi_server_conf));
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
c->logname = NULL;
|
|
Packit |
90a5c9 |
c->logbytes = DEFAULT_LOGBYTES;
|
|
Packit |
90a5c9 |
c->bufbytes = DEFAULT_BUFBYTES;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return c;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void *merge_cgi_config(apr_pool_t *p, void *basev, void *overridesv)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
cgi_server_conf *base = (cgi_server_conf *) basev,
|
|
Packit |
90a5c9 |
*overrides = (cgi_server_conf *) overridesv;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return overrides->logname ? overrides : base;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
a7938f |
static void *create_cgi_dirconf(apr_pool_t *p, char *dummy)
|
|
Packit |
a7938f |
{
|
|
Packit |
a7938f |
cgi_dirconf *c = (cgi_dirconf *) apr_pcalloc(p, sizeof(cgi_dirconf));
|
|
Packit |
a7938f |
return c;
|
|
Packit |
a7938f |
}
|
|
Packit |
a7938f |
|
|
Packit |
90a5c9 |
static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
server_rec *s = cmd->server;
|
|
Packit |
90a5c9 |
cgi_server_conf *conf = ap_get_module_config(s->module_config,
|
|
Packit |
90a5c9 |
&cgi_module);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
conf->logname = ap_server_root_relative(cmd->pool, arg);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!conf->logname) {
|
|
Packit |
90a5c9 |
return apr_pstrcat(cmd->pool, "Invalid ScriptLog path ",
|
|
Packit |
90a5c9 |
arg, NULL);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy,
|
|
Packit |
90a5c9 |
const char *arg)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
server_rec *s = cmd->server;
|
|
Packit |
90a5c9 |
cgi_server_conf *conf = ap_get_module_config(s->module_config,
|
|
Packit |
90a5c9 |
&cgi_module);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
conf->logbytes = atol(arg);
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy,
|
|
Packit |
90a5c9 |
const char *arg)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
server_rec *s = cmd->server;
|
|
Packit |
90a5c9 |
cgi_server_conf *conf = ap_get_module_config(s->module_config,
|
|
Packit |
90a5c9 |
&cgi_module);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
conf->bufbytes = atoi(arg);
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
a7938f |
static const char *set_script_timeout(cmd_parms *cmd, void *dummy, const char *arg)
|
|
Packit |
a7938f |
{
|
|
Packit |
a7938f |
cgi_dirconf *dc = dummy;
|
|
Packit |
a7938f |
|
|
Packit |
a7938f |
if (ap_timeout_parameter_parse(arg, &dc->timeout, "s") != APR_SUCCESS) {
|
|
Packit |
a7938f |
return "CGIScriptTimeout has wrong format";
|
|
Packit |
a7938f |
}
|
|
Packit |
a7938f |
|
|
Packit |
a7938f |
return NULL;
|
|
Packit |
a7938f |
}
|
|
Packit |
a7938f |
|
|
Packit |
90a5c9 |
static const command_rec cgi_cmds[] =
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
AP_INIT_TAKE1("ScriptLog", set_scriptlog, NULL, RSRC_CONF,
|
|
Packit |
90a5c9 |
"the name of a log for script debugging info"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE1("ScriptLogLength", set_scriptlog_length, NULL, RSRC_CONF,
|
|
Packit |
90a5c9 |
"the maximum length (in bytes) of the script debug log"),
|
|
Packit |
90a5c9 |
AP_INIT_TAKE1("ScriptLogBuffer", set_scriptlog_buffer, NULL, RSRC_CONF,
|
|
Packit |
90a5c9 |
"the maximum size (in bytes) to record of a POST request"),
|
|
Packit |
a7938f |
AP_INIT_TAKE1("CGIScriptTimeout", set_script_timeout, NULL, RSRC_CONF | ACCESS_CONF,
|
|
Packit |
a7938f |
"The amount of time to wait between successful reads from "
|
|
Packit |
a7938f |
"the CGI script, in seconds."),
|
|
Packit |
90a5c9 |
{NULL}
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static int log_scripterror(request_rec *r, cgi_server_conf * conf, int ret,
|
|
Packit |
90a5c9 |
apr_status_t rv, char *logno, char *error)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
apr_file_t *f = NULL;
|
|
Packit |
90a5c9 |
apr_finfo_t finfo;
|
|
Packit |
90a5c9 |
char time_str[APR_CTIME_LEN];
|
|
Packit |
90a5c9 |
int log_flags = rv ? APLOG_ERR : APLOG_ERR;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Intentional no APLOGNO */
|
|
Packit |
90a5c9 |
/* Callee provides APLOGNO in error text */
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, log_flags, rv, r,
|
|
Packit |
90a5c9 |
"%s%s: %s", logno ? logno : "", error, r->filename);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* XXX Very expensive mainline case! Open, then getfileinfo! */
|
|
Packit |
90a5c9 |
if (!conf->logname ||
|
|
Packit |
90a5c9 |
((apr_stat(&finfo, conf->logname,
|
|
Packit |
90a5c9 |
APR_FINFO_SIZE, r->pool) == APR_SUCCESS) &&
|
|
Packit |
90a5c9 |
(finfo.size > conf->logbytes)) ||
|
|
Packit |
90a5c9 |
(apr_file_open(&f, conf->logname,
|
|
Packit |
90a5c9 |
APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT,
|
|
Packit |
90a5c9 |
r->pool) != APR_SUCCESS)) {
|
|
Packit |
90a5c9 |
return ret;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* "%% [Wed Jun 19 10:53:21 1996] GET /cgi-bin/printenv HTTP/1.0" */
|
|
Packit |
90a5c9 |
apr_ctime(time_str, apr_time_now());
|
|
Packit |
90a5c9 |
apr_file_printf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
|
|
Packit |
90a5c9 |
r->args ? "?" : "", r->args ? r->args : "", r->protocol);
|
|
Packit |
90a5c9 |
/* "%% 500 /usr/local/apache/cgi-bin */
|
|
Packit |
90a5c9 |
apr_file_printf(f, "%%%% %d %s\n", ret, r->filename);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_file_printf(f, "%%error\n%s\n", error);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_file_close(f);
|
|
Packit |
90a5c9 |
return ret;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Soak up stderr from a script and redirect it to the error log.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
static apr_status_t log_script_err(request_rec *r, apr_file_t *script_err)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
char argsbuffer[HUGE_STRING_LEN];
|
|
Packit |
90a5c9 |
char *newline;
|
|
Packit |
90a5c9 |
apr_status_t rv;
|
|
Packit |
90a5c9 |
cgi_server_conf *conf = ap_get_module_config(r->server->module_config, &cgi_module);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
while ((rv = apr_file_gets(argsbuffer, HUGE_STRING_LEN,
|
|
Packit |
90a5c9 |
script_err)) == APR_SUCCESS) {
|
|
Packit |
90a5c9 |
newline = strchr(argsbuffer, '\n');
|
|
Packit |
90a5c9 |
if (newline) {
|
|
Packit |
90a5c9 |
*newline = '\0';
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
log_scripterror(r, conf, r->status, 0, APLOGNO(01215), argsbuffer);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return rv;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
|
|
Packit |
90a5c9 |
char *dbuf, const char *sbuf, apr_bucket_brigade *bb,
|
|
Packit |
90a5c9 |
apr_file_t *script_err)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
const apr_array_header_t *hdrs_arr = apr_table_elts(r->headers_in);
|
|
Packit |
90a5c9 |
const apr_table_entry_t *hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
|
|
Packit |
90a5c9 |
char argsbuffer[HUGE_STRING_LEN];
|
|
Packit |
90a5c9 |
apr_file_t *f = NULL;
|
|
Packit |
90a5c9 |
apr_bucket *e;
|
|
Packit |
90a5c9 |
const char *buf;
|
|
Packit |
90a5c9 |
apr_size_t len;
|
|
Packit |
90a5c9 |
apr_status_t rv;
|
|
Packit |
90a5c9 |
int first;
|
|
Packit |
90a5c9 |
int i;
|
|
Packit |
90a5c9 |
apr_finfo_t finfo;
|
|
Packit |
90a5c9 |
char time_str[APR_CTIME_LEN];
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* XXX Very expensive mainline case! Open, then getfileinfo! */
|
|
Packit |
90a5c9 |
if (!conf->logname ||
|
|
Packit |
90a5c9 |
((apr_stat(&finfo, conf->logname,
|
|
Packit |
90a5c9 |
APR_FINFO_SIZE, r->pool) == APR_SUCCESS) &&
|
|
Packit |
90a5c9 |
(finfo.size > conf->logbytes)) ||
|
|
Packit |
90a5c9 |
(apr_file_open(&f, conf->logname,
|
|
Packit |
90a5c9 |
APR_APPEND|APR_WRITE|APR_CREATE, APR_OS_DEFAULT,
|
|
Packit |
90a5c9 |
r->pool) != APR_SUCCESS)) {
|
|
Packit |
90a5c9 |
/* Soak up script output */
|
|
Packit |
90a5c9 |
discard_script_output(bb);
|
|
Packit |
90a5c9 |
log_script_err(r, script_err);
|
|
Packit |
90a5c9 |
return ret;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* "%% [Wed Jun 19 10:53:21 1996] GET /cgi-bin/printenv HTTP/1.0" */
|
|
Packit |
90a5c9 |
apr_ctime(time_str, apr_time_now());
|
|
Packit |
90a5c9 |
apr_file_printf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
|
|
Packit |
90a5c9 |
r->args ? "?" : "", r->args ? r->args : "", r->protocol);
|
|
Packit |
90a5c9 |
/* "%% 500 /usr/local/apache/cgi-bin" */
|
|
Packit |
90a5c9 |
apr_file_printf(f, "%%%% %d %s\n", ret, r->filename);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_file_puts("%request\n", f);
|
|
Packit |
90a5c9 |
for (i = 0; i < hdrs_arr->nelts; ++i) {
|
|
Packit |
90a5c9 |
if (!hdrs[i].key)
|
|
Packit |
90a5c9 |
continue;
|
|
Packit |
90a5c9 |
apr_file_printf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if ((r->method_number == M_POST || r->method_number == M_PUT) &&
|
|
Packit |
90a5c9 |
*dbuf) {
|
|
Packit |
90a5c9 |
apr_file_printf(f, "\n%s\n", dbuf);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_file_puts("%response\n", f);
|
|
Packit |
90a5c9 |
hdrs_arr = apr_table_elts(r->err_headers_out);
|
|
Packit |
90a5c9 |
hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
for (i = 0; i < hdrs_arr->nelts; ++i) {
|
|
Packit |
90a5c9 |
if (!hdrs[i].key)
|
|
Packit |
90a5c9 |
continue;
|
|
Packit |
90a5c9 |
apr_file_printf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (sbuf && *sbuf)
|
|
Packit |
90a5c9 |
apr_file_printf(f, "%s\n", sbuf);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
first = 1;
|
|
Packit |
90a5c9 |
for (e = APR_BRIGADE_FIRST(bb);
|
|
Packit |
90a5c9 |
e != APR_BRIGADE_SENTINEL(bb);
|
|
Packit |
90a5c9 |
e = APR_BUCKET_NEXT(e))
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
if (APR_BUCKET_IS_EOS(e)) {
|
|
Packit |
90a5c9 |
break;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
rv = apr_bucket_read(e, &buf, &len, APR_BLOCK_READ);
|
|
Packit |
90a5c9 |
if (rv != APR_SUCCESS || (len == 0)) {
|
|
Packit |
90a5c9 |
break;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (first) {
|
|
Packit |
90a5c9 |
apr_file_puts("%stdout\n", f);
|
|
Packit |
90a5c9 |
first = 0;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
apr_file_write(f, buf, &len;;
|
|
Packit |
90a5c9 |
apr_file_puts("\n", f);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err) == APR_SUCCESS) {
|
|
Packit |
90a5c9 |
apr_file_puts("%stderr\n", f);
|
|
Packit |
90a5c9 |
apr_file_puts(argsbuffer, f);
|
|
Packit |
90a5c9 |
while (apr_file_gets(argsbuffer, HUGE_STRING_LEN,
|
|
Packit |
90a5c9 |
script_err) == APR_SUCCESS) {
|
|
Packit |
90a5c9 |
apr_file_puts(argsbuffer, f);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
apr_file_puts("\n", f);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_brigade_destroy(bb);
|
|
Packit |
90a5c9 |
apr_file_close(script_err);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_file_close(f);
|
|
Packit |
90a5c9 |
return ret;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* This is the special environment used for running the "exec cmd="
|
|
Packit |
90a5c9 |
* variety of SSI directives.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
static void add_ssi_vars(request_rec *r)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
apr_table_t *e = r->subprocess_env;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (r->path_info && r->path_info[0] != '\0') {
|
|
Packit |
90a5c9 |
request_rec *pa_req;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_table_setn(e, "PATH_INFO", ap_escape_shell_cmd(r->pool,
|
|
Packit |
90a5c9 |
r->path_info));
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info),
|
|
Packit |
90a5c9 |
r, NULL);
|
|
Packit |
90a5c9 |
if (pa_req->filename) {
|
|
Packit |
90a5c9 |
apr_table_setn(e, "PATH_TRANSLATED",
|
|
Packit |
90a5c9 |
apr_pstrcat(r->pool, pa_req->filename,
|
|
Packit |
90a5c9 |
pa_req->path_info, NULL));
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
ap_destroy_sub_req(pa_req);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (r->args) {
|
|
Packit |
90a5c9 |
char *arg_copy = apr_pstrdup(r->pool, r->args);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_table_setn(e, "QUERY_STRING", r->args);
|
|
Packit |
90a5c9 |
ap_unescape_url(arg_copy);
|
|
Packit |
90a5c9 |
apr_table_setn(e, "QUERY_STRING_UNESCAPED",
|
|
Packit |
90a5c9 |
ap_escape_shell_cmd(r->pool, arg_copy));
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void cgi_child_errfn(apr_pool_t *pool, apr_status_t err,
|
|
Packit |
90a5c9 |
const char *description)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
apr_file_t *stderr_log;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_file_open_stderr(&stderr_log, pool);
|
|
Packit |
90a5c9 |
/* Escape the logged string because it may be something that
|
|
Packit |
90a5c9 |
* came in over the network.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
apr_file_printf(stderr_log,
|
|
Packit |
90a5c9 |
"(%d)%pm: %s\n",
|
|
Packit |
90a5c9 |
err,
|
|
Packit |
90a5c9 |
&err,
|
|
Packit |
90a5c9 |
#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED
|
|
Packit |
90a5c9 |
ap_escape_logitem(pool,
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
description
|
|
Packit |
90a5c9 |
#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED
|
|
Packit |
90a5c9 |
)
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t run_cgi_child(apr_file_t **script_out,
|
|
Packit |
90a5c9 |
apr_file_t **script_in,
|
|
Packit |
90a5c9 |
apr_file_t **script_err,
|
|
Packit |
90a5c9 |
const char *command,
|
|
Packit |
90a5c9 |
const char * const argv[],
|
|
Packit |
90a5c9 |
request_rec *r,
|
|
Packit |
90a5c9 |
apr_pool_t *p,
|
|
Packit |
90a5c9 |
cgi_exec_info_t *e_info)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
const char * const *env;
|
|
Packit |
90a5c9 |
apr_procattr_t *procattr;
|
|
Packit |
90a5c9 |
apr_proc_t *procnew;
|
|
Packit |
90a5c9 |
apr_status_t rc = APR_SUCCESS;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifdef AP_CGI_USE_RLIMIT
|
|
Packit |
90a5c9 |
core_dir_config *conf = ap_get_core_module_config(r->per_dir_config);
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifdef DEBUG_CGI
|
|
Packit |
90a5c9 |
#ifdef OS2
|
|
Packit |
90a5c9 |
/* Under OS/2 need to use device con. */
|
|
Packit |
90a5c9 |
FILE *dbg = fopen("con", "w");
|
|
Packit |
90a5c9 |
#else
|
|
Packit |
90a5c9 |
FILE *dbg = fopen("/dev/tty", "w");
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
int i;
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
RAISE_SIGSTOP(CGI_CHILD);
|
|
Packit |
90a5c9 |
#ifdef DEBUG_CGI
|
|
Packit |
90a5c9 |
fprintf(dbg, "Attempting to exec %s as CGI child (argv0 = %s)\n",
|
|
Packit |
90a5c9 |
r->filename, argv[0]);
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
env = (const char * const *)ap_create_environment(p, r->subprocess_env);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#ifdef DEBUG_CGI
|
|
Packit |
90a5c9 |
fprintf(dbg, "Environment: \n");
|
|
Packit |
90a5c9 |
for (i = 0; env[i]; ++i)
|
|
Packit |
90a5c9 |
fprintf(dbg, "'%s'\n", env[i]);
|
|
Packit |
90a5c9 |
fclose(dbg);
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Transmute ourselves into the script.
|
|
Packit |
90a5c9 |
* NB only ISINDEX scripts get decoded arguments.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (((rc = apr_procattr_create(&procattr, p)) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
((rc = apr_procattr_io_set(procattr,
|
|
Packit |
90a5c9 |
e_info->in_pipe,
|
|
Packit |
90a5c9 |
e_info->out_pipe,
|
|
Packit |
90a5c9 |
e_info->err_pipe)) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
((rc = apr_procattr_dir_set(procattr,
|
|
Packit |
90a5c9 |
ap_make_dirstr_parent(r->pool,
|
|
Packit |
90a5c9 |
r->filename))) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
#if defined(RLIMIT_CPU) && defined(AP_CGI_USE_RLIMIT)
|
|
Packit |
90a5c9 |
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_CPU,
|
|
Packit |
90a5c9 |
conf->limit_cpu)) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
#if defined(AP_CGI_USE_RLIMIT) && (defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS))
|
|
Packit |
90a5c9 |
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_MEM,
|
|
Packit |
90a5c9 |
conf->limit_mem)) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
#if defined(RLIMIT_NPROC) && defined(AP_CGI_USE_RLIMIT)
|
|
Packit |
90a5c9 |
((rc = apr_procattr_limit_set(procattr, APR_LIMIT_NPROC,
|
|
Packit |
90a5c9 |
conf->limit_nproc)) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
((rc = apr_procattr_cmdtype_set(procattr,
|
|
Packit |
90a5c9 |
e_info->cmd_type)) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
((rc = apr_procattr_detach_set(procattr,
|
|
Packit |
90a5c9 |
e_info->detached)) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
((rc = apr_procattr_addrspace_set(procattr,
|
|
Packit |
90a5c9 |
e_info->addrspace)) != APR_SUCCESS) ||
|
|
Packit |
90a5c9 |
((rc = apr_procattr_child_errfn_set(procattr, cgi_child_errfn)) != APR_SUCCESS)) {
|
|
Packit |
90a5c9 |
/* Something bad happened, tell the world. */
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, APLOGNO(01216)
|
|
Packit |
90a5c9 |
"couldn't set child process attributes: %s", r->filename);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
procnew = apr_pcalloc(p, sizeof(*procnew));
|
|
Packit |
90a5c9 |
rc = ap_os_create_privileged_process(r, procnew, command, argv, env,
|
|
Packit |
90a5c9 |
procattr, p);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (rc != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
/* Bad things happened. Everyone should have cleaned up. */
|
|
Packit |
90a5c9 |
/* Intentional no APLOGNO */
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_TOCLIENT, rc, r,
|
|
Packit |
90a5c9 |
"couldn't create child process: %d: %s", rc,
|
|
Packit |
90a5c9 |
apr_filepath_name_get(r->filename));
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
a7938f |
cgi_dirconf *dc = ap_get_module_config(r->per_dir_config, &cgi_module);
|
|
Packit |
a7938f |
apr_interval_time_t timeout = dc->timeout > 0 ? dc->timeout : r->server->timeout;
|
|
Packit |
a7938f |
|
|
Packit |
90a5c9 |
apr_pool_note_subprocess(p, procnew, APR_KILL_AFTER_TIMEOUT);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
*script_in = procnew->out;
|
|
Packit |
90a5c9 |
if (!*script_in)
|
|
Packit |
90a5c9 |
return APR_EBADF;
|
|
Packit |
a7938f |
apr_file_pipe_timeout_set(*script_in, timeout);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (e_info->prog_type == RUN_AS_CGI) {
|
|
Packit |
90a5c9 |
*script_out = procnew->in;
|
|
Packit |
90a5c9 |
if (!*script_out)
|
|
Packit |
90a5c9 |
return APR_EBADF;
|
|
Packit |
a7938f |
apr_file_pipe_timeout_set(*script_out, timeout);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
*script_err = procnew->err;
|
|
Packit |
90a5c9 |
if (!*script_err)
|
|
Packit |
90a5c9 |
return APR_EBADF;
|
|
Packit |
a7938f |
apr_file_pipe_timeout_set(*script_err, timeout);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return (rc);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t default_build_command(const char **cmd, const char ***argv,
|
|
Packit |
90a5c9 |
request_rec *r, apr_pool_t *p,
|
|
Packit |
90a5c9 |
cgi_exec_info_t *e_info)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
int numwords, x, idx;
|
|
Packit |
90a5c9 |
char *w;
|
|
Packit |
90a5c9 |
const char *args = NULL;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (e_info->process_cgi) {
|
|
Packit |
90a5c9 |
*cmd = r->filename;
|
|
Packit |
90a5c9 |
/* Do not process r->args if they contain an '=' assignment
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (r->args && r->args[0] && !ap_strchr_c(r->args, '=')) {
|
|
Packit |
90a5c9 |
args = r->args;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!args) {
|
|
Packit |
90a5c9 |
numwords = 1;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
/* count the number of keywords */
|
|
Packit |
90a5c9 |
for (x = 0, numwords = 2; args[x]; x++) {
|
|
Packit |
90a5c9 |
if (args[x] == '+') {
|
|
Packit |
90a5c9 |
++numwords;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
/* Everything is - 1 to account for the first parameter
|
|
Packit |
90a5c9 |
* which is the program name.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
if (numwords > APACHE_ARG_MAX - 1) {
|
|
Packit |
90a5c9 |
numwords = APACHE_ARG_MAX - 1; /* Truncate args to prevent overrun */
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
*argv = apr_palloc(p, (numwords + 2) * sizeof(char *));
|
|
Packit |
90a5c9 |
(*argv)[0] = *cmd;
|
|
Packit |
90a5c9 |
for (x = 1, idx = 1; x < numwords; x++) {
|
|
Packit |
90a5c9 |
w = ap_getword_nulls(p, &args, '+');
|
|
Packit |
90a5c9 |
ap_unescape_url(w);
|
|
Packit |
90a5c9 |
(*argv)[idx++] = ap_escape_shell_cmd(p, w);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
(*argv)[idx] = NULL;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#if APR_FILES_AS_SOCKETS
|
|
Packit |
a7938f |
#define WANT_CGI_BUCKET
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
a7938f |
#include "cgi_common.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static int cgi_handler(request_rec *r)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
int nph;
|
|
Packit |
90a5c9 |
apr_size_t dbpos = 0;
|
|
Packit |
90a5c9 |
const char *argv0;
|
|
Packit |
90a5c9 |
const char *command;
|
|
Packit |
90a5c9 |
const char **argv;
|
|
Packit |
90a5c9 |
char *dbuf = NULL;
|
|
Packit |
90a5c9 |
apr_file_t *script_out = NULL, *script_in = NULL, *script_err = NULL;
|
|
Packit |
90a5c9 |
apr_bucket_brigade *bb;
|
|
Packit |
90a5c9 |
apr_bucket *b;
|
|
Packit |
90a5c9 |
int is_included;
|
|
Packit |
90a5c9 |
int seen_eos, child_stopped_reading;
|
|
Packit |
90a5c9 |
apr_pool_t *p;
|
|
Packit |
90a5c9 |
cgi_server_conf *conf;
|
|
Packit |
90a5c9 |
apr_status_t rv;
|
|
Packit |
90a5c9 |
cgi_exec_info_t e_info;
|
|
Packit |
90a5c9 |
conn_rec *c;
|
|
Packit |
a7938f |
cgi_dirconf *dc = ap_get_module_config(r->per_dir_config, &cgi_module);
|
|
Packit |
a7938f |
apr_interval_time_t timeout = dc->timeout > 0 ? dc->timeout : r->server->timeout;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) {
|
|
Packit |
90a5c9 |
return DECLINED;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
c = r->connection;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
is_included = !strcmp(r->protocol, "INCLUDED");
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
p = r->main ? r->main->pool : r->pool;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
argv0 = apr_filepath_name_get(r->filename);
|
|
Packit |
90a5c9 |
nph = !(strncmp(argv0, "nph-", 4));
|
|
Packit |
90a5c9 |
conf = ap_get_module_config(r->server->module_config, &cgi_module);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!(ap_allow_options(r) & OPT_EXECCGI) && !is_scriptaliased(r))
|
|
Packit |
90a5c9 |
return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(02809),
|
|
Packit |
90a5c9 |
"Options ExecCGI is off in this directory");
|
|
Packit |
90a5c9 |
if (nph && is_included)
|
|
Packit |
90a5c9 |
return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(02810),
|
|
Packit |
90a5c9 |
"attempt to include NPH CGI script");
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (r->finfo.filetype == APR_NOFILE)
|
|
Packit |
90a5c9 |
return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, APLOGNO(02811),
|
|
Packit |
90a5c9 |
"script not found or unable to stat");
|
|
Packit |
90a5c9 |
if (r->finfo.filetype == APR_DIR)
|
|
Packit |
90a5c9 |
return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(02812),
|
|
Packit |
90a5c9 |
"attempt to invoke directory as script");
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ((r->used_path_info == AP_REQ_REJECT_PATH_INFO) &&
|
|
Packit |
90a5c9 |
r->path_info && *r->path_info)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
/* default to accept */
|
|
Packit |
90a5c9 |
return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, APLOGNO(02813),
|
|
Packit |
90a5c9 |
"AcceptPathInfo off disallows user's path");
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
/*
|
|
Packit |
90a5c9 |
if (!ap_suexec_enabled) {
|
|
Packit |
90a5c9 |
if (!ap_can_exec(&r->finfo))
|
|
Packit |
90a5c9 |
return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(03194)
|
|
Packit |
90a5c9 |
"file permissions deny server execution");
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
ap_add_common_vars(r);
|
|
Packit |
90a5c9 |
ap_add_cgi_vars(r);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
e_info.process_cgi = 1;
|
|
Packit |
90a5c9 |
e_info.cmd_type = APR_PROGRAM;
|
|
Packit |
90a5c9 |
e_info.detached = 0;
|
|
Packit |
90a5c9 |
e_info.in_pipe = APR_CHILD_BLOCK;
|
|
Packit |
90a5c9 |
e_info.out_pipe = APR_CHILD_BLOCK;
|
|
Packit |
90a5c9 |
e_info.err_pipe = APR_CHILD_BLOCK;
|
|
Packit |
90a5c9 |
e_info.prog_type = RUN_AS_CGI;
|
|
Packit |
90a5c9 |
e_info.bb = NULL;
|
|
Packit |
90a5c9 |
e_info.ctx = NULL;
|
|
Packit |
90a5c9 |
e_info.next = NULL;
|
|
Packit |
90a5c9 |
e_info.addrspace = 0;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* build the command line */
|
|
Packit |
90a5c9 |
if ((rv = cgi_build_command(&command, &argv, r, p, &e_info)) != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01222)
|
|
Packit |
90a5c9 |
"don't know how to spawn child process: %s",
|
|
Packit |
90a5c9 |
r->filename);
|
|
Packit |
90a5c9 |
return HTTP_INTERNAL_SERVER_ERROR;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* run the script in its own process */
|
|
Packit |
90a5c9 |
if ((rv = run_cgi_child(&script_out, &script_in, &script_err,
|
|
Packit |
90a5c9 |
command, argv, r, p, &e_info)) != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01223)
|
|
Packit |
90a5c9 |
"couldn't spawn child process: %s", r->filename);
|
|
Packit |
90a5c9 |
return HTTP_INTERNAL_SERVER_ERROR;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Transfer any put/post args, CERN style...
|
|
Packit |
90a5c9 |
* Note that we already ignore SIGPIPE in the core server.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
bb = apr_brigade_create(r->pool, c->bucket_alloc);
|
|
Packit |
90a5c9 |
seen_eos = 0;
|
|
Packit |
90a5c9 |
child_stopped_reading = 0;
|
|
Packit |
90a5c9 |
if (conf->logname) {
|
|
Packit |
90a5c9 |
dbuf = apr_palloc(r->pool, conf->bufbytes + 1);
|
|
Packit |
90a5c9 |
dbpos = 0;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
do {
|
|
Packit |
90a5c9 |
apr_bucket *bucket;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rv = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
|
|
Packit |
90a5c9 |
APR_BLOCK_READ, HUGE_STRING_LEN);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (rv != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01225)
|
|
Packit |
90a5c9 |
"Error reading request entity data");
|
|
Packit |
90a5c9 |
return ap_map_http_request_error(rv, HTTP_BAD_REQUEST);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
for (bucket = APR_BRIGADE_FIRST(bb);
|
|
Packit |
90a5c9 |
bucket != APR_BRIGADE_SENTINEL(bb);
|
|
Packit |
90a5c9 |
bucket = APR_BUCKET_NEXT(bucket))
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
const char *data;
|
|
Packit |
90a5c9 |
apr_size_t len;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (APR_BUCKET_IS_EOS(bucket)) {
|
|
Packit |
90a5c9 |
seen_eos = 1;
|
|
Packit |
90a5c9 |
break;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* We can't do much with this. */
|
|
Packit |
90a5c9 |
if (APR_BUCKET_IS_FLUSH(bucket)) {
|
|
Packit |
90a5c9 |
continue;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* If the child stopped, we still must read to EOS. */
|
|
Packit |
90a5c9 |
if (child_stopped_reading) {
|
|
Packit |
90a5c9 |
continue;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* read */
|
|
Packit |
90a5c9 |
apr_bucket_read(bucket, &data, &len, APR_BLOCK_READ);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (conf->logname && dbpos < conf->bufbytes) {
|
|
Packit |
90a5c9 |
int cursize;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ((dbpos + len) > conf->bufbytes) {
|
|
Packit |
90a5c9 |
cursize = conf->bufbytes - dbpos;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
cursize = len;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
memcpy(dbuf + dbpos, data, cursize);
|
|
Packit |
90a5c9 |
dbpos += cursize;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Keep writing data to the child until done or too much time
|
|
Packit |
90a5c9 |
* elapses with no progress or an error occurs.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
rv = apr_file_write_full(script_out, data, len, NULL);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (rv != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
/* silly script stopped reading, soak up remaining message */
|
|
Packit |
90a5c9 |
child_stopped_reading = 1;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
apr_brigade_cleanup(bb);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
while (!seen_eos);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (conf->logname) {
|
|
Packit |
90a5c9 |
dbuf[dbpos] = '\0';
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
/* Is this flush really needed? */
|
|
Packit |
90a5c9 |
apr_file_flush(script_out);
|
|
Packit |
90a5c9 |
apr_file_close(script_out);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
AP_DEBUG_ASSERT(script_in != NULL);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#if APR_FILES_AS_SOCKETS
|
|
Packit |
a7938f |
b = cgi_bucket_create(r, dc->timeout, script_in, script_err, c->bucket_alloc);
|
|
Packit |
90a5c9 |
if (b == NULL)
|
|
Packit |
90a5c9 |
return HTTP_INTERNAL_SERVER_ERROR;
|
|
Packit |
90a5c9 |
#else
|
|
Packit |
90a5c9 |
b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
|
|
Packit |
90a5c9 |
#endif
|
|
Packit |
90a5c9 |
APR_BRIGADE_INSERT_TAIL(bb, b);
|
|
Packit |
90a5c9 |
b = apr_bucket_eos_create(c->bucket_alloc);
|
|
Packit |
90a5c9 |
APR_BRIGADE_INSERT_TAIL(bb, b);
|
|
Packit |
90a5c9 |
|
|
Packit |
a7938f |
return cgi_handle_response(r, nph, bb, timeout, conf, dbuf, script_err);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/*============================================================================
|
|
Packit |
90a5c9 |
*============================================================================
|
|
Packit |
90a5c9 |
* This is the beginning of the cgi filter code moved from mod_include. This
|
|
Packit |
90a5c9 |
* is the code required to handle the "exec" SSI directive.
|
|
Packit |
90a5c9 |
*============================================================================
|
|
Packit |
90a5c9 |
*============================================================================*/
|
|
Packit |
90a5c9 |
static apr_status_t include_cgi(include_ctx_t *ctx, ap_filter_t *f,
|
|
Packit |
90a5c9 |
apr_bucket_brigade *bb, char *s)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
request_rec *r = f->r;
|
|
Packit |
90a5c9 |
request_rec *rr = ap_sub_req_lookup_uri(s, r, f->next);
|
|
Packit |
90a5c9 |
int rr_status;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (rr->status != HTTP_OK) {
|
|
Packit |
90a5c9 |
ap_destroy_sub_req(rr);
|
|
Packit |
90a5c9 |
return APR_EGENERAL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* No hardwired path info or query allowed */
|
|
Packit |
90a5c9 |
if ((rr->path_info && rr->path_info[0]) || rr->args) {
|
|
Packit |
90a5c9 |
ap_destroy_sub_req(rr);
|
|
Packit |
90a5c9 |
return APR_EGENERAL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (rr->finfo.filetype != APR_REG) {
|
|
Packit |
90a5c9 |
ap_destroy_sub_req(rr);
|
|
Packit |
90a5c9 |
return APR_EGENERAL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Script gets parameters of the *document*, for back compatibility */
|
|
Packit |
90a5c9 |
rr->path_info = r->path_info; /* hard to get right; see mod_cgi.c */
|
|
Packit |
90a5c9 |
rr->args = r->args;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Force sub_req to be treated as a CGI request, even if ordinary
|
|
Packit |
90a5c9 |
* typing rules would have called it something else.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
ap_set_content_type(rr, CGI_MAGIC_TYPE);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* Run it. */
|
|
Packit |
90a5c9 |
rr_status = ap_run_sub_req(rr);
|
|
Packit |
90a5c9 |
if (ap_is_HTTP_REDIRECT(rr_status)) {
|
|
Packit |
90a5c9 |
const char *location = apr_table_get(rr->headers_out, "Location");
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (location) {
|
|
Packit |
90a5c9 |
char *buffer;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
location = ap_escape_html(rr->pool, location);
|
|
Packit |
90a5c9 |
buffer = apr_pstrcat(ctx->pool, "",
|
|
Packit |
90a5c9 |
location, "", NULL);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(buffer,
|
|
Packit |
90a5c9 |
strlen(buffer), ctx->pool,
|
|
Packit |
90a5c9 |
f->c->bucket_alloc));
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ap_destroy_sub_req(rr);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t include_cmd(include_ctx_t *ctx, ap_filter_t *f,
|
|
Packit |
90a5c9 |
apr_bucket_brigade *bb, const char *command)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
cgi_exec_info_t e_info;
|
|
Packit |
90a5c9 |
const char **argv;
|
|
Packit |
90a5c9 |
apr_file_t *script_out = NULL, *script_in = NULL, *script_err = NULL;
|
|
Packit |
90a5c9 |
apr_status_t rv;
|
|
Packit |
90a5c9 |
request_rec *r = f->r;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
add_ssi_vars(r);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
e_info.process_cgi = 0;
|
|
Packit |
90a5c9 |
e_info.cmd_type = APR_SHELLCMD;
|
|
Packit |
90a5c9 |
e_info.detached = 0;
|
|
Packit |
90a5c9 |
e_info.in_pipe = APR_NO_PIPE;
|
|
Packit |
90a5c9 |
e_info.out_pipe = APR_FULL_BLOCK;
|
|
Packit |
90a5c9 |
e_info.err_pipe = APR_NO_PIPE;
|
|
Packit |
90a5c9 |
e_info.prog_type = RUN_AS_SSI;
|
|
Packit |
90a5c9 |
e_info.bb = &bb;
|
|
Packit |
90a5c9 |
e_info.ctx = ctx;
|
|
Packit |
90a5c9 |
e_info.next = f->next;
|
|
Packit |
90a5c9 |
e_info.addrspace = 0;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ((rv = cgi_build_command(&command, &argv, r, r->pool,
|
|
Packit |
90a5c9 |
&e_info)) != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01226)
|
|
Packit |
90a5c9 |
"don't know how to spawn cmd child process: %s",
|
|
Packit |
90a5c9 |
r->filename);
|
|
Packit |
90a5c9 |
return rv;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* run the script in its own process */
|
|
Packit |
90a5c9 |
if ((rv = run_cgi_child(&script_out, &script_in, &script_err,
|
|
Packit |
90a5c9 |
command, argv, r, r->pool,
|
|
Packit |
90a5c9 |
&e_info)) != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01227)
|
|
Packit |
90a5c9 |
"couldn't spawn child process: %s", r->filename);
|
|
Packit |
90a5c9 |
return rv;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pipe_create(script_in,
|
|
Packit |
90a5c9 |
f->c->bucket_alloc));
|
|
Packit |
90a5c9 |
ctx->flush_now = 1;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* We can't close the pipe here, because we may return before the
|
|
Packit |
90a5c9 |
* full CGI has been sent to the network. That's okay though,
|
|
Packit |
90a5c9 |
* because we can rely on the pool to close the pipe for us.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t handle_exec(include_ctx_t *ctx, ap_filter_t *f,
|
|
Packit |
90a5c9 |
apr_bucket_brigade *bb)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
char *tag = NULL;
|
|
Packit |
90a5c9 |
char *tag_val = NULL;
|
|
Packit |
90a5c9 |
request_rec *r = f->r;
|
|
Packit |
90a5c9 |
char *file = r->filename;
|
|
Packit |
90a5c9 |
char parsed_string[MAX_STRING_LEN];
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!ctx->argc) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK,
|
|
Packit |
90a5c9 |
(ctx->flags & SSI_FLAG_PRINTING)
|
|
Packit |
90a5c9 |
? APLOG_ERR : APLOG_WARNING,
|
|
Packit |
90a5c9 |
0, r, APLOGNO(03195)
|
|
Packit |
90a5c9 |
"missing argument for exec element in %s", r->filename);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!(ctx->flags & SSI_FLAG_PRINTING)) {
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!ctx->argc) {
|
|
Packit |
90a5c9 |
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (ctx->flags & SSI_FLAG_NO_EXEC) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01228) "exec used but not allowed "
|
|
Packit |
90a5c9 |
"in %s", r->filename);
|
|
Packit |
90a5c9 |
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
while (1) {
|
|
Packit |
90a5c9 |
cgi_pfn_gtv(ctx, &tag, &tag_val, SSI_VALUE_DECODED);
|
|
Packit |
90a5c9 |
if (!tag || !tag_val) {
|
|
Packit |
90a5c9 |
break;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!strcmp(tag, "cmd")) {
|
|
Packit |
90a5c9 |
apr_status_t rv;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
cgi_pfn_ps(ctx, tag_val, parsed_string, sizeof(parsed_string),
|
|
Packit |
90a5c9 |
SSI_EXPAND_LEAVE_NAME);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rv = include_cmd(ctx, f, bb, parsed_string);
|
|
Packit |
90a5c9 |
if (rv != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01229) "execution failure "
|
|
Packit |
90a5c9 |
"for parameter \"%s\" to tag exec in file %s",
|
|
Packit |
90a5c9 |
tag, r->filename);
|
|
Packit |
90a5c9 |
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
|
|
Packit |
90a5c9 |
break;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else if (!strcmp(tag, "cgi")) {
|
|
Packit |
90a5c9 |
apr_status_t rv;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
cgi_pfn_ps(ctx, tag_val, parsed_string, sizeof(parsed_string),
|
|
Packit |
90a5c9 |
SSI_EXPAND_DROP_NAME);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
rv = include_cgi(ctx, f, bb, parsed_string);
|
|
Packit |
90a5c9 |
if (rv != APR_SUCCESS) {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01230) "invalid CGI ref "
|
|
Packit |
90a5c9 |
"\"%s\" in %s", tag_val, file);
|
|
Packit |
90a5c9 |
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
|
|
Packit |
90a5c9 |
break;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01231) "unknown parameter "
|
|
Packit |
90a5c9 |
"\"%s\" to tag exec in %s", tag, file);
|
|
Packit |
90a5c9 |
SSI_CREATE_ERROR_BUCKET(ctx, f, bb);
|
|
Packit |
90a5c9 |
break;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/*============================================================================
|
|
Packit |
90a5c9 |
*============================================================================
|
|
Packit |
90a5c9 |
* This is the end of the cgi filter code moved from mod_include.
|
|
Packit |
90a5c9 |
*============================================================================
|
|
Packit |
90a5c9 |
*============================================================================*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static int cgi_post_config(apr_pool_t *p, apr_pool_t *plog,
|
|
Packit |
90a5c9 |
apr_pool_t *ptemp, server_rec *s)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
cgi_pfn_reg_with_ssi = APR_RETRIEVE_OPTIONAL_FN(ap_register_include_handler);
|
|
Packit |
90a5c9 |
cgi_pfn_gtv = APR_RETRIEVE_OPTIONAL_FN(ap_ssi_get_tag_and_value);
|
|
Packit |
90a5c9 |
cgi_pfn_ps = APR_RETRIEVE_OPTIONAL_FN(ap_ssi_parse_string);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ((cgi_pfn_reg_with_ssi) && (cgi_pfn_gtv) && (cgi_pfn_ps)) {
|
|
Packit |
90a5c9 |
/* Required by mod_include filter. This is how mod_cgi registers
|
|
Packit |
90a5c9 |
* with mod_include to provide processing of the exec directive.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
cgi_pfn_reg_with_ssi("exec", handle_exec);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* This is the means by which unusual (non-unix) os's may find alternate
|
|
Packit |
90a5c9 |
* means to run a given command (e.g. shebang/registry parsing on Win32)
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
cgi_build_command = APR_RETRIEVE_OPTIONAL_FN(ap_cgi_build_command);
|
|
Packit |
90a5c9 |
if (!cgi_build_command) {
|
|
Packit |
90a5c9 |
cgi_build_command = default_build_command;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return OK;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void register_hooks(apr_pool_t *p)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
static const char * const aszPre[] = { "mod_include.c", NULL };
|
|
Packit |
90a5c9 |
ap_hook_handler(cgi_handler, NULL, NULL, APR_HOOK_MIDDLE);
|
|
Packit |
90a5c9 |
ap_hook_post_config(cgi_post_config, aszPre, NULL, APR_HOOK_REALLY_FIRST);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
AP_DECLARE_MODULE(cgi) =
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
STANDARD20_MODULE_STUFF,
|
|
Packit |
a7938f |
create_cgi_dirconf, /* dir config creater */
|
|
Packit |
90a5c9 |
NULL, /* dir merger --- default is to override */
|
|
Packit |
90a5c9 |
create_cgi_config, /* server config */
|
|
Packit |
90a5c9 |
merge_cgi_config, /* merge server config */
|
|
Packit |
90a5c9 |
cgi_cmds, /* command apr_table_t */
|
|
Packit |
90a5c9 |
register_hooks /* register hooks */
|
|
Packit |
90a5c9 |
};
|