From: Jeff Trawick Date: Thu, 13 Nov 2003 18:33:42 +0000 (+0000) Subject: merge this from 2.1-dev: X-Git-Tag: 2.0.49~377 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20c2ac879aa4e00bd6bbc284a6d35fe16e1327d9;p=thirdparty%2Fapache%2Fhttpd.git merge this from 2.1-dev: Fix the inability to log errors like exec failure in mod_ext_filter/mod_cgi script children. This was broken after such children stopped inheriting the error log handle. Reviewed by: nd, jorton git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@101778 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 51203ed6eb1..000ca58fd51 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,10 @@ Changes with Apache 2.0.49 + *) Fix the inability to log errors like exec failure in + mod_ext_filter/mod_cgi script children. This was broken after + such children stopped inheriting the error log handle. + [Jeff Trawick] + *) Fix mod_info to use the real config file name, not the default config file name. [Aryeh Katz ] diff --git a/STATUS b/STATUS index 83e0702dc5b..3c32a94719b 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2003/11/13 18:04:16 $] +Last modified at [$Date: 2003/11/13 18:33:40 $] Release: @@ -262,13 +262,6 @@ PATCHES TO BACKPORT FROM 2.1 modules/ssl/ssl_engine_io.c r1.111 +1: jorton - * Fix the inability to log errors like exec failure in - mod_ext_filter/mod_cgi script children. This was broken after - such children stopped inheriting the error log handle. - modules/generators/mod_cgi.c r1.152 - modules/filters/mod_ext_filter.c r1.5 - +1: trawick, nd, jorton - * When UseCanonicalName is set to OFF, allow ap_get_server_port to check r->connection->local_addr->port before defaulting to server->port or ap_default_port() diff --git a/modules/filters/mod_ext_filter.c b/modules/filters/mod_ext_filter.c index c0a018dc79c..a680280de0c 100644 --- a/modules/filters/mod_ext_filter.c +++ b/modules/filters/mod_ext_filter.c @@ -69,6 +69,7 @@ #include "apr_buckets.h" #include "util_filter.h" #include "util_script.h" +#include "util_time.h" #include "apr_strings.h" #include "apr_hash.h" #include "apr_lib.h" @@ -423,15 +424,25 @@ static apr_status_t ef_close_file(void *vfile) return apr_file_close(vfile); } -static void child_errfn(apr_pool_t *p, apr_status_t err, const char *desc) +static void child_errfn(apr_pool_t *pool, apr_status_t err, const char *description) { request_rec *r; void *vr; + apr_file_t *stderr_log; + char errbuf[200]; + char time_str[APR_CTIME_LEN]; - apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, p); + apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, pool); r = vr; - - ap_log_rerror(APLOG_MARK, APLOG_ERR, err, r, "%s", desc); + apr_file_open_stderr(&stderr_log, pool); + ap_recent_ctime(time_str, apr_time_now()); + apr_file_printf(stderr_log, + "[%s] [client %s] mod_ext_filter (%d)%s: %s\n", + time_str, + r->connection->remote_ip, + err, + apr_strerror(err, errbuf, sizeof(errbuf)), + description); } /* init_ext_filter_process: get the external filter process going diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index 3d9e1284b56..01c1f245eb7 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -122,8 +122,6 @@ static int is_scriptaliased(request_rec *r) #define DEFAULT_LOGBYTES 10385760 #define DEFAULT_BUFBYTES 1024 -#define ERRFN_USERDATA_KEY "CGICHILDERRFN" - typedef struct { const char *logname; long logbytes; @@ -385,13 +383,15 @@ static void add_ssi_vars(request_rec *r) static void cgi_child_errfn(apr_pool_t *pool, apr_status_t err, const char *description) { - request_rec *r; - void *vr; - - apr_pool_userdata_get(&vr, ERRFN_USERDATA_KEY, pool); - r = vr; - - ap_log_rerror(APLOG_MARK, APLOG_ERR, err, r, "%s", description); + apr_file_t *stderr_log; + char errbuf[200]; + + apr_file_open_stderr(&stderr_log, pool); + apr_file_printf(stderr_log, + "(%d)%s: %s\n", + err, + apr_strerror(err, errbuf, sizeof(errbuf)), + description); } static apr_status_t run_cgi_child(apr_file_t **script_out, @@ -473,8 +473,6 @@ static apr_status_t run_cgi_child(apr_file_t **script_out, "couldn't set child process attributes: %s", r->filename); } else { - apr_pool_userdata_set(r, ERRFN_USERDATA_KEY, apr_pool_cleanup_null, p); - procnew = apr_pcalloc(p, sizeof(*procnew)); if (e_info->prog_type == RUN_AS_SSI) { SPLIT_AND_PASS_PRETAG_BUCKETS(*(e_info->bb), e_info->ctx,