Return-Path: Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 28959 invoked by uid 500); 23 Apr 2003 15:09:06 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 28942 invoked from network); 23 Apr 2003 15:09:05 -0000 Date: Wed, 23 Apr 2003 17:07:22 +0200 From: Christian Brunner To: dev@httpd.apache.org Subject: [PATCH] mod_cgi and logging Message-ID: <20030423150722.GC12816@sir.home> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0OAP2g/MAC+5xKAE" Content-Disposition: inline User-Agent: Mutt/1.4i X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline We have discovered two minor issues with CGIs sending debugging information to STDERR: 1. When the CGI sends a "Location" header with an absolute URL the output isn't stored in the ErrorLog logfile. log_script_err() is missing in this case. 2. If the last line of STDERR output isn't terminated by '\n' the line isn't stored either. log_script_err() or ap_log_rerror() are not called when the return code of apr_file_gets() is APR_EOF. A patch to fix these issues is attached. Christian -- SpaceNet AG Web : http://www.space.net/ Joseph-Dollinger-Bogen 14 Tel : +49-89-32356-0 80807 Muenchen Fax : +49-89-32356-299 --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="httpd-2.0.45-cgi-errorlog.patch" --- httpd-2.0.45/modules/generators/mod_cgi.c.cgi-errorlog 2003-02-27 13:33:07.000000000 +0100 +++ httpd-2.0.45/modules/generators/mod_cgi.c 2003-04-23 12:53:48.000000000 +0200 @@ -240,15 +240,22 @@ { char argsbuffer[HUGE_STRING_LEN]; char *newline; + apr_status_t gstat; - while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, - script_err) == APR_SUCCESS) { + for(;;) { + gstat = apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err); + if ((gstat != APR_SUCCESS) && (gstat != APR_EOF)) { + break; + } newline = strchr(argsbuffer, '\n'); if (newline) { *newline = '\0'; } ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "%s", argsbuffer); + if (gstat == APR_EOF) { + break; + } } } @@ -263,7 +270,7 @@ apr_bucket *e; const char *buf; apr_size_t len; - apr_status_t rv; + apr_status_t rv, gstat; int first; int i; apr_finfo_t finfo; @@ -334,9 +341,15 @@ if (apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err) == APR_SUCCESS) { apr_file_puts("%stderr\n", f); apr_file_puts(argsbuffer, f); - while (apr_file_gets(argsbuffer, HUGE_STRING_LEN, - script_err) == APR_SUCCESS) { + for(;;) { + gstat = apr_file_gets(argsbuffer, HUGE_STRING_LEN, script_err); + if ((gstat != APR_SUCCESS) && (gstat != APR_EOF)) { + break; + } apr_file_puts(argsbuffer, f); + if (gstat == APR_EOF) { + break; + } } apr_file_puts("\n", f); } @@ -796,6 +809,7 @@ /* XX Note that if a script wants to produce its own Redirect * body, it now has to explicitly *say* "Status: 302" */ + log_script_err(r, script_err); discard_script_output(bb); apr_brigade_destroy(bb); return HTTP_MOVED_TEMPORARILY; --0OAP2g/MAC+5xKAE--