]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
merge this from 2.1-dev:
authorJeff Trawick <trawick@apache.org>
Thu, 13 Nov 2003 18:33:42 +0000 (18:33 +0000)
committerJeff Trawick <trawick@apache.org>
Thu, 13 Nov 2003 18:33:42 +0000 (18:33 +0000)
  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

CHANGES
STATUS
modules/filters/mod_ext_filter.c
modules/generators/mod_cgi.c

diff --git a/CHANGES b/CHANGES
index 51203ed6eb13e5ab484607bbe34dbd951eba9473..000ca58fd5104f0f03c4fd90423c989d5c78b1c7 100644 (file)
--- 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 <aryeh secured-services.com>]
 
diff --git a/STATUS b/STATUS
index 83e0702dc5b5e8825b28a2b1ece608035abd63ee..3c32a94719b8c61eacd97210bc5658a450ad5405 100644 (file)
--- 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()
index c0a018dc79c5ff03e19007f5492fdccf1a976575..a680280de0cc2209eb4f06904b213c5f14cf7559 100644 (file)
@@ -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
index 3d9e1284b56100e3350566b7bdf013ef231084f5..01c1f245eb788be37b6a8a4e63319b1449e7c873 100644 (file)
@@ -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,