| |
@@ -1,14 +1,41 @@
|
| |
|
| |
https://github.com/apache/httpd/pull/209
|
| |
|
| |
- Upstream-Status: in trunk, not proposed for 2.4.x
|
| |
-
|
| |
+ diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
|
| |
+ index ddacd4af19..6d4379d165 100644
|
| |
+ --- a/.github/workflows/linux.yml
|
| |
+ +++ b/.github/workflows/linux.yml
|
| |
+ @@ -48,11 +48,11 @@ jobs:
|
| |
+ - name: Shared MPMs, all-modules
|
| |
+ config: --enable-mods-shared=reallyall --enable-mpms-shared=all
|
| |
+ # -------------------------------------------------------------------------
|
| |
+ - - name: Event MPM, all-modules, mod_cgid only
|
| |
+ - config: --enable-mods-shared=reallyall --with-mpm=event --disable-cgi
|
| |
+ + - name: Event MPM, all-modules, mod_cgid fdpassing
|
| |
+ + config: --enable-mods-shared=reallyall --with-mpm=event --disable-cgi --enable-cgid-fdpassing
|
| |
+ # -------------------------------------------------------------------------
|
| |
+ - - name: Event MPM, all-modules, no CMSG_DATA
|
| |
+ - config: --enable-mods-shared=reallyall --with-mpm=event ac_cv_have_decl_CMSG_DATA=no
|
| |
+ + - name: Event MPM, all-modules, mod_cgid w/o fdpassing
|
| |
+ + config: --enable-mods-shared=reallyall --with-mpm=event --disable-cgi
|
| |
+ # -------------------------------------------------------------------------
|
| |
+ - name: Default, all-modules + install
|
| |
+ config: --enable-mods-shared=reallyall
|
| |
+ diff --git a/changes-entries/pr54221.txt b/changes-entries/pr54221.txt
|
| |
+ new file mode 100644
|
| |
+ index 0000000000..62b75ea4dd
|
| |
+ --- /dev/null
|
| |
+ +++ b/changes-entries/pr54221.txt
|
| |
+ @@ -0,0 +1,3 @@
|
| |
+ + *) mod_cgid: Optional support for file descriptor passing, fixing
|
| |
+ + error log handling (configure --enable-cgid-fdpassing) on Unix
|
| |
+ + platforms. PR 54221. [Joe Orton]
|
| |
diff --git a/modules/generators/cgi_common.h b/modules/generators/cgi_common.h
|
| |
new file mode 100644
|
| |
- index 0000000000..69df73ce68
|
| |
+ index 0000000000..66f9418f21
|
| |
--- /dev/null
|
| |
+++ b/modules/generators/cgi_common.h
|
| |
- @@ -0,0 +1,629 @@
|
| |
+ @@ -0,0 +1,639 @@
|
| |
+/* Licensed to the Apache Software Foundation (ASF) under one or more
|
| |
+ * contributor license agreements. See the NOTICE file distributed with
|
| |
+ * this work for additional information regarding copyright ownership.
|
| |
@@ -37,6 +64,7 @@
|
| |
+
|
| |
+#include "httpd.h"
|
| |
+#include "util_filter.h"
|
| |
+ +#include "util_script.h"
|
| |
+
|
| |
+static APR_OPTIONAL_FN_TYPE(ap_ssi_get_tag_and_value) *cgi_pfn_gtv;
|
| |
+static APR_OPTIONAL_FN_TYPE(ap_ssi_parse_string) *cgi_pfn_ps;
|
| |
@@ -439,9 +467,18 @@
|
| |
+ char sbuf[MAX_STRING_LEN];
|
| |
+ int ret;
|
| |
+
|
| |
- + if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
|
| |
- + APLOG_MODULE_INDEX)))
|
| |
- + {
|
| |
+ + ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
|
| |
+ + APLOG_MODULE_INDEX);
|
| |
+ +
|
| |
+ + /* xCGI has its own body framing mechanism which we don't
|
| |
+ + * match against any provided Content-Length, so let the
|
| |
+ + * core determine C-L vs T-E based on what's actually sent.
|
| |
+ + */
|
| |
+ + if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
|
| |
+ + apr_table_unset(r->headers_out, "Content-Length");
|
| |
+ + apr_table_unset(r->headers_out, "Transfer-Encoding");
|
| |
+ +
|
| |
+ + if (ret != OK) {
|
| |
+ /* In the case of a timeout reading script output, clear
|
| |
+ * the brigade to avoid a second attempt to read the
|
| |
+ * output. */
|
| |
@@ -659,10 +696,18 @@
|
| |
+
|
| |
APACHE_MODPATH_FINISH
|
| |
diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c
|
| |
- index 7e4b126c10..421124a0cb 100644
|
| |
+ index 1f7778617e..3799b06ce3 100644
|
| |
--- a/modules/generators/mod_cgi.c
|
| |
+++ b/modules/generators/mod_cgi.c
|
| |
- @@ -61,9 +61,6 @@
|
| |
+ @@ -48,7 +48,6 @@
|
| |
+ #include "http_protocol.h"
|
| |
+ #include "http_main.h"
|
| |
+ #include "http_log.h"
|
| |
+ -#include "util_script.h"
|
| |
+ #include "ap_mpm.h"
|
| |
+ #include "mod_core.h"
|
| |
+ #include "mod_cgi.h"
|
| |
+ @@ -61,9 +60,6 @@
|
| |
|
| |
module AP_MODULE_DECLARE_DATA cgi_module;
|
| |
|
| |
@@ -672,14 +717,10 @@
|
| |
static APR_OPTIONAL_FN_TYPE(ap_cgi_build_command) *cgi_build_command;
|
| |
|
| |
/* Read and discard the data in the brigade produced by a CGI script */
|
| |
- @@ -92,6 +89,15 @@ typedef struct {
|
| |
- apr_size_t bufbytes;
|
| |
- } cgi_server_conf;
|
| |
+ @@ -96,6 +92,11 @@ typedef struct {
|
| |
+ apr_interval_time_t timeout;
|
| |
+ } cgi_dirconf;
|
| |
|
| |
- +typedef struct {
|
| |
- + apr_interval_time_t timeout;
|
| |
- +} cgi_dirconf;
|
| |
- +
|
| |
+#if APR_FILES_AS_SOCKETS
|
| |
+#define WANT_CGI_BUCKET
|
| |
+#endif
|
| |
@@ -688,44 +729,7 @@
|
| |
static void *create_cgi_config(apr_pool_t *p, server_rec *s)
|
| |
{
|
| |
cgi_server_conf *c =
|
| |
- @@ -112,6 +118,12 @@ static void *merge_cgi_config(apr_pool_t *p, void *basev, void *overridesv)
|
| |
- return overrides->logname ? overrides : base;
|
| |
- }
|
| |
-
|
| |
- +static void *create_cgi_dirconf(apr_pool_t *p, char *dummy)
|
| |
- +{
|
| |
- + cgi_dirconf *c = (cgi_dirconf *) apr_pcalloc(p, sizeof(cgi_dirconf));
|
| |
- + return c;
|
| |
- +}
|
| |
- +
|
| |
- static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
|
| |
- {
|
| |
- server_rec *s = cmd->server;
|
| |
- @@ -150,6 +162,17 @@ static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy,
|
| |
- return NULL;
|
| |
- }
|
| |
-
|
| |
- +static const char *set_script_timeout(cmd_parms *cmd, void *dummy, const char *arg)
|
| |
- +{
|
| |
- + cgi_dirconf *dc = dummy;
|
| |
- +
|
| |
- + if (ap_timeout_parameter_parse(arg, &dc->timeout, "s") != APR_SUCCESS) {
|
| |
- + return "CGIScriptTimeout has wrong format";
|
| |
- + }
|
| |
- +
|
| |
- + return NULL;
|
| |
- +}
|
| |
- +
|
| |
- static const command_rec cgi_cmds[] =
|
| |
- {
|
| |
- AP_INIT_TAKE1("ScriptLog", set_scriptlog, NULL, RSRC_CONF,
|
| |
- @@ -158,67 +181,12 @@ AP_INIT_TAKE1("ScriptLogLength", set_scriptlog_length, NULL, RSRC_CONF,
|
| |
- "the maximum length (in bytes) of the script debug log"),
|
| |
- AP_INIT_TAKE1("ScriptLogBuffer", set_scriptlog_buffer, NULL, RSRC_CONF,
|
| |
- "the maximum size (in bytes) to record of a POST request"),
|
| |
- +AP_INIT_TAKE1("CGIScriptTimeout", set_script_timeout, NULL, RSRC_CONF | ACCESS_CONF,
|
| |
- + "The amount of time to wait between successful reads from "
|
| |
- + "the CGI script, in seconds."),
|
| |
+ @@ -185,64 +186,6 @@ AP_INIT_TAKE1("CGIScriptTimeout", set_script_timeout, NULL, RSRC_CONF | ACCESS_C
|
| |
{NULL}
|
| |
};
|
| |
|
| |
@@ -790,37 +794,7 @@
|
| |
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)
|
| |
- @@ -466,23 +434,26 @@ static apr_status_t run_cgi_child(apr_file_t **script_out,
|
| |
- apr_filepath_name_get(r->filename));
|
| |
- }
|
| |
- else {
|
| |
- + cgi_dirconf *dc = ap_get_module_config(r->per_dir_config, &cgi_module);
|
| |
- + apr_interval_time_t timeout = dc->timeout > 0 ? dc->timeout : r->server->timeout;
|
| |
- +
|
| |
- apr_pool_note_subprocess(p, procnew, APR_KILL_AFTER_TIMEOUT);
|
| |
-
|
| |
- *script_in = procnew->out;
|
| |
- if (!*script_in)
|
| |
- return APR_EBADF;
|
| |
- - apr_file_pipe_timeout_set(*script_in, r->server->timeout);
|
| |
- + apr_file_pipe_timeout_set(*script_in, timeout);
|
| |
-
|
| |
- if (e_info->prog_type == RUN_AS_CGI) {
|
| |
- *script_out = procnew->in;
|
| |
- if (!*script_out)
|
| |
- return APR_EBADF;
|
| |
- - apr_file_pipe_timeout_set(*script_out, r->server->timeout);
|
| |
- + apr_file_pipe_timeout_set(*script_out, timeout);
|
| |
-
|
| |
- *script_err = procnew->err;
|
| |
- if (!*script_err)
|
| |
- return APR_EBADF;
|
| |
- - apr_file_pipe_timeout_set(*script_err, r->server->timeout);
|
| |
- + apr_file_pipe_timeout_set(*script_err, timeout);
|
| |
- }
|
| |
- }
|
| |
- }
|
| |
- @@ -536,234 +507,30 @@ static apr_status_t default_build_command(const char **cmd, const char ***argv,
|
| |
+ @@ -563,230 +506,23 @@ static apr_status_t default_build_command(const char **cmd, const char ***argv,
|
| |
return APR_SUCCESS;
|
| |
}
|
| |
|
| |
@@ -963,11 +937,14 @@
|
| |
- apr_size_t *len, apr_read_type_e block)
|
| |
-{
|
| |
- struct cgi_bucket_data *data = b->data;
|
| |
- - apr_interval_time_t timeout;
|
| |
+ - apr_interval_time_t timeout = 0;
|
| |
- apr_status_t rv;
|
| |
- int gotdata = 0;
|
| |
+ - cgi_dirconf *dc = ap_get_module_config(data->r->per_dir_config, &cgi_module);
|
| |
-
|
| |
- - timeout = block == APR_NONBLOCK_READ ? 0 : data->r->server->timeout;
|
| |
+ - if (block != APR_NONBLOCK_READ) {
|
| |
+ - timeout = dc->timeout > 0 ? dc->timeout : data->r->server->timeout;
|
| |
+ - }
|
| |
-
|
| |
- do {
|
| |
- const apr_pollfd_t *results;
|
| |
@@ -1048,10 +1025,10 @@
|
| |
apr_status_t rv;
|
| |
cgi_exec_info_t e_info;
|
| |
- conn_rec *c;
|
| |
- + cgi_dirconf *dc = ap_get_module_config(r->per_dir_config, &cgi_module);
|
| |
- + apr_interval_time_t timeout = dc->timeout > 0 ? dc->timeout : r->server->timeout;
|
| |
+ cgi_dirconf *dc = ap_get_module_config(r->per_dir_config, &cgi_module);
|
| |
+ apr_interval_time_t timeout = dc->timeout > 0 ? dc->timeout : r->server->timeout;
|
| |
|
| |
- if (strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) {
|
| |
+ @@ -794,8 +530,6 @@ static int cgi_handler(request_rec *r)
|
| |
return DECLINED;
|
| |
}
|
| |
|
| |
@@ -1060,7 +1037,7 @@
|
| |
is_included = !strcmp(r->protocol, "INCLUDED");
|
| |
|
| |
p = r->main ? r->main->pool : r->pool;
|
| |
- @@ -832,83 +599,24 @@ static int cgi_handler(request_rec *r)
|
| |
+ @@ -864,83 +598,24 @@ static int cgi_handler(request_rec *r)
|
| |
return HTTP_INTERNAL_SERVER_ERROR;
|
| |
}
|
| |
|
| |
@@ -1157,7 +1134,7 @@
|
| |
/* Is this flush really needed? */
|
| |
apr_file_flush(script_out);
|
| |
apr_file_close(script_out);
|
| |
- @@ -916,10 +624,7 @@ static int cgi_handler(request_rec *r)
|
| |
+ @@ -948,10 +623,7 @@ static int cgi_handler(request_rec *r)
|
| |
AP_DEBUG_ASSERT(script_in != NULL);
|
| |
|
| |
#if APR_FILES_AS_SOCKETS
|
| |
@@ -1169,7 +1146,7 @@
|
| |
if (b == NULL)
|
| |
return HTTP_INTERNAL_SERVER_ERROR;
|
| |
#else
|
| |
- @@ -929,111 +634,7 @@ static int cgi_handler(request_rec *r)
|
| |
+ @@ -961,120 +633,7 @@ static int cgi_handler(request_rec *r)
|
| |
b = apr_bucket_eos_create(c->bucket_alloc);
|
| |
APR_BRIGADE_INSERT_TAIL(bb, b);
|
| |
|
| |
@@ -1179,9 +1156,18 @@
|
| |
- char sbuf[MAX_STRING_LEN];
|
| |
- int ret;
|
| |
-
|
| |
- - if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
|
| |
- - APLOG_MODULE_INDEX)))
|
| |
- - {
|
| |
+ - ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
|
| |
+ - APLOG_MODULE_INDEX);
|
| |
+ -
|
| |
+ - /* xCGI has its own body framing mechanism which we don't
|
| |
+ - * match against any provided Content-Length, so let the
|
| |
+ - * core determine C-L vs T-E based on what's actually sent.
|
| |
+ - */
|
| |
+ - if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
|
| |
+ - apr_table_unset(r->headers_out, "Content-Length");
|
| |
+ - apr_table_unset(r->headers_out, "Transfer-Encoding");
|
| |
+ -
|
| |
+ - if (ret != OK) {
|
| |
- ret = log_script(r, conf, ret, dbuf, sbuf, bb, script_err);
|
| |
-
|
| |
- /*
|
| |
@@ -1220,7 +1206,7 @@
|
| |
- * stderr output, as normal. */
|
| |
- discard_script_output(bb);
|
| |
- apr_brigade_destroy(bb);
|
| |
- - apr_file_pipe_timeout_set(script_err, r->server->timeout);
|
| |
+ - apr_file_pipe_timeout_set(script_err, timeout);
|
| |
- log_script_err(r, script_err);
|
| |
- }
|
| |
-
|
| |
@@ -1271,7 +1257,7 @@
|
| |
- * connection drops or we stopped sending output for some other
|
| |
- * reason */
|
| |
- if (rv == APR_SUCCESS && !r->connection->aborted) {
|
| |
- - apr_file_pipe_timeout_set(script_err, r->server->timeout);
|
| |
+ - apr_file_pipe_timeout_set(script_err, timeout);
|
| |
- log_script_err(r, script_err);
|
| |
- }
|
| |
-
|
| |
@@ -1282,7 +1268,7 @@
|
| |
}
|
| |
|
| |
/*============================================================================
|
| |
- @@ -1147,107 +748,9 @@ static apr_status_t include_cmd(include_ctx_t *ctx, ap_filter_t *f,
|
| |
+ @@ -1188,107 +747,9 @@ static apr_status_t include_cmd(include_ctx_t *ctx, ap_filter_t *f,
|
| |
return APR_SUCCESS;
|
| |
}
|
| |
|
| |
@@ -1390,7 +1376,7 @@
|
| |
/* This is the means by which unusual (non-unix) os's may find alternate
|
| |
* means to run a given command (e.g. shebang/registry parsing on Win32)
|
| |
*/
|
| |
- @@ -1263,12 +766,13 @@ static void register_hooks(apr_pool_t *p)
|
| |
+ @@ -1304,6 +765,7 @@ static void register_hooks(apr_pool_t *p)
|
| |
static const char * const aszPre[] = { "mod_include.c", NULL };
|
| |
ap_hook_handler(cgi_handler, NULL, NULL, APR_HOOK_MIDDLE);
|
| |
ap_hook_post_config(cgi_post_config, aszPre, NULL, APR_HOOK_REALLY_FIRST);
|
| |
@@ -1398,18 +1384,19 @@
|
| |
}
|
| |
|
| |
AP_DECLARE_MODULE(cgi) =
|
| |
- {
|
| |
- STANDARD20_MODULE_STUFF,
|
| |
- - NULL, /* dir config creater */
|
| |
- + create_cgi_dirconf, /* dir config creater */
|
| |
- NULL, /* dir merger --- default is to override */
|
| |
- create_cgi_config, /* server config */
|
| |
- merge_cgi_config, /* merge server config */
|
| |
diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c
|
| |
- index 2258a683b7..dddfb25254 100644
|
| |
+ index 4bab59f932..1d55b8dc48 100644
|
| |
--- a/modules/generators/mod_cgid.c
|
| |
+++ b/modules/generators/mod_cgid.c
|
| |
- @@ -80,11 +80,6 @@ module AP_MODULE_DECLARE_DATA cgid_module;
|
| |
+ @@ -57,7 +57,6 @@
|
| |
+ #include "http_protocol.h"
|
| |
+ #include "http_main.h"
|
| |
+ #include "http_log.h"
|
| |
+ -#include "util_script.h"
|
| |
+ #include "ap_mpm.h"
|
| |
+ #include "mpm_common.h"
|
| |
+ #include "mod_suexec.h"
|
| |
+ @@ -80,11 +79,6 @@ module AP_MODULE_DECLARE_DATA cgid_module;
|
| |
|
| |
static int cgid_start(apr_pool_t *p, server_rec *main_server, apr_proc_t *procnew);
|
| |
static int cgid_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *main_server);
|
| |
@@ -1421,7 +1408,7 @@
|
| |
|
| |
static apr_pool_t *pcgi = NULL;
|
| |
static pid_t daemon_pid;
|
| |
- @@ -220,6 +215,15 @@ typedef struct {
|
| |
+ @@ -220,6 +214,15 @@ typedef struct {
|
| |
#endif
|
| |
} cgid_req_t;
|
| |
|
| |
@@ -1437,7 +1424,7 @@
|
| |
/* This routine is called to create the argument list to be passed
|
| |
* to the CGI script. When suexec is enabled, the suexec path, user, and
|
| |
* group are the first three arguments to be passed; if not, all three
|
| |
- @@ -342,15 +346,19 @@ static apr_status_t close_unix_socket(void *thefd)
|
| |
+ @@ -342,15 +345,19 @@ static apr_status_t close_unix_socket(void *thefd)
|
| |
return close(fd);
|
| |
}
|
| |
|
| |
@@ -1462,7 +1449,7 @@
|
| |
do {
|
| |
do {
|
| |
rc = read(fd, buf + bytes_read, buf_size - bytes_read);
|
| |
- @@ -365,9 +373,60 @@ static apr_status_t sock_read(int fd, void *vbuf, size_t buf_size)
|
| |
+ @@ -365,9 +372,60 @@ static apr_status_t sock_read(int fd, void *vbuf, size_t buf_size)
|
| |
}
|
| |
} while (bytes_read < buf_size);
|
| |
|
| |
@@ -1523,7 +1510,7 @@
|
| |
/* deal with signals
|
| |
*/
|
| |
static apr_status_t sock_write(int fd, const void *buf, size_t buf_size)
|
| |
- @@ -384,7 +443,7 @@ static apr_status_t sock_write(int fd, const void *buf, size_t buf_size)
|
| |
+ @@ -384,7 +442,7 @@ static apr_status_t sock_write(int fd, const void *buf, size_t buf_size)
|
| |
return APR_SUCCESS;
|
| |
}
|
| |
|
| |
@@ -1532,7 +1519,7 @@
|
| |
{
|
| |
va_list ap;
|
| |
int rc;
|
| |
- @@ -399,9 +458,39 @@ static apr_status_t sock_writev(int fd, request_rec *r, int count, ...)
|
| |
+ @@ -399,9 +457,39 @@ static apr_status_t sock_writev(int fd, request_rec *r, int count, ...)
|
| |
}
|
| |
va_end(ap);
|
| |
|
| |
@@ -1572,7 +1559,7 @@
|
| |
if (rc < 0) {
|
| |
return errno;
|
| |
}
|
| |
- @@ -410,7 +499,7 @@ static apr_status_t sock_writev(int fd, request_rec *r, int count, ...)
|
| |
+ @@ -410,7 +498,7 @@ static apr_status_t sock_writev(int fd, request_rec *r, int count, ...)
|
| |
}
|
| |
|
| |
static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env,
|
| |
@@ -1581,7 +1568,7 @@
|
| |
{
|
| |
int i;
|
| |
char **environ;
|
| |
- @@ -421,7 +510,7 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env,
|
| |
+ @@ -421,7 +509,7 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env,
|
| |
r->server = apr_pcalloc(r->pool, sizeof(server_rec));
|
| |
|
| |
/* read the request header */
|
| |
@@ -1590,7 +1577,7 @@
|
| |
if (stat != APR_SUCCESS) {
|
| |
return stat;
|
| |
}
|
| |
- @@ -431,6 +520,14 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env,
|
| |
+ @@ -431,6 +519,14 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env,
|
| |
return APR_SUCCESS;
|
| |
}
|
| |
|
| |
@@ -1605,7 +1592,7 @@
|
| |
/* handle module indexes and such */
|
| |
rconf = (void **)ap_create_request_config(r->pool);
|
| |
|
| |
- @@ -479,14 +576,15 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env,
|
| |
+ @@ -479,14 +575,15 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env,
|
| |
return APR_SUCCESS;
|
| |
}
|
| |
|
| |
@@ -1623,7 +1610,7 @@
|
| |
|
| |
|
| |
if (ugid == NULL) {
|
| |
- @@ -507,16 +605,21 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env,
|
| |
+ @@ -507,16 +604,21 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env,
|
| |
req.args_len = r->args ? strlen(r->args) : 0;
|
| |
req.loglevel = r->server->log.level;
|
| |
|
| |
@@ -1647,7 +1634,7 @@
|
| |
&req, sizeof(req),
|
| |
r->filename, req.filename_len,
|
| |
argv0, req.argv0_len,
|
| |
- @@ -531,7 +634,7 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env,
|
| |
+ @@ -531,7 +633,7 @@ static apr_status_t send_req(int fd, request_rec *r, char *argv0, char **env,
|
| |
for (i = 0; i < req.env_count; i++) {
|
| |
apr_size_t curlen = strlen(env[i]);
|
| |
|
| |
@@ -1656,7 +1643,7 @@
|
| |
env[i], curlen)) != APR_SUCCESS) {
|
| |
return stat;
|
| |
}
|
| |
- @@ -582,20 +685,34 @@ static void daemon_signal_handler(int sig)
|
| |
+ @@ -582,20 +684,34 @@ static void daemon_signal_handler(int sig)
|
| |
}
|
| |
}
|
| |
|
| |
@@ -1699,7 +1686,7 @@
|
| |
}
|
| |
|
| |
static int cgid_server(void *data)
|
| |
- @@ -670,7 +787,7 @@ static int cgid_server(void *data)
|
| |
+ @@ -670,7 +786,7 @@ static int cgid_server(void *data)
|
| |
}
|
| |
|
| |
while (!daemon_should_exit) {
|
| |
@@ -1708,7 +1695,7 @@
|
| |
char *argv0 = NULL;
|
| |
char **env = NULL;
|
| |
const char * const *argv;
|
| |
- @@ -710,7 +827,7 @@ static int cgid_server(void *data)
|
| |
+ @@ -710,7 +826,7 @@ static int cgid_server(void *data)
|
| |
r = apr_pcalloc(ptrans, sizeof(request_rec));
|
| |
procnew = apr_pcalloc(ptrans, sizeof(*procnew));
|
| |
r->pool = ptrans;
|
| |
@@ -1717,7 +1704,7 @@
|
| |
if (stat != APR_SUCCESS) {
|
| |
ap_log_error(APLOG_MARK, APLOG_ERR, stat,
|
| |
main_server, APLOGNO(01248)
|
| |
- @@ -742,6 +859,16 @@ static int cgid_server(void *data)
|
| |
+ @@ -742,6 +858,16 @@ static int cgid_server(void *data)
|
| |
continue;
|
| |
}
|
| |
|
| |
@@ -1734,7 +1721,7 @@
|
| |
apr_os_file_put(&r->server->error_log, &errfileno, 0, r->pool);
|
| |
apr_os_file_put(&inout, &sd2, 0, r->pool);
|
| |
|
| |
- @@ -801,7 +928,10 @@ static int cgid_server(void *data)
|
| |
+ @@ -801,7 +927,10 @@ static int cgid_server(void *data)
|
| |
close(sd2);
|
| |
}
|
| |
else {
|
| |
@@ -1746,7 +1733,7 @@
|
| |
|
| |
argv = (const char * const *)create_argv(r->pool, NULL, NULL, NULL, argv0, r->args);
|
| |
|
| |
- @@ -946,16 +1076,6 @@ static int cgid_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,
|
| |
+ @@ -946,16 +1075,6 @@ static int cgid_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,
|
| |
if (ret != OK ) {
|
| |
return ret;
|
| |
}
|
| |
@@ -1763,7 +1750,7 @@
|
| |
}
|
| |
return ret;
|
| |
}
|
| |
- @@ -1066,41 +1186,6 @@ static const command_rec cgid_cmds[] =
|
| |
+ @@ -1066,41 +1185,6 @@ static const command_rec cgid_cmds[] =
|
| |
{NULL}
|
| |
};
|
| |
|
| |
@@ -1805,7 +1792,7 @@
|
| |
static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
|
| |
char *dbuf, const char *sbuf, apr_bucket_brigade *bb,
|
| |
apr_file_t *script_err)
|
| |
- @@ -1221,7 +1306,7 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
|
| |
+ @@ -1221,7 +1305,7 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
|
| |
++connect_tries;
|
| |
if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
| |
return log_scripterror(r, conf, HTTP_INTERNAL_SERVER_ERROR, errno,
|
| |
@@ -1814,7 +1801,7 @@
|
| |
}
|
| |
if (connect(sd, (struct sockaddr *)server_addr, server_addr_len) < 0) {
|
| |
/* Save errno for later */
|
| |
- @@ -1242,7 +1327,7 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
|
| |
+ @@ -1242,7 +1326,7 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
|
| |
}
|
| |
else {
|
| |
close(sd);
|
| |
@@ -1823,7 +1810,7 @@
|
| |
"unable to connect to cgi daemon after multiple tries");
|
| |
}
|
| |
}
|
| |
- @@ -1258,13 +1343,15 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
|
| |
+ @@ -1258,13 +1342,15 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
|
| |
if (connect_errno == ENOENT &&
|
| |
apr_time_sec(apr_time_now() - ap_scoreboard_image->global->restart_time) >
|
| |
DEFAULT_CONNECT_STARTUP_DELAY) {
|
| |
@@ -1842,7 +1829,7 @@
|
| |
"cgid daemon is gone; is Apache terminating?");
|
| |
}
|
| |
}
|
| |
- @@ -1272,23 +1359,6 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
|
| |
+ @@ -1272,23 +1358,6 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
|
| |
return OK;
|
| |
}
|
| |
|
| |
@@ -1866,7 +1853,7 @@
|
| |
/****************************************************************
|
| |
*
|
| |
* Actual cgid handling...
|
| |
- @@ -1374,7 +1444,9 @@ static apr_status_t get_cgi_pid(request_rec *r, cgid_server_conf *conf, pid_t *
|
| |
+ @@ -1374,7 +1443,9 @@ static apr_status_t get_cgi_pid(request_rec *r, cgid_server_conf *conf, pid_t *
|
| |
return stat;
|
| |
}
|
| |
|
| |
@@ -1877,7 +1864,7 @@
|
| |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01261)
|
| |
"daemon couldn't find CGI process for connection %lu",
|
| |
r->connection->id);
|
| |
- @@ -1393,19 +1465,21 @@ static apr_status_t cleanup_script(void *vptr)
|
| |
+ @@ -1393,19 +1464,21 @@ static apr_status_t cleanup_script(void *vptr)
|
| |
|
| |
static int cgid_handler(request_rec *r)
|
| |
{
|
| |
@@ -1903,7 +1890,7 @@
|
| |
|
| |
if (strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) {
|
| |
return DECLINED;
|
| |
- @@ -1414,7 +1488,7 @@ static int cgid_handler(request_rec *r)
|
| |
+ @@ -1414,7 +1487,7 @@ static int cgid_handler(request_rec *r)
|
| |
conf = ap_get_module_config(r->server->module_config, &cgid_module);
|
| |
dc = ap_get_module_config(r->per_dir_config, &cgid_module);
|
| |
|
| |
@@ -1912,7 +1899,7 @@
|
| |
is_included = !strcmp(r->protocol, "INCLUDED");
|
| |
|
| |
if ((argv0 = strrchr(r->filename, '/')) != NULL) {
|
| |
- @@ -1429,12 +1503,12 @@ static int cgid_handler(request_rec *r)
|
| |
+ @@ -1429,12 +1502,12 @@ static int cgid_handler(request_rec *r)
|
| |
argv0 = r->filename;
|
| |
|
| |
if (!(ap_allow_options(r) & OPT_EXECCGI) && !is_scriptaliased(r)) {
|
| |
@@ -1927,7 +1914,7 @@
|
| |
"attempt to include NPH CGI script");
|
| |
}
|
| |
|
| |
- @@ -1443,12 +1517,12 @@ static int cgid_handler(request_rec *r)
|
| |
+ @@ -1443,12 +1516,12 @@ static int cgid_handler(request_rec *r)
|
| |
#error at mod_cgi.c for required code in this path.
|
| |
#else
|
| |
if (r->finfo.filetype == APR_NOFILE) {
|
| |
@@ -1942,7 +1929,7 @@
|
| |
"attempt to invoke directory as script");
|
| |
}
|
| |
|
| |
- @@ -1456,7 +1530,7 @@ static int cgid_handler(request_rec *r)
|
| |
+ @@ -1456,7 +1529,7 @@ static int cgid_handler(request_rec *r)
|
| |
r->path_info && *r->path_info)
|
| |
{
|
| |
/* default to accept */
|
| |
@@ -1951,7 +1938,7 @@
|
| |
"AcceptPathInfo off disallows user's path");
|
| |
}
|
| |
/*
|
| |
- @@ -1467,6 +1541,17 @@ static int cgid_handler(request_rec *r)
|
| |
+ @@ -1467,6 +1540,17 @@ static int cgid_handler(request_rec *r)
|
| |
}
|
| |
*/
|
| |
|
| |
@@ -1969,7 +1956,7 @@
|
| |
/*
|
| |
* httpd core function used to add common environment variables like
|
| |
* DOCUMENT_ROOT.
|
| |
- @@ -1479,24 +1564,28 @@ static int cgid_handler(request_rec *r)
|
| |
+ @@ -1479,24 +1563,28 @@ static int cgid_handler(request_rec *r)
|
| |
return retval;
|
| |
}
|
| |
|
| |
@@ -2005,7 +1992,7 @@
|
| |
}
|
| |
|
| |
/* We are putting the socket discriptor into an apr_file_t so that we can
|
| |
- @@ -1506,95 +1595,25 @@ static int cgid_handler(request_rec *r)
|
| |
+ @@ -1506,95 +1594,25 @@ static int cgid_handler(request_rec *r)
|
| |
*/
|
| |
|
| |
apr_os_pipe_put_ex(&tempsock, &sd, 1, r->pool);
|
| |
@@ -2114,7 +2101,7 @@
|
| |
}
|
| |
|
| |
/* we're done writing, or maybe we didn't write at all;
|
| |
- @@ -1603,125 +1622,22 @@ static int cgid_handler(request_rec *r)
|
| |
+ @@ -1603,134 +1621,22 @@ static int cgid_handler(request_rec *r)
|
| |
*/
|
| |
shutdown(sd, 1);
|
| |
|
| |
@@ -2131,9 +2118,18 @@
|
| |
- b = apr_bucket_eos_create(c->bucket_alloc);
|
| |
- APR_BRIGADE_INSERT_TAIL(bb, b);
|
| |
-
|
| |
- - if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
|
| |
- - APLOG_MODULE_INDEX)))
|
| |
- - {
|
| |
+ - ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
|
| |
+ - APLOG_MODULE_INDEX);
|
| |
+ -
|
| |
+ - /* xCGI has its own body framing mechanism which we don't
|
| |
+ - * match against any provided Content-Length, so let the
|
| |
+ - * core determine C-L vs T-E based on what's actually sent.
|
| |
+ - */
|
| |
+ - if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
|
| |
+ - apr_table_unset(r->headers_out, "Content-Length");
|
| |
+ - apr_table_unset(r->headers_out, "Transfer-Encoding");
|
| |
+ -
|
| |
+ - if (ret != OK) {
|
| |
- ret = log_script(r, conf, ret, dbuf, sbuf, bb, NULL);
|
| |
-
|
| |
- /*
|
| |
@@ -2253,7 +2249,7 @@
|
| |
static apr_status_t include_cgi(include_ctx_t *ctx, ap_filter_t *f,
|
| |
apr_bucket_brigade *bb, char *s)
|
| |
{
|
| |
- @@ -1806,7 +1722,7 @@ static void add_ssi_vars(request_rec *r)
|
| |
+ @@ -1815,7 +1721,7 @@ static void add_ssi_vars(request_rec *r)
|
| |
}
|
| |
|
| |
static int include_cmd(include_ctx_t *ctx, ap_filter_t *f,
|
| |
@@ -2262,7 +2258,7 @@
|
| |
{
|
| |
char **env;
|
| |
int sd;
|
| |
- @@ -1827,7 +1743,7 @@ static int include_cmd(include_ctx_t *ctx, ap_filter_t *f,
|
| |
+ @@ -1836,7 +1742,7 @@ static int include_cmd(include_ctx_t *ctx, ap_filter_t *f,
|
| |
return retval;
|
| |
}
|
| |
|
| |
@@ -2271,7 +2267,7 @@
|
| |
|
| |
info = apr_palloc(r->pool, sizeof(struct cleanup_script_info));
|
| |
info->conf = conf;
|
| |
- @@ -1872,91 +1788,6 @@ static int include_cmd(include_ctx_t *ctx, ap_filter_t *f,
|
| |
+ @@ -1881,91 +1787,6 @@ static int include_cmd(include_ctx_t *ctx, ap_filter_t *f,
|
| |
return APR_SUCCESS;
|
| |
}
|
| |
|
| |
@@ -2363,7 +2359,7 @@
|
| |
static void register_hook(apr_pool_t *p)
|
| |
{
|
| |
static const char * const aszPre[] = { "mod_include.c", NULL };
|
| |
- @@ -1964,6 +1795,7 @@ static void register_hook(apr_pool_t *p)
|
| |
+ @@ -1973,6 +1794,7 @@ static void register_hook(apr_pool_t *p)
|
| |
ap_hook_pre_config(cgid_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
|
| |
ap_hook_post_config(cgid_init, aszPre, NULL, APR_HOOK_MIDDLE);
|
| |
ap_hook_handler(cgid_handler, NULL, NULL, APR_HOOK_MIDDLE);
|
| |