| 1466 | } |
| 1467 | |
| 1468 | static int cgid_handler(request_rec *r) |
| 1469 | { |
| 1470 | conn_rec *c = r->connection; |
| 1471 | int retval, nph; |
| 1472 | char *argv0, *dbuf; |
| 1473 | apr_size_t dbufsize; |
| 1474 | apr_bucket_brigade *bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); |
| 1475 | apr_bucket *b; |
| 1476 | cgid_server_conf *conf; |
| 1477 | int is_included; |
| 1478 | int sd; |
| 1479 | char **env; |
| 1480 | apr_file_t *tempsock, *script_err, *errpipe_out; |
| 1481 | struct cleanup_script_info *info; |
| 1482 | apr_status_t rv; |
| 1483 | cgid_dirconf *dc; |
| 1484 | apr_interval_time_t timeout; |
| 1485 | |
| 1486 | if (strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) { |
| 1487 | return DECLINED; |
| 1488 | } |
| 1489 | |
| 1490 | conf = ap_get_module_config(r->server->module_config, &cgid_module); |
| 1491 | dc = ap_get_module_config(r->per_dir_config, &cgid_module); |
| 1492 | |
| 1493 | timeout = dc->timeout > 0 ? dc->timeout : r->server->timeout; |
| 1494 | is_included = !strcmp(r->protocol, "INCLUDED"); |
| 1495 | |
| 1496 | if ((argv0 = strrchr(r->filename, '/')) != NULL) { |
| 1497 | argv0++; |
| 1498 | } |
| 1499 | else { |
| 1500 | argv0 = r->filename; |
| 1501 | } |
| 1502 | |
| 1503 | nph = !(strncmp(argv0, "nph-", 4)); |
| 1504 | |
| 1505 | argv0 = r->filename; |
| 1506 | |
| 1507 | if (!(ap_allow_options(r) & OPT_EXECCGI) && !is_scriptaliased(r)) { |
| 1508 | return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(01262), |
| 1509 | "Options ExecCGI is off in this directory"); |
| 1510 | } |
| 1511 | |
| 1512 | if (nph && is_included) { |
| 1513 | return log_scripterror(r, conf, HTTP_FORBIDDEN, 0, APLOGNO(01263), |
| 1514 | "attempt to include NPH CGI script"); |
| 1515 | } |
| 1516 | |
| 1517 | #if defined(OS2) || defined(WIN32) |
| 1518 | #error mod_cgid does not work on this platform. If you teach it to, look |
| 1519 | #error at mod_cgi.c for required code in this path. |
| 1520 | #else |
| 1521 | if (r->finfo.filetype == APR_NOFILE) { |
| 1522 | return log_scripterror(r, conf, HTTP_NOT_FOUND, 0, APLOGNO(01264), |
| 1523 | "script not found or unable to stat"); |
| 1524 | } |
| 1525 | #endif |
nothing calls this directly
no test coverage detected