Apache HTTPD
mod_cgi.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * http_script: keeps all script-related ramblings together.
19 *
20 * Compliant to CGI/1.1 spec
21 *
22 * Adapted by rst from original NCSA code by Rob McCool
23 *
24 * This modules uses a httpd core function (ap_add_common_vars) to add some new env vars,
25 * like REDIRECT_URL and REDIRECT_QUERY_STRING for custom error responses and DOCUMENT_ROOT.
26 * It also adds SERVER_ADMIN - useful for scripts to know who to mail when they fail.
27 *
28 */
29
30#include "apr.h"
31#include "apr_strings.h"
32#include "apr_thread_proc.h" /* for RLIMIT stuff */
33#include "apr_optional.h"
34#include "apr_buckets.h"
35#include "apr_lib.h"
36#include "apr_poll.h"
37
38#define APR_WANT_STRFUNC
39#define APR_WANT_MEMFUNC
40#include "apr_want.h"
41
42#include "util_filter.h"
43#include "ap_config.h"
44#include "httpd.h"
45#include "http_config.h"
46#include "http_request.h"
47#include "http_core.h"
48#include "http_protocol.h"
49#include "http_main.h"
50#include "http_log.h"
51#include "ap_mpm.h"
52#include "mod_core.h"
53#include "mod_cgi.h"
54
55#if APR_HAVE_STRUCT_RLIMIT
56#if defined (RLIMIT_CPU) || defined (RLIMIT_NPROC) || defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
57#define AP_CGI_USE_RLIMIT
58#endif
59#endif
60
61module AP_MODULE_DECLARE_DATA cgi_module;
62
64
65/* Read and discard the data in the brigade produced by a CGI script */
67
68/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
69 * in ScriptAliased directories, which means we need to know if this
70 * request came through ScriptAlias or not... so the Alias module
71 * leaves a note for us.
72 */
73
75{
76 const char *t = apr_table_get(r->notes, "alias-forced-type");
77 return t && (!strcasecmp(t, "cgi-script"));
78}
79
80/* Configuration stuff */
81
82#define DEFAULT_LOGBYTES 10385760
83#define DEFAULT_BUFBYTES 1024
84
85typedef struct {
86 const char *logname;
90
94
95#if APR_FILES_AS_SOCKETS
96#define WANT_CGI_BUCKET
97#endif
98#include "cgi_common.h"
99
101{
104
105 c->logname = NULL;
106 c->logbytes = DEFAULT_LOGBYTES;
107 c->bufbytes = DEFAULT_BUFBYTES;
108
109 return c;
110}
111
112static void *merge_cgi_config(apr_pool_t *p, void *basev, void *overridesv)
113{
116
117 return overrides->logname ? overrides : base;
118}
119
121{
123 return c;
124}
125
126static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
127{
128 server_rec *s = cmd->server;
129 cgi_server_conf *conf = ap_get_module_config(s->module_config,
130 &cgi_module);
131
132 conf->logname = ap_server_root_relative(cmd->pool, arg);
133
134 if (!conf->logname) {
135 return apr_pstrcat(cmd->pool, "Invalid ScriptLog path ",
136 arg, NULL);
137 }
138
139 return NULL;
140}
141
142static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy,
143 const char *arg)
144{
145 server_rec *s = cmd->server;
146 cgi_server_conf *conf = ap_get_module_config(s->module_config,
147 &cgi_module);
148
149 conf->logbytes = atol(arg);
150 return NULL;
151}
152
153static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy,
154 const char *arg)
155{
156 server_rec *s = cmd->server;
157 cgi_server_conf *conf = ap_get_module_config(s->module_config,
158 &cgi_module);
159
160 conf->bufbytes = atoi(arg);
161 return NULL;
162}
163
164static const char *set_script_timeout(cmd_parms *cmd, void *dummy, const char *arg)
165{
166 cgi_dirconf *dc = dummy;
167
169 return "CGIScriptTimeout has wrong format";
170 }
171
172 return NULL;
173}
174
175static const command_rec cgi_cmds[] =
176{
178 "the name of a log for script debugging info"),
180 "the maximum length (in bytes) of the script debug log"),
182 "the maximum size (in bytes) to record of a POST request"),
184 "The amount of time to wait between successful reads from "
185 "the CGI script, in seconds."),
186 {NULL}
187};
188
189static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
190 char *dbuf, const char *sbuf, apr_bucket_brigade *bb,
192{
194 const apr_table_entry_t *hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
196 apr_file_t *f = NULL;
197 apr_bucket *e;
198 const char *buf;
200 apr_status_t rv;
201 int first;
202 int i;
203 apr_finfo_t finfo;
204 char time_str[APR_CTIME_LEN];
205
206 /* XXX Very expensive mainline case! Open, then getfileinfo! */
207 if (!conf->logname ||
208 ((apr_stat(&finfo, conf->logname,
210 (finfo.size > conf->logbytes)) ||
211 (apr_file_open(&f, conf->logname,
213 r->pool) != APR_SUCCESS)) {
214 /* Soak up script output */
217 return ret;
218 }
219
220 /* "%% [Wed Jun 19 10:53:21 1996] GET /cgi-bin/printenv HTTP/1.0" */
221 apr_ctime(time_str, apr_time_now());
222 apr_file_printf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
223 r->args ? "?" : "", r->args ? r->args : "", r->protocol);
224 /* "%% 500 /usr/local/apache/cgi-bin" */
225 apr_file_printf(f, "%%%% %d %s\n", ret, r->filename);
226
227 apr_file_puts("%request\n", f);
228 for (i = 0; i < hdrs_arr->nelts; ++i) {
229 if (!hdrs[i].key)
230 continue;
231 apr_file_printf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
232 }
233 if ((r->method_number == M_POST || r->method_number == M_PUT) &&
234 *dbuf) {
235 apr_file_printf(f, "\n%s\n", dbuf);
236 }
237
238 apr_file_puts("%response\n", f);
240 hdrs = (const apr_table_entry_t *) hdrs_arr->elts;
241
242 for (i = 0; i < hdrs_arr->nelts; ++i) {
243 if (!hdrs[i].key)
244 continue;
245 apr_file_printf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
246 }
247
248 if (sbuf && *sbuf)
249 apr_file_printf(f, "%s\n", sbuf);
250
251 first = 1;
252 for (e = APR_BRIGADE_FIRST(bb);
253 e != APR_BRIGADE_SENTINEL(bb);
255 {
256 if (APR_BUCKET_IS_EOS(e)) {
257 break;
258 }
260 if (rv != APR_SUCCESS || (len == 0)) {
261 break;
262 }
263 if (first) {
264 apr_file_puts("%stdout\n", f);
265 first = 0;
266 }
268 apr_file_puts("\n", f);
269 }
270
272 apr_file_puts("%stderr\n", f);
277 }
278 apr_file_puts("\n", f);
279 }
280
283
285 return ret;
286}
287
288
289/* This is the special environment used for running the "exec cmd="
290 * variety of SSI directives.
291 */
293{
295
296 if (r->path_info && r->path_info[0] != '\0') {
298
300 r->path_info));
301
303 r, NULL);
304 if (pa_req->filename) {
305 apr_table_setn(e, "PATH_TRANSLATED",
306 apr_pstrcat(r->pool, pa_req->filename,
307 pa_req->path_info, NULL));
308 }
310 }
311
312 if (r->args) {
313 char *arg_copy = apr_pstrdup(r->pool, r->args);
314
315 apr_table_setn(e, "QUERY_STRING", r->args);
317 apr_table_setn(e, "QUERY_STRING_UNESCAPED",
319 }
320}
321
323 const char *description)
324{
326
328 /* Escape the logged string because it may be something that
329 * came in over the network.
330 */
332 "(%d)%pm: %s\n",
333 err,
334 &err,
337#endif
338 description
340 )
341#endif
342 );
343}
344
348 const char *command,
349 const char * const argv[],
350 request_rec *r,
351 apr_pool_t *p,
353{
354 const char * const *env;
355 apr_procattr_t *procattr;
358
359#ifdef AP_CGI_USE_RLIMIT
361#endif
362
363#ifdef DEBUG_CGI
364#ifdef OS2
365 /* Under OS/2 need to use device con. */
366 FILE *dbg = fopen("con", "w");
367#else
368 FILE *dbg = fopen("/dev/tty", "w");
369#endif
370 int i;
371#endif
372
374#ifdef DEBUG_CGI
375 fprintf(dbg, "Attempting to exec %s as CGI child (argv0 = %s)\n",
376 r->filename, argv[0]);
377#endif
378
379 env = (const char * const *)ap_create_environment(p, r->subprocess_env);
380
381#ifdef DEBUG_CGI
382 fprintf(dbg, "Environment: \n");
383 for (i = 0; env[i]; ++i)
384 fprintf(dbg, "'%s'\n", env[i]);
385 fclose(dbg);
386#endif
387
388 /* Transmute ourselves into the script.
389 * NB only ISINDEX scripts get decoded arguments.
390 */
391 if (((rc = apr_procattr_create(&procattr, p)) != APR_SUCCESS) ||
392 ((rc = apr_procattr_io_set(procattr,
393 e_info->in_pipe,
394 e_info->out_pipe,
395 e_info->err_pipe)) != APR_SUCCESS) ||
396 ((rc = apr_procattr_dir_set(procattr,
398 r->filename))) != APR_SUCCESS) ||
401 conf->limit_cpu)) != APR_SUCCESS) ||
402#endif
405 conf->limit_mem)) != APR_SUCCESS) ||
406#endif
409 conf->limit_nproc)) != APR_SUCCESS) ||
410#endif
411 ((rc = apr_procattr_cmdtype_set(procattr,
412 e_info->cmd_type)) != APR_SUCCESS) ||
413
414 ((rc = apr_procattr_detach_set(procattr,
415 e_info->detached)) != APR_SUCCESS) ||
416 ((rc = apr_procattr_addrspace_set(procattr,
419 /* Something bad happened, tell the world. */
421 "couldn't set child process attributes: %s", r->filename);
422 }
423 else {
424 procnew = apr_pcalloc(p, sizeof(*procnew));
426 procattr, p);
427
428 if (rc != APR_SUCCESS) {
429 /* Bad things happened. Everyone should have cleaned up. */
430 /* Intentional no APLOGNO */
432 "couldn't create child process: %d: %s", rc,
434 }
435 else {
438
440
441 *script_in = procnew->out;
442 if (!*script_in)
443 return APR_EBADF;
445
446 if (e_info->prog_type == RUN_AS_CGI) {
447 *script_out = procnew->in;
448 if (!*script_out)
449 return APR_EBADF;
451
452 *script_err = procnew->err;
453 if (!*script_err)
454 return APR_EBADF;
456 }
457 }
458 }
459 return (rc);
460}
461
462
463static apr_status_t default_build_command(const char **cmd, const char ***argv,
466{
467 int numwords, x, idx;
468 char *w;
469 const char *args = NULL;
470
471 if (e_info->process_cgi) {
472 *cmd = r->filename;
473 /* Do not process r->args if they contain an '=' assignment
474 */
475 if (r->args && r->args[0] && !ap_strchr_c(r->args, '=')) {
476 args = r->args;
477 }
478 }
479
480 if (!args) {
481 numwords = 1;
482 }
483 else {
484 /* count the number of keywords */
485 for (x = 0, numwords = 2; args[x]; x++) {
486 if (args[x] == '+') {
487 ++numwords;
488 }
489 }
490 }
491 /* Everything is - 1 to account for the first parameter
492 * which is the program name.
493 */
494 if (numwords > APACHE_ARG_MAX - 1) {
495 numwords = APACHE_ARG_MAX - 1; /* Truncate args to prevent overrun */
496 }
497 *argv = apr_palloc(p, (numwords + 2) * sizeof(char *));
498 (*argv)[0] = *cmd;
499 for (x = 1, idx = 1; x < numwords; x++) {
500 w = ap_getword_nulls(p, &args, '+');
502 (*argv)[idx++] = ap_escape_shell_cmd(p, w);
503 }
504 (*argv)[idx] = NULL;
505
506 return APR_SUCCESS;
507}
508
510{
511 int nph;
513 const char *argv0;
514 const char *command;
515 const char **argv;
516 char *dbuf = NULL;
519 apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
520 apr_bucket *b;
521 int is_included;
522 apr_pool_t *p;
523 cgi_server_conf *conf;
524 apr_status_t rv;
528
529 if (strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) {
530 return DECLINED;
531 }
532
533 is_included = !strcmp(r->protocol, "INCLUDED");
534
535 p = r->main ? r->main->pool : r->pool;
536
538 nph = !(strncmp(argv0, "nph-", 4));
540
542 return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(02809),
543 "Options ExecCGI is off in this directory");
544 if (nph && is_included)
545 return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(02810),
546 "attempt to include NPH CGI script");
547
548 if (r->finfo.filetype == APR_NOFILE)
549 return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, APLOGNO(02811),
550 "script not found or unable to stat");
551 if (r->finfo.filetype == APR_DIR)
552 return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(02812),
553 "attempt to invoke directory as script");
554
556 r->path_info && *r->path_info)
557 {
558 /* default to accept */
559 return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, APLOGNO(02813),
560 "AcceptPathInfo off disallows user's path");
561 }
562/*
563 if (!ap_suexec_enabled) {
564 if (!ap_can_exec(&r->finfo))
565 return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(03194)
566 "file permissions deny server execution");
567 }
568
569*/
572
573 e_info.process_cgi = 1;
574 e_info.cmd_type = APR_PROGRAM;
575 e_info.detached = 0;
576 e_info.in_pipe = APR_CHILD_BLOCK;
577 e_info.out_pipe = APR_CHILD_BLOCK;
578 e_info.err_pipe = APR_CHILD_BLOCK;
579 e_info.prog_type = RUN_AS_CGI;
580 e_info.bb = NULL;
581 e_info.ctx = NULL;
582 e_info.next = NULL;
583 e_info.addrspace = 0;
584
585 /* build the command line */
586 if ((rv = cgi_build_command(&command, &argv, r, p, &e_info)) != APR_SUCCESS) {
588 "don't know how to spawn child process: %s",
589 r->filename);
591 }
592
593 /* run the script in its own process */
595 command, argv, r, p, &e_info)) != APR_SUCCESS) {
597 "couldn't spawn child process: %s", r->filename);
599 }
600
601 /* Buffer for logging script stdout. */
602 if (conf->logname) {
603 dbufsize = conf->bufbytes;
604 dbuf = apr_palloc(r->pool, dbufsize + 1);
605 }
606 else {
607 dbufsize = 0;
608 dbuf = NULL;
609 }
610
611 /* Read the request body. */
613 if (rv) {
615 "Error reading request entity data");
617 }
618
619 /* Is this flush really needed? */
622
624
625#if APR_FILES_AS_SOCKETS
626 b = cgi_bucket_create(r, dc->timeout, script_in, script_err, c->bucket_alloc);
627 if (b == NULL)
629#else
630 b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
631#endif
633 b = apr_bucket_eos_create(c->bucket_alloc);
635
636 return cgi_handle_response(r, nph, bb, timeout, conf, dbuf, script_err);
637}
638
639/*============================================================================
640 *============================================================================
641 * This is the beginning of the cgi filter code moved from mod_include. This
642 * is the code required to handle the "exec" SSI directive.
643 *============================================================================
644 *============================================================================*/
646 apr_bucket_brigade *bb, char *s)
647{
648 request_rec *r = f->r;
650 int rr_status;
651
652 if (rr->status != HTTP_OK) {
654 return APR_EGENERAL;
655 }
656
657 /* No hardwired path info or query allowed */
658 if ((rr->path_info && rr->path_info[0]) || rr->args) {
660 return APR_EGENERAL;
661 }
662 if (rr->finfo.filetype != APR_REG) {
664 return APR_EGENERAL;
665 }
666
667 /* Script gets parameters of the *document*, for back compatibility */
668 rr->path_info = r->path_info; /* hard to get right; see mod_cgi.c */
669 rr->args = r->args;
670
671 /* Force sub_req to be treated as a CGI request, even if ordinary
672 * typing rules would have called it something else.
673 */
675
676 /* Run it. */
679 const char *location = apr_table_get(rr->headers_out, "Location");
680
681 if (location) {
682 char *buffer;
683
684 location = ap_escape_html(rr->pool, location);
685 buffer = apr_pstrcat(ctx->pool, "<a href=\"", location, "\">",
686 location, "</a>", NULL);
687
689 strlen(buffer), ctx->pool,
690 f->c->bucket_alloc));
691 }
692 }
693
695
696 return APR_SUCCESS;
697}
698
700 apr_bucket_brigade *bb, const char *command)
701{
703 const char **argv;
705 apr_status_t rv;
706 request_rec *r = f->r;
707
709
710 e_info.process_cgi = 0;
711 e_info.cmd_type = APR_SHELLCMD;
712 e_info.detached = 0;
713 e_info.in_pipe = APR_NO_PIPE;
714 e_info.out_pipe = APR_FULL_BLOCK;
715 e_info.err_pipe = APR_NO_PIPE;
716 e_info.prog_type = RUN_AS_SSI;
717 e_info.bb = &bb;
718 e_info.ctx = ctx;
719 e_info.next = f->next;
720 e_info.addrspace = 0;
721
722 if ((rv = cgi_build_command(&command, &argv, r, r->pool,
723 &e_info)) != APR_SUCCESS) {
725 "don't know how to spawn cmd child process: %s",
726 r->filename);
727 return rv;
728 }
729
730 /* run the script in its own process */
732 command, argv, r, r->pool,
733 &e_info)) != APR_SUCCESS) {
735 "couldn't spawn child process: %s", r->filename);
736 return rv;
737 }
738
740 f->c->bucket_alloc));
741 ctx->flush_now = 1;
742
743 /* We can't close the pipe here, because we may return before the
744 * full CGI has been sent to the network. That's okay though,
745 * because we can rely on the pool to close the pipe for us.
746 */
747 return APR_SUCCESS;
748}
749
751 apr_pool_t *ptemp, server_rec *s)
752{
753 /* This is the means by which unusual (non-unix) os's may find alternate
754 * means to run a given command (e.g. shebang/registry parsing on Win32)
755 */
757 if (!cgi_build_command) {
759 }
760 return OK;
761}
762
770
772{
774 create_cgi_dirconf, /* dir config creater */
775 NULL, /* dir merger --- default is to override */
776 create_cgi_config, /* server config */
777 merge_cgi_config, /* merge server config */
778 cgi_cmds, /* command apr_table_t */
779 register_hooks /* register hooks */
780};
Symbol export macros and hook functions.
Apache Multi-Processing Module library.
const char apr_size_t len
Definition ap_regex.h:187
APR-UTIL Buckets/Bucket Brigades.
APR general purpose library routines.
APR-UTIL registration of functions exported by modules.
APR Poll interface.
APR Strings library.
APR Thread and Process Library.
APR Standard Headers Support.
static void cgi_optfns_retrieve(void)
Definition cgi_common.h:208
static int cgi_handle_response(request_rec *r, int nph, apr_bucket_brigade *bb, apr_interval_time_t timeout, cgi_server_conf *conf, char *logdata, apr_file_t *script_err)
Definition cgi_common.h:420
static int log_scripterror(request_rec *r, cgi_server_conf *conf, int ret, apr_status_t rv, const char *logno, const char *error)
Definition cgi_common.h:64
static apr_status_t log_script_err(request_rec *r, apr_file_t *script_err)
Definition cgi_common.h:103
static apr_status_t cgi_handle_request(request_rec *r, apr_file_t *script_out, apr_bucket_brigade *bb, char *logbuf, apr_size_t logbufbytes)
Definition cgi_common.h:557
#define AP_INIT_TAKE1(directive, func, mconfig, where, help)
#define ap_get_module_config(v, m)
void ap_hook_post_config(ap_HOOK_post_config_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
Definition config.c:105
#define AP_DECLARE_MODULE(foo)
ap_conf_vector_t * base
char * ap_server_root_relative(apr_pool_t *p, const char *fname)
Definition config.c:1594
void ap_hook_handler(ap_HOOK_handler_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
Definition config.c:170
request_rec * r
void ap_hook_optional_fn_retrieve(ap_HOOK_optional_fn_retrieve_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
Definition config.c:195
#define HUGE_STRING_LEN
Definition httpd.h:303
#define DECLINED
Definition httpd.h:457
#define OK
Definition httpd.h:456
#define OPT_EXECCGI
Definition http_core.h:78
#define ap_get_core_module_config(v)
Definition http_core.h:383
int ap_allow_options(request_rec *r)
Definition core.c:771
#define APLOGNO(n)
Definition http_log.h:117
#define ap_log_rerror
Definition http_log.h:454
#define APLOG_ERR
Definition http_log.h:67
#define APLOG_TOCLIENT
Definition http_log.h:102
#define APLOG_MARK
Definition http_log.h:283
const unsigned char * buf
Definition util_md5.h:50
apr_status_t ap_os_create_privileged_process(const request_rec *r, apr_proc_t *newproc, const char *progname, const char *const *args, const char *const *env, apr_procattr_t *attr, apr_pool_t *p)
int ap_map_http_request_error(apr_status_t rv, int status)
void ap_set_content_type_ex(request_rec *r, const char *ct, int trusted)
request_rec * ap_sub_req_lookup_uri(const char *new_uri, const request_rec *r, ap_filter_t *next_filter)
Definition request.c:2297
int ap_run_sub_req(request_rec *r)
Definition request.c:2528
void ap_destroy_sub_req(request_rec *r)
Definition request.c:2547
void ap_add_common_vars(request_rec *r)
char ** ap_create_environment(apr_pool_t *p, apr_table_t *t)
#define APACHE_ARG_MAX
Definition util_script.h:40
void ap_add_cgi_vars(request_rec *r)
void * dummy
Definition http_vhost.h:62
void const char * arg
Definition http_vhost.h:63
#define APR_EGENERAL
Definition apr_errno.h:313
#define APR_EBADF
Definition apr_errno.h:704
apr_file_t * f
#define APR_BRIGADE_INSERT_TAIL(b, e)
#define APR_BUCKET_NEXT(e)
apr_bucket * e
#define APR_BRIGADE_SENTINEL(b)
#define APR_BUCKET_IS_EOS(e)
apr_brigade_flush void * ctx
#define APR_BRIGADE_FIRST(b)
#define apr_bucket_read(e, str, len, block)
@ APR_BLOCK_READ
Definition apr_buckets.h:58
const char *const * aszPre
Definition apr_hooks.h:345
#define APR_HOOK_REALLY_FIRST
Definition apr_hooks.h:299
#define APR_HOOK_MIDDLE
Definition apr_hooks.h:303
#define APR_RETRIEVE_OPTIONAL_FN(name)
#define APR_OPTIONAL_FN_TYPE(name)
apr_redis_t * rc
Definition apr_redis.h:173
#define ACCESS_CONF
#define RSRC_CONF
#define HTTP_OK
Definition httpd.h:490
#define HTTP_BAD_REQUEST
Definition httpd.h:508
#define HTTP_INTERNAL_SERVER_ERROR
Definition httpd.h:535
#define ap_is_HTTP_REDIRECT(x)
Definition httpd.h:552
#define HTTP_FORBIDDEN
Definition httpd.h:511
#define HTTP_NOT_FOUND
Definition httpd.h:512
@ RUN_AS_SSI
Definition mod_cgi.h:31
@ RUN_AS_CGI
Definition mod_cgi.h:31
#define M_PUT
Definition httpd.h:593
#define M_POST
Definition httpd.h:594
#define STANDARD20_MODULE_STUFF
char * ap_escape_logitem(apr_pool_t *p, const char *str)
Definition util.c:2183
#define ap_escape_uri(ppool, path)
Definition httpd.h:1836
char * ap_escape_shell_cmd(apr_pool_t *p, const char *s)
Definition util.c:1812
#define ap_strchr_c(s, c)
Definition httpd.h:2353
char * ap_make_dirstr_parent(apr_pool_t *p, const char *s)
Definition util.c:692
#define AP_DEBUG_ASSERT(exp)
Definition httpd.h:2283
char * ap_getword_nulls(apr_pool_t *p, const char **line, char stop)
Definition util.c:779
#define ap_escape_html(p, s)
Definition httpd.h:1860
int ap_unescape_url(char *url)
Definition util.c:1939
apr_status_t ap_timeout_parameter_parse(const char *timeout_parameter, apr_interval_time_t *timeout, const char *default_time_unit)
Definition util.c:2622
apr_size_t size
apr_uint32_t val
Definition apr_atomic.h:66
const char int apr_pool_t * pool
Definition apr_cstr.h:84
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
@ APR_REG
@ APR_DIR
@ APR_NOFILE
const char * key
char * buffer
#define APR_APPEND
Definition apr_file_io.h:96
#define APR_WRITE
Definition apr_file_io.h:94
#define APR_CREATE
Definition apr_file_io.h:95
#define APR_OS_DEFAULT
#define APR_FINFO_SIZE
int strcasecmp(const char *a, const char *b)
apr_vformatter_buff_t * c
Definition apr_lib.h:175
char const *const char const *const ** env
apr_interval_time_t t
apr_pool_t * b
Definition apr_pools.h:529
#define apr_pcalloc(p, size)
Definition apr_pools.h:465
const char * s
Definition apr_strings.h:95
const apr_array_header_t * first
Definition apr_tables.h:207
apr_int32_t apr_int32_t apr_int32_t err
#define APR_FULL_BLOCK
#define APR_LIMIT_MEM
#define APR_LIMIT_NPROC
apr_cmdtype_e cmd
#define APR_LIMIT_CPU
const char const char *const * args
#define APR_NO_PIPE
#define APR_CHILD_BLOCK
@ APR_KILL_AFTER_TIMEOUT
@ APR_SHELLCMD
@ APR_PROGRAM
#define APR_CTIME_LEN
Definition apr_time.h:198
apr_int64_t apr_interval_time_t
Definition apr_time.h:55
#define CGI_MAGIC_TYPE
Definition httpd.h:705
#define RAISE_SIGSTOP(x)
Definition httpd.h:2312
#define AP_REQ_REJECT_PATH_INFO
Definition httpd.h:763
Apache Configuration.
CORE HTTP Daemon.
Apache Logging library.
Command line options.
HTTP protocol handling.
Apache Request library.
HTTP Daemon routines.
static apr_file_t * stderr_log
Definition log.c:170
apr_pool_t * p
Definition md_event.c:32
static const char * set_scriptlog_length(cmd_parms *cmd, void *dummy, const char *arg)
Definition mod_cgi.c:142
static apr_status_t default_build_command(const char **cmd, const char ***argv, request_rec *r, apr_pool_t *p, cgi_exec_info_t *e_info)
Definition mod_cgi.c:463
static const char * set_script_timeout(cmd_parms *cmd, void *dummy, const char *arg)
Definition mod_cgi.c:164
static void cgi_child_errfn(apr_pool_t *pool, apr_status_t err, const char *description)
Definition mod_cgi.c:322
static void * create_cgi_dirconf(apr_pool_t *p, char *dummy)
Definition mod_cgi.c:120
static int log_script(request_rec *r, cgi_server_conf *conf, int ret, char *dbuf, const char *sbuf, apr_bucket_brigade *bb, apr_file_t *script_err)
Definition mod_cgi.c:189
static const char * set_scriptlog_buffer(cmd_parms *cmd, void *dummy, const char *arg)
Definition mod_cgi.c:153
static apr_OFN_ap_cgi_build_command_t * cgi_build_command
Definition mod_cgi.c:63
static int cgi_handler(request_rec *r)
Definition mod_cgi.c:509
static apr_status_t run_cgi_child(apr_file_t **script_out, apr_file_t **script_in, apr_file_t **script_err, const char *command, const char *const argv[], request_rec *r, apr_pool_t *p, cgi_exec_info_t *e_info)
Definition mod_cgi.c:345
static int cgi_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
Definition mod_cgi.c:750
#define DEFAULT_LOGBYTES
Definition mod_cgi.c:82
static void * merge_cgi_config(apr_pool_t *p, void *basev, void *overridesv)
Definition mod_cgi.c:112
static void register_hooks(apr_pool_t *p)
Definition mod_cgi.c:763
static int is_scriptaliased(request_rec *r)
Definition mod_cgi.c:74
static apr_status_t include_cmd(include_ctx_t *ctx, ap_filter_t *f, apr_bucket_brigade *bb, const char *command)
Definition mod_cgi.c:699
static void add_ssi_vars(request_rec *r)
Definition mod_cgi.c:292
static apr_status_t include_cgi(include_ctx_t *ctx, ap_filter_t *f, apr_bucket_brigade *bb, char *s)
Definition mod_cgi.c:645
static const char * set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
Definition mod_cgi.c:126
static void * create_cgi_config(apr_pool_t *p, server_rec *s)
Definition mod_cgi.c:100
static const command_rec cgi_cmds[]
Definition mod_cgi.c:175
#define DEFAULT_BUFBYTES
Definition mod_cgi.c:83
static void discard_script_output(apr_bucket_brigade *bb)
CGI Script Execution Extension Module for Apache.
#define cgi_module
Definition mod_cgid.c:218
mod_core private header file
const char * argv[3]
return NULL
Definition mod_so.c:359
int i
Definition mod_so.c:347
static apr_status_t command(sed_eval_t *eval, sed_reptr_t *ipc, step_vars_storage *step_vars)
Definition sed1.c:766
The representation of a filter chain.
apr_filetype_e filetype
apr_off_t size
Definition apr_tables.h:81
apr_interval_time_t timeout
Definition mod_cgi.c:92
apr_size_t bufbytes
Definition mod_cgi.c:88
const char * logname
Definition mod_cgi.c:86
Structure to store things which are per connection.
Definition httpd.h:1152
Per-directory configuration.
Definition http_core.h:527
A structure that represents the current request.
Definition httpd.h:845
char * uri
Definition httpd.h:1016
const char * handler
Definition httpd.h:994
apr_table_t * notes
Definition httpd.h:985
int used_path_info
Definition httpd.h:1036
int method_number
Definition httpd.h:898
apr_pool_t * pool
Definition httpd.h:847
char * filename
Definition httpd.h:1018
conn_rec * connection
Definition httpd.h:849
apr_table_t * err_headers_out
Definition httpd.h:981
apr_finfo_t finfo
Definition httpd.h:1094
apr_table_t * headers_in
Definition httpd.h:976
char * protocol
Definition httpd.h:879
request_rec * main
Definition httpd.h:860
apr_table_t * subprocess_env
Definition httpd.h:983
server_rec * server
Definition httpd.h:851
struct ap_conf_vector_t * per_dir_config
Definition httpd.h:1047
const char * method
Definition httpd.h:900
char * path_info
Definition httpd.h:1024
char * args
Definition httpd.h:1026
A structure to store information for each virtual server.
Definition httpd.h:1322
apr_interval_time_t timeout
Definition httpd.h:1372
struct ap_conf_vector_t * module_config
Definition httpd.h:1341
apr_status_t apr_ctime(char *date_str, apr_time_t t)
Definition timestr.c:90
Apache filter library.
IN ULONG IN INT timeout