diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 1999-11-14 22:28:45 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 1999-11-14 22:28:45 +0000 |
commit | fa90dac0be8371dfe49ad2507e1c3f50de59e786 (patch) | |
tree | 5a8f52f4d504733ab98b26a4e091879d8d3373b5 | |
parent | 78f3f6733a592c508765583e736c9d61a21af677 (diff) |
avoid extra fd per sshd, from millert@
-rw-r--r-- | usr.bin/ssh/log-server.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/ssh/log-server.c b/usr.bin/ssh/log-server.c index aa5aeec12e1..67b1062773a 100644 --- a/usr.bin/ssh/log-server.c +++ b/usr.bin/ssh/log-server.c @@ -15,7 +15,7 @@ to the system log. */ #include "includes.h" -RCSID("$Id: log-server.c,v 1.7 1999/11/10 23:36:44 markus Exp $"); +RCSID("$Id: log-server.c,v 1.8 1999/11/14 22:28:44 markus Exp $"); #include <syslog.h> #include "packet.h" @@ -24,6 +24,7 @@ RCSID("$Id: log-server.c,v 1.7 1999/11/10 23:36:44 markus Exp $"); static LogLevel log_level = SYSLOG_LEVEL_INFO; static int log_on_stderr = 0; +static int log_facility = LOG_AUTH; /* Initialize the log. av0 program name (should be argv[0]) @@ -33,7 +34,6 @@ static int log_on_stderr = 0; void log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) { - int log_facility; switch (level) { @@ -93,8 +93,6 @@ void log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) } log_on_stderr = on_stderr; - closelog(); /* Close any previous log. */ - openlog(av0, LOG_PID, log_facility); } #define MSGBUFSIZE 1024 @@ -106,6 +104,7 @@ do_log(LogLevel level, const char *fmt, va_list args) char fmtbuf[MSGBUFSIZE]; char *txt = NULL; int pri = LOG_INFO; + extern char *__progname; if (level > log_level) return; @@ -143,5 +142,7 @@ do_log(LogLevel level, const char *fmt, va_list args) } if (log_on_stderr) fprintf(stderr, "%s\n", msgbuf); + openlog(__progname, LOG_PID, log_facility); syslog(pri, "%.500s", msgbuf); + closelog(); } |