Received: (qmail 21997 invoked by uid 501); 28 Aug 2001 19:37:16 -0000 Message-Id: <20010828193716.21994.qmail@apache.org> Date: 28 Aug 2001 19:37:16 -0000 From: David Sullivan Reply-To: sullivan@cs.uoregon.edu To: submit@bugz.apache.org Subject: per user error logs are useful X-Send-Pr-Version: 3.110 >Number: 8255 >Category: suexec >Synopsis: per user error logs are useful >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: apache >Arrival-Date: Tue Aug 28 12:40:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: sullivan@cs.uoregon.edu >Release: 1.3.19 >Organization: apache >Environment: SunOS sarcastix.cs.uoregon.edu 5.8 Generic_108528-08 sun4u sparc SUNW,Ultra-5_10 >Description: We've found that dealing with students, it's hard to get properly debugged code in CGI scripts, also to get them to redirect stderr on their own. So, we end up with confusing errorlogs. It makes life simpler to provide each user with their own log file, and point them to it when there are problems. >How-To-Repeat: run a few perl CGI scripts with -w, and try to interpret errorlog >Fix: --- suexec-old.c Tue Aug 21 15:20:48 2001 +++ suexec.c Tue Aug 21 18:07:33 2001 @@ -559,6 +559,33 @@ #endif /* SUEXEC_UMASK */ clean_env(); +#ifdef USER_LOGS + { +#include +#ifndef NULLP +#define NULLP (void *)0 +#endif + char filename[129]; + time_t timevar; + struct tm *lt; + + snprintf(filename, 128, "%s/%s.errlog", USER_LOGS, target_uname); + log_err("info: changing error log to %s\n", filename); + if (freopen(filename, "a", stderr) == NULLP) { + log_err("notice: unable to setup individual error log (%d) %s\n", + errno, strerror(errno)); + } else chmod(filename, S_IRUSR|S_IWUSR); + setbuf(stderr, NULLP); + + time(&timevar); + lt = localtime(&timevar); + + fprintf(stderr, "[%d-%.2d-%.2d %.2d:%.2d:%.2d]: %s\n", + lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, + lt->tm_hour, lt->tm_min, lt->tm_sec, cmd); + fflush(stderr); + } +#endif /* * Be sure to close the log file so the CGI can't * mess with it. If the exec fails, it will be reopened --- suexec-old.h Tue Aug 21 15:18:28 2001 +++ suexec.h Thu Aug 23 12:46:11 2001 @@ -141,4 +141,11 @@ #define SAFE_PATH "/usr/local/bin:/usr/bin:/bin" #endif +/* + * USER_LOGS -- Store individual user logs in this directory. Don't define + * to leave logs in normal error_log. + * + */ +/* #define USER_LOGS "/usr/local/shared/logs" */ + #endif /* _SUEXEC_H */ >Release-Note: >Audit-Trail: >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database automatically because of the potential for mail ] [loops. If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request from a ] [developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]