From 60007c82f10621acdbcd4d5f6522c6660aeba5c5 Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Mon, 19 Mar 2001 16:07:59 +0000 Subject: [PATCH] Fix a problem in mod_mime_magic where file descriptor 2 would be inadvertently closed. This logic was in the uncompress child in 1.3 but was in the parent in 2.0. uncompress_child() was renamed to create_uncompress_child() to reflect a change in use since 1.3. A note was added about missing 1.3 logic for doing something with the stderr of the uncompress process. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88538 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ modules/metadata/mod_mime_magic.c | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index b5b14d91c7..eb9a0dbe74 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.15-dev + *) Get rid of an inadvertent close of file descriptor 2 in + mod_mime_magic. [Greg Ames, Jeff Trawick] + *) Add a hook, create_request. This hook allows modules to modify a request while it is being created. This hook is called for all request_rec's, main request, sub request, and internal redirect. diff --git a/modules/metadata/mod_mime_magic.c b/modules/metadata/mod_mime_magic.c index 81b8ebce2c..36aa086918 100644 --- a/modules/metadata/mod_mime_magic.c +++ b/modules/metadata/mod_mime_magic.c @@ -2147,8 +2147,8 @@ struct uncompress_parms { int method; }; -static int uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt, - apr_file_t **pipe_in) +static int create_uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt, + apr_file_t **pipe_in) { int rc = 1; const char *new_argv[4]; @@ -2158,6 +2158,12 @@ static int uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt, apr_procattr_t *procattr; apr_proc_t *procnew; + /* XXX missing 1.3 logic: + * + * what happens when !compr[parm->method].silent? + * Should we create the err pipe, read it, and copy to the log? + */ + env = (const char *const *)ap_create_environment(child_context, r->subprocess_env); if ((apr_procattr_create(&procattr, child_context) != APR_SUCCESS) || @@ -2175,10 +2181,6 @@ static int uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt, new_argv[2] = r->filename; new_argv[3] = NULL; - if (compr[parm->method].silent) { - close(STDERR_FILENO); - } - procnew = apr_pcalloc(child_context, sizeof(*procnew)); rc = apr_proc_create(procnew, compr[parm->method].argv[0], new_argv, env, procattr, child_context); @@ -2216,7 +2218,7 @@ static int uncompress(request_rec *r, int method, if (apr_pool_create(&sub_context, r->pool) != APR_SUCCESS) return -1; - if ((rv = uncompress_child(&parm, sub_context, &pipe_out)) != APR_SUCCESS) { + if ((rv = create_uncompress_child(&parm, sub_context, &pipe_out)) != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, MODNAME ": couldn't spawn uncompress process: %s", r->uri); return -1; -- 2.40.0