From 9b5495d23ee28fa77dc58a31953d3f6f86d5baa1 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Tue, 1 Feb 2005 17:35:09 +1100 Subject: [PATCH] - (dtucker) [log.c] Bug #973: force log_init() to open syslog, since on some platforms syslog will revert to its default values. This may result in messages from external libraries (eg libwrap) being sent to a different facility. --- ChangeLog | 8 +++++++- log.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 703d8e670..3abcb90b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +20050201 + - (dtucker) [log.c] Bug #973: force log_init() to open syslog, since on some + platforms syslog will revert to its default values. This may result in + messages from external libraries (eg libwrap) being sent to a different + facility. + 20050124 - (dtucker) OpenBSD CVS Sync - otto@cvs.openbsd.org 2005/01/21 08:32:02 @@ -2043,4 +2049,4 @@ - (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu -$Id: ChangeLog,v 1.3626 2005/01/24 11:50:47 dtucker Exp $ +$Id: ChangeLog,v 1.3627 2005/02/01 06:35:09 dtucker Exp $ diff --git a/log.c b/log.c index 5d8625d15..bb95c6c39 100644 --- a/log.c +++ b/log.c @@ -194,6 +194,9 @@ void log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) { argv0 = av0; +#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) + struct syslog_data sdata = SYSLOG_DATA_INIT; +#endif switch (level) { case SYSLOG_LEVEL_QUIET: @@ -261,6 +264,19 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) (int) facility); exit(1); } + + /* + * If an external library (eg libwrap) attempts to use syslog + * immediately after reexec, syslog may be pointing to the wrong + * facility, so we force an open/close of syslog here. + */ +#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) + openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata); + closelog_r(&sdata); +#else + openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility); + closelog(); +#endif } #define MSGBUFSIZ 1024