cvs commit: apache-1.3/src/main http_log.c
martin 00/01/31 14:24:29 Modified:src/main http_log.c Log: Enforce a sensible umask value, even when a stupid default was in effect. (Noticed by Frank Miller, Patch by Martin Kraemer) Submitted by: Frank Miller <[EMAIL PROTECTED]> Reviewed by: Martin Kraemer Revision ChangesPath 1.82 +10 -0 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -r1.81 -r1.82 --- http_log.c1999/10/21 20:44:38 1.81 +++ http_log.c2000/01/31 22:24:07 1.82 @@ -498,6 +498,9 @@ struct stat finfo; static pid_t saved_pid = -1; pid_t mypid; +#ifndef WIN32 +mode_t u; +#endif if (!fname) return; @@ -519,12 +522,19 @@ ); } +#ifndef WIN32 +u = umask(022); +(void) umask(u | 022); +#endif if(!(pid_file = fopen(fname, "w"))) { perror("fopen"); fprintf(stderr, "%s: could not log pid to file %s\n", ap_server_argv0, fname); exit(1); } +#ifndef WIN32 +(void) umask(u); +#endif fprintf(pid_file, "%ld\n", (long)mypid); fclose(pid_file); saved_pid = mypid;
cvs commit: apache-1.3/src/main http_log.c
bjh 99/05/30 01:55:30 Modified:src/main http_log.c Log: Fix piped logs under OS/2 Revision ChangesPath 1.78 +8 -4 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.77 retrieving revision 1.78 diff -u -r1.77 -r1.78 --- http_log.c1999/04/27 20:36:31 1.77 +++ http_log.c1999/05/30 08:55:29 1.78 @@ -172,8 +172,10 @@ child_pid = spawnl(_P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); return(child_pid); #elif defined(OS2) -/* For OS/2 we need to use a '/' */ -execl(SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); +/* For OS/2 we need to use a '/' and spawn the child rather than exec as + * we haven't forked */ +child_pid = spawnl(P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); +return(child_pid); #else execl(SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL); #endif @@ -727,8 +729,10 @@ child_pid = spawnl(_P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); return(child_pid); #elif defined(OS2) -/* For OS/2 we need to use a '/' */ -execl (SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); +/* For OS/2 we need to use a '/' and spawn the child rather than exec as + * we haven't forked */ +child_pid = spawnl(P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); +return(child_pid); #else execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL); #endif
cvs commit: apache-1.3/src/main http_log.c
dgaudet 99/03/11 08:52:39 Modified:src/main http_log.c Log: remove the extra "httpd: " logged for each error message Reviewed by: Marc Slemko, Ralf S. Engelschall Revision ChangesPath 1.76 +1 -2 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- http_log.c1999/01/01 19:04:48 1.75 +++ http_log.c1999/03/11 16:52:38 1.76 @@ -322,8 +322,7 @@ } if (logf) { - len = ap_snprintf(errstr, sizeof(errstr), "%s: [%s] ", - ap_server_argv0, ap_get_time()); + len = ap_snprintf(errstr, sizeof(errstr), "[%s] ", ap_get_time()); } else { len = 0; }
cvs commit: apache-1.3/src/main http_log.c
marc98/10/22 17:34:21 Modified:src/main http_log.c Log: apache --> Apache in log message. Revision ChangesPath 1.73 +1 -1 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- http_log.c1998/10/03 14:28:55 1.72 +++ http_log.c1998/10/23 00:34:20 1.73 @@ -481,7 +481,7 @@ */ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, ap_psprintf(p, -"pid file %s overwritten -- Unclean shutdown of previous apache run?", +"pid file %s overwritten -- Unclean shutdown of previous Apache run?", fname) ); }
cvs commit: apache-1.3/src/main http_log.c
rse 98/10/03 07:28:56 Modified:src/main http_log.c Log: The second part of the patch from Youichirou Koga <[EMAIL PROTECTED]> (PR#3095). These are now only coding style fixups, because the bugfix parts I've already extracted and committed separately. Revision ChangesPath 1.72 +89 -86apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- http_log.c1998/10/03 14:07:08 1.71 +++ http_log.c1998/10/03 14:28:55 1.72 @@ -154,7 +154,7 @@ {NULL, -1}, }; -static int error_log_child (void *cmd, child_info *pinfo) +static int error_log_child(void *cmd, child_info *pinfo) { /* Child process code for 'ErrorLog "|..."'; * may want a common framework for this, since I expect it will @@ -165,23 +165,23 @@ ap_cleanup_for_exec(); #ifdef SIGHUP /* No concept of a child process on Win32 */ -signal (SIGHUP, SIG_IGN); +signal(SIGHUP, SIG_IGN); #endif /* ndef SIGHUP */ #if defined(WIN32) -child_pid = spawnl (_P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); +child_pid = spawnl(_P_NOWAIT, SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); return(child_pid); #elif defined(OS2) /* For OS/2 we need to use a '/' */ -execl (SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); +execl(SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); #else -execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL); +execl(SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL); #endif -exit (1); +exit(1); /* NOT REACHED */ return(child_pid); } -static void open_error_log (server_rec *s, pool *p) +static void open_error_log(server_rec *s, pool *p) { char *fname; @@ -190,9 +190,9 @@ if (!ap_spawn_child(p, error_log_child, (void *)(s->error_fname+1), kill_after_timeout, &dummy, NULL, NULL)) { - perror ("ap_spawn_child"); - fprintf (stderr, "Couldn't fork child for ErrorLog process\n"); - exit (1); + perror("ap_spawn_child"); + fprintf(stderr, "Couldn't fork child for ErrorLog process\n"); + exit(1); } s->error_log = dummy; @@ -219,8 +219,8 @@ } #endif else { - fname = ap_server_root_relative (p, s->error_fname); -if(!(s->error_log = ap_pfopen(p, fname, "a"))) { + fname = ap_server_root_relative(p, s->error_fname); +if (!(s->error_log = ap_pfopen(p, fname, "a"))) { perror("fopen"); fprintf(stderr,"httpd: could not open error log file %s.\n", fname); exit(1); @@ -228,12 +228,12 @@ } } -void ap_open_logs (server_rec *s_main, pool *p) +void ap_open_logs(server_rec *s_main, pool *p) { server_rec *virt, *q; int replace_stderr; -open_error_log (s_main, p); +open_error_log(s_main, p); replace_stderr = 1; if (s_main->error_log) { @@ -262,21 +262,23 @@ if (q->error_fname != NULL && strcmp(q->error_fname, virt->error_fname) == 0) break; - if (q == virt) open_error_log (virt, p); - else virt->error_log = q->error_log; + if (q == virt) + open_error_log(virt, p); + else + virt->error_log = q->error_log; } else virt->error_log = s_main->error_log; } } -API_EXPORT(void) ap_error_log2stderr (server_rec *s) { +API_EXPORT(void) ap_error_log2stderr(server_rec *s) { if ( s->error_log != NULL && fileno(s->error_log) != STDERR_FILENO) dup2(fileno(s->error_log), STDERR_FILENO); } -static void log_error_core (const char *file, int line, int level, +static void log_error_core(const char *file, int line, int level, const server_rec *s, const request_rec *r, const char *fmt, va_list args) { @@ -424,7 +426,7 @@ #endif } -API_EXPORT(void) ap_log_error (const char *file, int line, int level, +API_EXPORT(void) ap_log_error(const char *file, int line, int level, const server_rec *s, const char *fmt, ...) { va_list args; @@ -457,18 +459,19 @@ va_end(args); } -void ap_log_pid (pool *p, char *fname) +void ap_log_pid(pool *p, char *fname) { FILE *pid_file; struct stat finfo; static pid_t saved_pid = -1; pid_t mypid; -if (!fname) return; +if (!fname) + return; -fname = ap_server_root_relative (p, fname); +fname = ap_server_roo
cvs commit: apache-1.3/src/main http_log.c
rse 98/10/03 07:07:09 Modified:src CHANGES src/main http_log.c Log: Fix stderr redirection under syslog-based error logging situation. PS: This is actually an extracted sub-patch of a large patch which contains lots of style changes, too. The style changes I'll commit in a second round (I don't want to commit the stuff mixed together). Only one change (2->STDERR_FILENO) is committed also now, because it's more like a bugfix. Submitted by: Youichirou Koga <[EMAIL PROTECTED]> PR: 3095 Revision ChangesPath 1.1092+3 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1091 retrieving revision 1.1092 diff -u -r1.1091 -r1.1092 --- CHANGES 1998/10/03 13:38:29 1.1091 +++ CHANGES 1998/10/03 14:07:07 1.1092 @@ -1,5 +1,8 @@ Changes with Apache 1.3.3 + *) Fix stderr redirection under syslog-based error logging situation. + [Youichirou Koga <[EMAIL PROTECTED]>] PR#3095 + *) Document `ErrorLog syslog:facility' variant of error logging. [Youichirou Koga <[EMAIL PROTECTED]>] PR#3096 1.71 +4 -3 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- http_log.c1998/09/25 12:27:05 1.70 +++ http_log.c1998/10/03 14:07:08 1.71 @@ -239,7 +239,7 @@ if (s_main->error_log) { /* replace stderr with this new log */ fflush(stderr); - if (dup2(fileno(s_main->error_log), 2) == -1) { + if (dup2(fileno(s_main->error_log), STDERR_FILENO) == -1) { ap_log_error(APLOG_MARK, APLOG_CRIT, s_main, "unable to replace stderr with error_log"); } else { @@ -271,8 +271,9 @@ } API_EXPORT(void) ap_error_log2stderr (server_rec *s) { -if(fileno(s->error_log) != STDERR_FILENO) -dup2(fileno(s->error_log),STDERR_FILENO); +if ( s->error_log != NULL +&& fileno(s->error_log) != STDERR_FILENO) +dup2(fileno(s->error_log), STDERR_FILENO); } static void log_error_core (const char *file, int line, int level,
cvs commit: apache-1.3/src/main http_log.c http_protocol.c
coar98/09/25 05:27:06 Modified:.STATUS src/main http_log.c http_protocol.c Log: Put back the default server status pages, with no inclusion of error-notes, except for HTTP_INTERNAL_SERVER_ERROR, LENGTH_REQUIRED, and HTTP_BAD_REQUEST. Also only store ap_log_rerror() text in error-notes if the severity is 'warning' or worse. PR: 3071 Reviewed by: Roy Fielding Revision ChangesPath 1.493 +0 -10 apache-1.3/STATUS Index: STATUS === RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.492 retrieving revision 1.493 diff -u -r1.492 -r1.493 --- STATUS1998/09/24 22:01:08 1.492 +++ STATUS1998/09/25 12:27:04 1.493 @@ -25,16 +25,6 @@ Available Patches: -* Ken's fix for error pages and error-notes (#2) - Take references to error-notes out of ap_send_error_response() - except for internal HTTP_BAD_REQUEST uses. Otherwise, - leave its use for page customisation to ErrorDocuments. - Only copy ap_log_rerror() text into error-notes if the - level is 'warning' or more severe AND there's not already - something stored there. - Message-ID: <[EMAIL PROTECTED]> - Status: Ken +1 - * Earle Ake: Apache 1.3.1 port to Pyramid DC/OSx <[EMAIL PROTECTED]> 1.70 +11 -2 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- http_log.c1998/09/22 15:43:42 1.69 +++ http_log.c1998/09/25 12:27:05 1.70 @@ -440,9 +440,18 @@ va_start(args, fmt); log_error_core(file, line, level, r->server, r, fmt, args); -if (ap_table_get(r->notes, "error-notes") == NULL) { +/* + * IF the error level is 'warning' or more severe, + * AND there isn't already error text associated with this request, + * THEN make the message text available to ErrorDocument and + * other error processors. This can be disabled by stuffing + * something, even an empty string, into the "error-notes" cell + * before calling this routine. + */ +if (((level & APLOG_LEVELMASK) <= APLOG_WARNING) + && (ap_table_get(r->notes, "error-notes") == NULL)) { ap_table_setn(r->notes, "error-notes", - ap_pvsprintf(r->pool, fmt, args)); + ap_pvsprintf(r->pool, fmt, args)); } va_end(args); } 1.240 +141 -126 apache-1.3/src/main/http_protocol.c Index: http_protocol.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_protocol.c,v retrieving revision 1.239 retrieving revision 1.240 diff -u -r1.239 -r1.240 --- http_protocol.c 1998/08/25 09:15:31 1.239 +++ http_protocol.c 1998/09/25 12:27:05 1.240 @@ -2127,132 +2127,147 @@ "\n\n", h1, "\n", NULL); -if ((error_notes = ap_table_get(r->notes, "error-notes"))) { -ap_bputs(error_notes, fd); -} -else -switch (status) { -case REDIRECT: -case MOVED: -ap_bvputs(fd, "The document has moved pool, location), "\">here.\n", NULL); -break; -case HTTP_SEE_OTHER: -ap_bvputs(fd, "The answer to your request is located pool, location), "\">here.\n", NULL); -break; -case HTTP_USE_PROXY: -ap_bvputs(fd, "This resource is only accessible through the proxy\n", -ap_escape_html(r->pool, location), "\nYou will need to ", - "configure your client to use that proxy.\n", NULL); -break; -case HTTP_PROXY_AUTHENTICATION_REQUIRED: -case AUTH_REQUIRED: -ap_bputs("This server could not verify that you\n", fd); -ap_bputs("are authorized to access the document you\n", fd); -ap_bputs("requested. Either you supplied the wrong\n", fd); -ap_bputs("credentials (e.g., bad password), or your\n", fd); -ap_bputs("browser doesn't understand how to supply\n", fd); -ap_bputs("the credentials required.\n", fd); -break; -case BAD_REQUEST: -ap_bputs("Your browser sent a request that\n", fd); -ap_bputs("this server could not understand.\n", fd); -break; -case HTTP_FORBIDDEN: -ap_bvputs(fd, "You don't have permission to access ", -
cvs commit: apache-1.3/src/main http_log.c
dgaudet 98/09/22 08:43:43 Modified:src/main http_log.c Log: ap_table_set() causes an ap_pstrdup() of both arguments, one of the arguments is a constant and it's a waste to pstrdup it. Furthermore using a static local buffer means there is a static limit to the message length. Also, ap_pvsprintf() can get away with zero-copies of the output in most cases, whereas ap_pstrdup() always copies the output at least once. Unlike Ken's claim there's no "gyration" required by ap_pv?sprintf() to figure out the string length. Clean this all up. Revision ChangesPath 1.69 +2 -4 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- http_log.c1998/09/21 17:29:45 1.68 +++ http_log.c1998/09/22 15:43:42 1.69 @@ -441,10 +441,8 @@ va_start(args, fmt); log_error_core(file, line, level, r->server, r, fmt, args); if (ap_table_get(r->notes, "error-notes") == NULL) { - char errstr[MAX_STRING_LEN]; - - ap_vsnprintf(errstr, sizeof(errstr), fmt, args); - ap_table_set(r->notes, "error-notes", errstr); + ap_table_setn(r->notes, "error-notes", + ap_pvsprintf(r->pool, fmt, args)); } va_end(args); }
cvs commit: apache-1.3/src/main http_log.c
rse 98/09/21 10:29:46 Modified:src/main http_log.c Log: I knew it: It's always best to think about a patch one hour more. After I again and again read the patch (because I wanted to make sure we don't break anything just before release), I find out: _both_ ap_snprintf and ap_psprintf are wrong in the context. Because "args" is a va_list and _CANNOT_ be used safely for ap_snprintf and therefore not for ap_psprintf, too. But (pu) we have ap_vsnprintf in our libap, so use this... So, we fix two things here: 1. The logic of the if-clause 2. The string creating itself Revision ChangesPath 1.68 +2 -2 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- http_log.c1998/09/18 04:29:07 1.67 +++ http_log.c1998/09/21 17:29:45 1.68 @@ -440,10 +440,10 @@ va_start(args, fmt); log_error_core(file, line, level, r->server, r, fmt, args); -if (ap_table_get(r->notes, "error-notes") != NULL) { +if (ap_table_get(r->notes, "error-notes") == NULL) { char errstr[MAX_STRING_LEN]; - ap_snprintf(errstr, sizeof(errstr), fmt, args); + ap_vsnprintf(errstr, sizeof(errstr), fmt, args); ap_table_set(r->notes, "error-notes", errstr); } va_end(args);
cvs commit: apache-1.3/src/main http_log.c
coar98/09/17 21:29:08 Modified:.STATUS src CHANGES src/main http_log.c Log: In ap_log_rerror(), set the "error-notes" special entry in r->notes to the error message, unless it's already set to something else. This makes the actual error available to ErrorDocument scripts and the like, while allowing it to be overridden by storing a "" value in that entry. Reviewed by: Doug MacEachern Revision ChangesPath 1.469 +0 -6 apache-1.3/STATUS Index: STATUS === RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.468 retrieving revision 1.469 diff -u -r1.468 -r1.469 --- STATUS1998/09/17 16:30:46 1.468 +++ STATUS1998/09/18 04:29:05 1.469 @@ -63,12 +63,6 @@ Available Patches: -* Ken's patch to set *ERROR_NOTES by default in ap_log_rerror() - Avoids special-casing the setting everywhere, and allows sensitive - error_log-only messages to be kept out of *ERROR_NOTES. - Message-ID: <[EMAIL PROTECTED]> - Status: Ken +1, Doug +1 - * Patches for the DSO/mod_perl problem (see below for description): Doug MacEachern's "[PATCH] fix for dso/mod_perl" 1.1068+3 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1067 retrieving revision 1.1068 diff -u -r1.1067 -r1.1068 --- CHANGES 1998/09/17 20:23:47 1.1067 +++ CHANGES 1998/09/18 04:29:06 1.1068 @@ -1,5 +1,8 @@ Changes with Apache 1.3.2 + *) When using ap_log_rerror(), make the error message available to the + *ERROR_NOTES envariables by default. [Ken Coar] + *) BS2000 platform only: get rid of the nasty BS2000AuthFile. You now must define a BS2000Account name for the server User. This has fewer security implications than the old approach. 1.67 +8 -2 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- http_log.c1998/09/15 00:15:18 1.66 +++ http_log.c1998/09/18 04:29:07 1.67 @@ -433,13 +433,19 @@ va_end(args); } -API_EXPORT(void) ap_log_rerror (const char *file, int line, int level, - const request_rec *r, const char *fmt, ...) +API_EXPORT(void) ap_log_rerror(const char *file, int line, int level, +const request_rec *r, const char *fmt, ...) { va_list args; va_start(args, fmt); log_error_core(file, line, level, r->server, r, fmt, args); +if (ap_table_get(r->notes, "error-notes") != NULL) { + char errstr[MAX_STRING_LEN]; + + ap_snprintf(errstr, sizeof(errstr), fmt, args); + ap_table_set(r->notes, "error-notes", errstr); +} va_end(args); }
cvs commit: apache-1.3/src/main http_log.c http_main.c
martin 98/09/14 17:15:20 Modified:src CHANGES src/main http_log.c http_main.c Log: When the server shuts down cleanly, it also removes the httpd.pid PID file. This avoids the problem that apachectl cannot decide whether a "kill -0 pid" failed because of permissions (or system restrictions) or because the pid doesn't exist. Upon startup, an info msg is logged if an old PID file remains. PR: 2947 Submitted by: Charles Randall <[EMAIL PROTECTED]> Reviewed by: Martin Kraemer, Dean Gaudet Revision ChangesPath 1.1058+3 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1057 retrieving revision 1.1058 diff -u -r1.1057 -r1.1058 --- CHANGES 1998/09/12 11:26:00 1.1057 +++ CHANGES 1998/09/15 00:15:16 1.1058 @@ -1,5 +1,8 @@ Changes with Apache 1.3.2 + *) Delete PID file on clean shutdowns. + [Charles Randall <[EMAIL PROTECTED]>] PR#2947 + *) Fix mod_auth_*.html documents: NSCA -> NCSA [Youichirou Koga <[EMAIL PROTECTED]>] PR#2991 1.66 +22 -1 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- http_log.c1998/09/10 06:58:19 1.65 +++ http_log.c1998/09/15 00:15:18 1.66 @@ -446,16 +446,37 @@ void ap_log_pid (pool *p, char *fname) { FILE *pid_file; +struct stat finfo; +static pid_t saved_pid = -1; +pid_t mypid; if (!fname) return; + fname = ap_server_root_relative (p, fname); +mypid = getpid(); +if (mypid != saved_pid && stat(fname,&finfo) == 0) { + /* USR1 and HUP call this on each restart. + * Only warn on first time through for this pid. + * + * XXX: Could just write first time through too, although + * that may screw up scripts written to do something + * based on the last modification time of the pid file. + */ + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, +ap_psprintf(p, +"pid file %s overwritten -- Unclean shutdown of previous apache run?", +fname) +); +} + if(!(pid_file = fopen(fname,"w"))) { perror("fopen"); fprintf(stderr,"httpd: could not log pid to file %s\n", fname); exit(1); } -fprintf(pid_file,"%ld\n",(long)getpid()); +fprintf(pid_file,"%ld\n",(long)mypid); fclose(pid_file); +saved_pid = mypid; } API_EXPORT(void) ap_log_error_old (const char *err, server_rec *s) 1.390 +11 -1 apache-1.3/src/main/http_main.c Index: http_main.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v retrieving revision 1.389 retrieving revision 1.390 diff -u -r1.389 -r1.390 --- http_main.c 1998/09/10 17:38:00 1.389 +++ http_main.c 1998/09/15 00:15:19 1.390 @@ -4288,9 +4288,19 @@ ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGTERM"); } reclaim_child_processes(1); /* Start with SIGTERM */ + + /* cleanup pid file on normal shutdown */ + { + const char *pidfile = NULL; + pidfile = ap_server_root_relative (pconf, ap_pid_fname); + if ( pidfile != NULL && unlink(pidfile) == 0) + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf, + "httpd: removed PID file %s (pid=%d)", + pidfile, getpid()); + } + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, "httpd: caught SIGTERM, shutting down"); - clean_parent_exit(0); }
cvs commit: apache-1.3/src/main http_log.c
rse 98/09/09 23:58:19 Modified:src CHANGES src/main http_log.c Log: Fix the ap_log_error_old(), ap_log_unixerr() and ap_log_printf() functions: First all three functions no longer fail on strings containing "%" chars and second ap_log_printf() no longer does a double-formatting (instead it directly passes through the message to be formatted to the real internal formatting function). PR: 2941 Revision ChangesPath 1.1049+6 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1048 retrieving revision 1.1049 diff -u -r1.1048 -r1.1049 --- CHANGES 1998/09/09 22:05:23 1.1048 +++ CHANGES 1998/09/10 06:58:17 1.1049 @@ -1,5 +1,11 @@ Changes with Apache 1.3.2 + *) Fix the ap_log_error_old(), ap_log_unixerr() and ap_log_printf() + functions: First all three functions no longer fail on strings containing + "%" chars and second ap_log_printf() no longer does a double-formatting + (instead it directly passes through the message to be formatted to the + real internal formatting function). [Ralf S. Engelschall] PR#2941 + *) Allow "Include" directives anywhere in the server config files (but not .htaccess files). [Ken Coar] PR#2727 1.65 +3 -5 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- http_log.c1998/08/10 16:17:54 1.64 +++ http_log.c1998/09/10 06:58:19 1.65 @@ -460,23 +460,21 @@ API_EXPORT(void) ap_log_error_old (const char *err, server_rec *s) { -ap_log_error(APLOG_MARK, APLOG_ERR, s, err); +ap_log_error(APLOG_MARK, APLOG_ERR, s, "%s", err); } API_EXPORT(void) ap_log_unixerr (const char *routine, const char *file, const char *msg, server_rec *s) { -ap_log_error(file, 0, APLOG_ERR, s, msg); +ap_log_error(file, 0, APLOG_ERR, s, "%s", msg); } API_EXPORT(void) ap_log_printf (const server_rec *s, const char *fmt, ...) { -char buf[MAX_STRING_LEN]; va_list args; va_start(args, fmt); -ap_vsnprintf(buf, sizeof(buf), fmt, args); -ap_log_error(APLOG_MARK, APLOG_ERR, s, buf); +log_error_core(APLOG_MARK, APLOG_ERR, s, NULL, fmt, args); va_end(args); }
cvs commit: apache-1.3/src/main http_log.c
dgaudet 98/08/10 09:17:55 Modified:src/main http_log.c Log: be a little more uniform, use [client %s] similar to other log fields Revision ChangesPath 1.64 +1 -1 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- http_log.c1998/08/06 17:30:29 1.63 +++ http_log.c1998/08/10 16:17:54 1.64 @@ -353,7 +353,7 @@ * first. -djg */ len += ap_snprintf(errstr + len, sizeof(errstr) - len, - "(client %s): ", r->connection->remote_ip); + "[client %s] ", r->connection->remote_ip); } if (!(level & APLOG_NOERRNO) && (save_errno != 0)
cvs commit: apache-1.3/src/main http_log.c
brian 98/05/28 17:09:22 Modified:src/main http_log.c Log: This was causing warnings in some compilation environments, and is the correct set of arguments for the function, even though pinfo never ends up getting used. See error_log_child for a similar situation. Revision ChangesPath 1.60 +1 -1 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- http_log.c1998/05/28 22:09:50 1.59 +++ http_log.c1998/05/29 00:09:22 1.60 @@ -620,7 +620,7 @@ } #else -static int piped_log_child (void *cmd) +static int piped_log_child (void *cmd, child_info *pinfo) { /* Child process code for 'TransferLog "|..."'; * may want a common framework for this, since I expect it will
cvs commit: apache-1.3/src/main http_log.c
martin 98/05/04 09:28:47 Modified:src CHANGES src/main http_log.c Log: BS2000 Debug Logging logs relative paths now, as in unix Revision ChangesPath 1.816 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.815 retrieving revision 1.816 diff -u -u -r1.815 -r1.816 --- CHANGES 1998/05/04 06:58:02 1.815 +++ CHANGES 1998/05/04 16:28:45 1.816 @@ -1,5 +1,9 @@ Changes with Apache 1.3b7 + *) Fix debug log messages for BS2000/OSD: instead of logging the whole + absolute path, only log base name of logging source as is done + in unix. [Martin Kraemer] + *) Ronald Tschalaer's Accept-Encoding patch - preserve the "x-" in the encoding type from the Accept-Encoding header (if it's there) and use it in the response, as that's probably what it'll be expecting. 1.56 +18 -0 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -u -r1.55 -r1.56 --- http_log.c1998/05/03 17:16:59 1.55 +++ http_log.c1998/05/04 16:28:47 1.56 @@ -325,6 +325,24 @@ "[%s] ", priorities[level & APLOG_LEVELMASK].t_name); if (file && (level & APLOG_LEVELMASK) == APLOG_DEBUG) { +#ifdef _OSD_POSIX + char tmp[256]; + char *e = strrchr(file, '/'); + + /* In OSD/POSIX, the compiler returns for __FILE__ + * a string like: __FILE__="*POSIX(/usr/include/stdio.h)" + * (it even returns an absolute path for sources in + * the current directory). Here we try to strip this + * down to the basename. + */ + if (e != NULL && e[1] != '\0') { + ap_snprintf(tmp, sizeof(tmp), "%s", &e[1]); + e = &tmp[strlen(tmp)-1]; + if (*e == ')') + *e = '\0'; + file = tmp; + } +#endif /*_OSD_POSIX*/ len += ap_snprintf(errstr + len, sizeof(errstr) - len, "%s(%d): ", file, line); }
cvs commit: apache-1.3/src/main http_log.c http_main.c
jim 98/05/03 10:17:01 Modified:.STATUS src CHANGES src/include httpd.h src/main http_log.c http_main.c Log: Submitted by: Jim Jagielski Reviewed by: Dean Gaudet, Ralf Engelschall If a child exits with a status of APEXIT_CHILDFATAL, the main httpd process will see this as a "things are totally hosed" and do a server abort, shutting down completely. This is to prevent situations where child errors prevent the server from running correctly and filling the logs up with messages. Revision ChangesPath 1.355 +2 -8 apache-1.3/STATUS Index: STATUS === RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.354 retrieving revision 1.355 diff -u -r1.354 -r1.355 --- STATUS1998/05/03 16:46:47 1.354 +++ STATUS1998/05/03 17:16:56 1.355 @@ -83,6 +83,8 @@ * Ben's WIN32: Extensive overhaul of the way UNCs are handled. * Ralf's fix for referer/agent log entries in installed httpd.conf, PR#2175 * Jim's fix for MIME type case sensitivity disparity, PR#2112 +* Child processes can now "signal" to the parent process that + it (the parent process) should abort, shutting down the server. Available Patches: @@ -147,14 +149,6 @@ errors. The respective flush_funcs also need to be exercised. o Jim's looked over the ap_snprintf() stuff (the changes that Dean did to make thread-safe) and they look fine. - -* The fatal errors that the children detect and fill up the log with - (such as bogus group id) need to be stopped. The proposed fix is to - make the child exit with a special code when a fatal error occurs; the - parent would then abort. See - <[EMAIL PROTECTED]> - [PATCH] <[EMAIL PROTECTED]> - Status: Jim, Dean +1, Ralf +1 * The DoS issue about symlinks to /dev/zero is still present. A device checker patch had been sent to the list a while ago. 1.811 +5 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.810 retrieving revision 1.811 diff -u -r1.810 -r1.811 --- CHANGES 1998/05/03 16:46:48 1.810 +++ CHANGES 1998/05/03 17:16:57 1.811 @@ -1,5 +1,10 @@ Changes with Apache 1.3b7 + *) Child processes can now "signal" (by exiting with a status + of APEXIT_CHILDFATAL) the parent process to abort and + shutdown the server if the error in the child process was + fatal enough. [Jim Jagielski] + *) mod_autoindex's find_itme() was sensitive to MIME type case. [Jim Jagielski] PR#2112 1.207 +21 -0 apache-1.3/src/include/httpd.h Index: httpd.h === RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v retrieving revision 1.206 retrieving revision 1.207 diff -u -r1.206 -r1.207 --- httpd.h 1998/04/19 20:10:45 1.206 +++ httpd.h 1998/05/03 17:16:58 1.207 @@ -301,6 +301,27 @@ #endif /* + * Special Apache error codes. These are basically used + * in http_main.c so we can keep track of various errors. + * + * APEXIT_OK: + * A normal exit + * APEXIT_INIT: + * A fatal error arising during the server's init sequence + * APEXIT_CHILDINIT: + * The child died during it's init sequence + * APEXIT_CHILDFATAL: + * A fatal error, resulting in the whole server aborting. + * If a child exits with this error, the parent process + * considers this a server-wide fatal error and aborts. + * + */ +#define APEXIT_OK0x0 +#define APEXIT_INIT 0x2 +#define APEXIT_CHILDINIT 0x3 +#define APEXIT_CHILDFATAL0xf + +/* * (Unix, OS/2 only) * Interval, in microseconds, between scoreboard maintenance. During * each scoreboard maintenance cycle the parent decides if it needs to 1.55 +1 -0 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- http_log.c1998/04/27 22:38:05 1.54 +++ http_log.c1998/05/03 17:16:59 1.55 @@ -177,6 +177,7 @@ execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL); #endif exit (1); +/* NOT REACHED */ return(child_pid); } 1.329 +51 -40apache-1.3/src/main/http_main.c Index: http_main.c === RCS file: /export/home/cvs/apa
cvs commit: apache-1.3/src/main http_log.c
martin 98/04/27 15:38:05 Modified:src CHANGES src/main http_log.c Log: Suppress "error(0)" messages for ap_log_error() when the APLOG_NOERRNO is unset (as it is in situations like timeouts) where it is unclear whether errno is set or not. It is questionable whether the ap_log_error() timeout calls in http_protocol should not have an APLOG_NOERRNO as well. Revision ChangesPath 1.800 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.799 retrieving revision 1.800 diff -u -u -r1.799 -r1.800 --- CHANGES 1998/04/27 13:01:05 1.799 +++ CHANGES 1998/04/27 22:37:47 1.800 @@ -1,5 +1,9 @@ Changes with Apache 1.3b7 + *) Suppress "error(0)" messages for ap_log_error() when the APLOG_NOERRNO + is unset (as it is in situations like timeouts) where it is unclear + whether errno is set or not. [Martin Kraemer] + *) Just having APACI's localstatedir is too general and not enough for most of the systems. 1.3b6 again required manual APACI patches by package maintainers from RedHat and FreeBSD because for their filesystem layout a 1.54 +1 -0 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -u -r1.53 -r1.54 --- http_log.c1998/04/18 10:54:55 1.53 +++ http_log.c1998/04/27 22:38:05 1.54 @@ -328,6 +328,7 @@ "%s(%d): ", file, line); } if (!(level & APLOG_NOERRNO) + && (save_errno != 0) #ifdef WIN32 && !(level & APLOG_WIN32ERROR) #endif
cvs commit: apache-1.3/src/main http_log.c
rse 98/04/18 03:54:56 Modified:.STATUS src CHANGES src/main http_log.c Log: Fix error logging for the startup case where ap_log_error() still uses stderr as the target. Now the default log level is honored here, too. This especially removes the confusing mod_so debug messages on startup when LoadModule commands are used. Submitted by: Ralf S. Engelschall Reviewed by: Dean Gaudet, Ralf S. Engelschall Revision ChangesPath 1.304 +1 -0 apache-1.3/STATUS Index: STATUS === RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.303 retrieving revision 1.304 diff -u -r1.303 -r1.304 --- STATUS1998/04/18 07:40:37 1.303 +++ STATUS1998/04/18 10:54:53 1.304 @@ -44,6 +44,7 @@ * Lars' Configure fix to avoid confusing message under APACI control * Ralf's Configure fix for AWK's failing with "string to long" error +* Ralf's fix for stderr logging to make sure default loglevel is honored Available Patches: 1.772 +4 -0 apache-1.3/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.771 retrieving revision 1.772 diff -u -r1.771 -r1.772 --- CHANGES 1998/04/17 18:49:35 1.771 +++ CHANGES 1998/04/18 10:54:54 1.772 @@ -1,5 +1,9 @@ Changes with Apache 1.3b7 + *) Fix error logging for the startup case where ap_log_error() still uses + stderr as the target. Now the default log level is honored here, too. + [Ralf S. Engelschall] + *) PORT: Make sure some AWK's don't fail in src/Configure with "string too long" errors when generating the MODULES entry for src/Makefile [Ben Hyde, Ralf S. Engelschall] 1.53 +8 -0 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- http_log.c1998/04/11 18:51:34 1.52 +++ http_log.c1998/04/18 10:54:55 1.53 @@ -284,6 +284,14 @@ FILE *logf; if (s == NULL) { + /* + * If we are doing stderr logging (startup), don't log messages that are + * above the default server log level unless it is a startup/shutdown + * notice + */ + if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) && + ((level & APLOG_LEVELMASK) > DEFAULT_LOGLEVEL)) + return; logf = stderr; } else if (s->error_log) {
cvs commit: apache-1.3/src/main http_log.c
dgaudet 98/04/11 11:51:35 Modified:src/main http_log.c Log: overzealous renaming Revision ChangesPath 1.52 +5 -5 apache-1.3/src/main/http_log.c Index: http_log.c === RCS file: /export/home/cvs/apache-1.3/src/main/http_log.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- http_log.c1998/04/11 12:00:29 1.51 +++ http_log.c1998/04/11 18:51:34 1.52 @@ -389,15 +389,15 @@ } -void ap_log_pid (pool *p, char *ap_pid_fname) +void ap_log_pid (pool *p, char *fname) { FILE *pid_file; -if (!ap_pid_fname) return; -ap_pid_fname = ap_server_root_relative (p, ap_pid_fname); -if(!(pid_file = fopen(ap_pid_fname,"w"))) { +if (!fname) return; +fname = ap_server_root_relative (p, fname); +if(!(pid_file = fopen(fname,"w"))) { perror("fopen"); -fprintf(stderr,"httpd: could not log pid to file %s\n", ap_pid_fname); +fprintf(stderr,"httpd: could not log pid to file %s\n", fname); exit(1); } fprintf(pid_file,"%ld\n",(long)getpid());