summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-05-18 23:22:02 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-05-18 23:22:02 +0000
commitd70cb7e607858353e69e57e3f79657fe7adf2f98 (patch)
tree8b7d0725abe1f2df3bc7546a3a8533bf7cc2c547
parentb3377516b3c980db757772ff33b79cfb043e382e (diff)
use syslog_r() in a signal handler called place; markus ok
-rw-r--r--usr.bin/ssh/log.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/ssh/log.c b/usr.bin/ssh/log.c
index 025a4b42d95..24744f2fd19 100644
--- a/usr.bin/ssh/log.c
+++ b/usr.bin/ssh/log.c
@@ -34,7 +34,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: log.c,v 1.26 2003/04/08 20:21:28 itojun Exp $");
+RCSID("$OpenBSD: log.c,v 1.27 2003/05/18 23:22:01 deraadt Exp $");
#include "log.h"
#include "xmalloc.h"
@@ -331,6 +331,7 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
void
do_log(LogLevel level, const char *fmt, va_list args)
{
+ struct syslog_data sdata = SYSLOG_DATA_INIT;
char msgbuf[MSGBUFSIZ];
char fmtbuf[MSGBUFSIZ];
char *txt = NULL;
@@ -380,10 +381,11 @@ do_log(LogLevel level, const char *fmt, va_list args)
vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
}
if (log_on_stderr) {
- fprintf(stderr, "%s\r\n", msgbuf);
+ snprintf(fmtbuf, sizeof fmtbuf, "%s\r\n", msgbuf);
+ write(STDERR_FILENO, fmtbuf, strlen(fmtbuf));
} else {
- openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
- syslog(pri, "%.500s", msgbuf);
- closelog();
+ openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata);
+ syslog_r(pri, &sdata, "%.500s", msgbuf);
+ closelog_r(&sdata);
}
}