|
|
331623 |
--- a/modules/generators/mod_cgid.c 2014/07/14 20:16:45 1610511
|
|
|
331623 |
+++ b/modules/generators/mod_cgid.c 2014/07/14 20:18:26 1610512
|
|
|
331623 |
@@ -97,6 +97,10 @@
|
|
|
331623 |
static pid_t parent_pid;
|
|
|
331623 |
static ap_unix_identity_t empty_ugid = { (uid_t)-1, (gid_t)-1, -1 };
|
|
|
331623 |
|
|
|
331623 |
+typedef struct {
|
|
|
331623 |
+ apr_interval_time_t timeout;
|
|
|
331623 |
+} cgid_dirconf;
|
|
|
331623 |
+
|
|
|
331623 |
/* The APR other-child API doesn't tell us how the daemon exited
|
|
|
331623 |
* (SIGSEGV vs. exit(1)). The other-child maintenance function
|
|
|
331623 |
* needs to decide whether to restart the daemon after a failure
|
|
|
331623 |
@@ -968,7 +972,14 @@
|
|
|
331623 |
return overrides->logname ? overrides : base;
|
|
|
331623 |
}
|
|
|
331623 |
|
|
|
331623 |
+static void *create_cgid_dirconf(apr_pool_t *p, char *dummy)
|
|
|
331623 |
+{
|
|
|
331623 |
+ cgid_dirconf *c = (cgid_dirconf *) apr_pcalloc(p, sizeof(cgid_dirconf));
|
|
|
331623 |
+ return c;
|
|
|
331623 |
+}
|
|
|
331623 |
+
|
|
|
331623 |
static const char *set_scriptlog(cmd_parms *cmd, void *dummy, const char *arg)
|
|
|
331623 |
+
|
|
|
331623 |
{
|
|
|
331623 |
server_rec *s = cmd->server;
|
|
|
331623 |
cgid_server_conf *conf = ap_get_module_config(s->module_config,
|
|
|
331623 |
@@ -1021,7 +1032,16 @@
|
|
|
331623 |
|
|
|
331623 |
return NULL;
|
|
|
331623 |
}
|
|
|
331623 |
+static const char *set_script_timeout(cmd_parms *cmd, void *dummy, const char *arg)
|
|
|
331623 |
+{
|
|
|
331623 |
+ cgid_dirconf *dc = dummy;
|
|
|
331623 |
|
|
|
331623 |
+ if (ap_timeout_parameter_parse(arg, &dc->timeout, "s") != APR_SUCCESS) {
|
|
|
331623 |
+ return "CGIDScriptTimeout has wrong format";
|
|
|
331623 |
+ }
|
|
|
331623 |
+
|
|
|
331623 |
+ return NULL;
|
|
|
331623 |
+}
|
|
|
331623 |
static const command_rec cgid_cmds[] =
|
|
|
331623 |
{
|
|
|
331623 |
AP_INIT_TAKE1("ScriptLog", set_scriptlog, NULL, RSRC_CONF,
|
|
|
331623 |
@@ -1033,6 +1053,10 @@
|
|
|
331623 |
AP_INIT_TAKE1("ScriptSock", set_script_socket, NULL, RSRC_CONF,
|
|
|
331623 |
"the name of the socket to use for communication with "
|
|
|
331623 |
"the cgi daemon."),
|
|
|
331623 |
+ AP_INIT_TAKE1("CGIDScriptTimeout", set_script_timeout, NULL, RSRC_CONF | ACCESS_CONF,
|
|
|
331623 |
+ "The amount of time to wait between successful reads from "
|
|
|
331623 |
+ "the CGI script, in seconds."),
|
|
|
331623 |
+
|
|
|
331623 |
{NULL}
|
|
|
331623 |
};
|
|
|
331623 |
|
|
|
331623 |
@@ -1356,12 +1380,16 @@
|
|
|
331623 |
apr_file_t *tempsock;
|
|
|
331623 |
struct cleanup_script_info *info;
|
|
|
331623 |
apr_status_t rv;
|
|
|
331623 |
+ cgid_dirconf *dc;
|
|
|
331623 |
|
|
|
331623 |
if (strcmp(r->handler, CGI_MAGIC_TYPE) && strcmp(r->handler, "cgi-script")) {
|
|
|
331623 |
return DECLINED;
|
|
|
331623 |
}
|
|
|
331623 |
|
|
|
331623 |
conf = ap_get_module_config(r->server->module_config, &cgid_module);
|
|
|
331623 |
+ dc = ap_get_module_config(r->per_dir_config, &cgid_module);
|
|
|
331623 |
+
|
|
|
331623 |
+
|
|
|
331623 |
is_included = !strcmp(r->protocol, "INCLUDED");
|
|
|
331623 |
|
|
|
331623 |
if ((argv0 = strrchr(r->filename, '/')) != NULL) {
|
|
|
331623 |
@@ -1441,6 +1469,12 @@
|
|
|
331623 |
*/
|
|
|
331623 |
|
|
|
331623 |
apr_os_pipe_put_ex(&tempsock, &sd, 1, r->pool);
|
|
|
331623 |
+ if (dc->timeout > 0) {
|
|
|
331623 |
+ apr_file_pipe_timeout_set(tempsock, dc->timeout);
|
|
|
331623 |
+ }
|
|
|
331623 |
+ else {
|
|
|
331623 |
+ apr_file_pipe_timeout_set(tempsock, r->server->timeout);
|
|
|
331623 |
+ }
|
|
|
331623 |
apr_pool_cleanup_kill(r->pool, (void *)((long)sd), close_unix_socket);
|
|
|
331623 |
|
|
|
331623 |
/* Transfer any put/post args, CERN style...
|
|
|
331623 |
@@ -1517,6 +1551,10 @@
|
|
|
331623 |
if (rv != APR_SUCCESS) {
|
|
|
331623 |
/* silly script stopped reading, soak up remaining message */
|
|
|
331623 |
child_stopped_reading = 1;
|
|
|
331623 |
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(02651)
|
|
|
331623 |
+ "Error writing request body to script %s",
|
|
|
331623 |
+ r->filename);
|
|
|
331623 |
+
|
|
|
331623 |
}
|
|
|
331623 |
}
|
|
|
331623 |
apr_brigade_cleanup(bb);
|
|
|
331623 |
@@ -1610,7 +1648,13 @@
|
|
|
331623 |
return HTTP_MOVED_TEMPORARILY;
|
|
|
331623 |
}
|
|
|
331623 |
|
|
|
331623 |
- ap_pass_brigade(r->output_filters, bb);
|
|
|
331623 |
+ rv = ap_pass_brigade(r->output_filters, bb);
|
|
|
331623 |
+ if (rv != APR_SUCCESS) {
|
|
|
331623 |
+ /* APLOG_ERR because the core output filter message is at error,
|
|
|
331623 |
+ * but doesn't know it's passing CGI output
|
|
|
331623 |
+ */
|
|
|
331623 |
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(02550) "Failed to flush CGI output to client");
|
|
|
331623 |
+ }
|
|
|
331623 |
}
|
|
|
331623 |
|
|
|
331623 |
if (nph) {
|
|
|
331623 |
@@ -1741,6 +1785,8 @@
|
|
|
331623 |
request_rec *r = f->r;
|
|
|
331623 |
cgid_server_conf *conf = ap_get_module_config(r->server->module_config,
|
|
|
331623 |
&cgid_module);
|
|
|
331623 |
+ cgid_dirconf *dc = ap_get_module_config(r->per_dir_config, &cgid_module);
|
|
|
331623 |
+
|
|
|
331623 |
struct cleanup_script_info *info;
|
|
|
331623 |
|
|
|
331623 |
add_ssi_vars(r);
|
|
|
331623 |
@@ -1770,6 +1816,13 @@
|
|
|
331623 |
* get rid of the cleanup we registered when we created the socket.
|
|
|
331623 |
*/
|
|
|
331623 |
apr_os_pipe_put_ex(&tempsock, &sd, 1, r->pool);
|
|
|
331623 |
+ if (dc->timeout > 0) {
|
|
|
331623 |
+ apr_file_pipe_timeout_set(tempsock, dc->timeout);
|
|
|
331623 |
+ }
|
|
|
331623 |
+ else {
|
|
|
331623 |
+ apr_file_pipe_timeout_set(tempsock, r->server->timeout);
|
|
|
331623 |
+ }
|
|
|
331623 |
+
|
|
|
331623 |
apr_pool_cleanup_kill(r->pool, (void *)((long)sd), close_unix_socket);
|
|
|
331623 |
|
|
|
331623 |
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pipe_create(tempsock,
|
|
|
331623 |
@@ -1875,7 +1928,7 @@
|
|
|
331623 |
|
|
|
331623 |
AP_DECLARE_MODULE(cgid) = {
|
|
|
331623 |
STANDARD20_MODULE_STUFF,
|
|
|
331623 |
- NULL, /* dir config creater */
|
|
|
331623 |
+ create_cgid_dirconf, /* dir config creater */
|
|
|
331623 |
NULL, /* dir merger --- default is to override */
|
|
|
331623 |
create_cgid_config, /* server config */
|
|
|
331623 |
merge_cgid_config, /* merge server config */
|