diff options
author | Damien Miller <djm@mindrot.org> | 2003-05-20 01:24:17 +0200 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2003-05-20 01:24:17 +0200 |
commit | 74a3442d10b875d73f770249844138856b87e4e9 (patch) | |
tree | 66353792a8e3a4784e1e02a4d22872c22554d541 /log.c | |
parent | - (djm) Sync auth-pam.h with what we actually implement (diff) | |
download | openssh-74a3442d10b875d73f770249844138856b87e4e9.tar.xz openssh-74a3442d10b875d73f770249844138856b87e4e9.zip |
- deraadt@cvs.openbsd.org 2003/05/18 23:22:01
[log.c]
use syslog_r() in a signal handler called place; markus ok
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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" @@ -339,6 +339,9 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) void do_log(LogLevel level, const char *fmt, va_list args) { +#ifdef OPENLOG_R + struct syslog_data sdata = SYSLOG_DATA_INIT; +#endif char msgbuf[MSGBUFSIZ]; char fmtbuf[MSGBUFSIZ]; char *txt = NULL; @@ -391,10 +394,17 @@ do_log(LogLevel level, const char *fmt, va_list args) strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_OCTAL); if (log_on_stderr) { - fprintf(stderr, "%s\r\n", fmtbuf); + snprintf(fmtbuf, sizeof fmtbuf, "%s\r\n", msgbuf); + write(STDERR_FILENO, fmtbuf, strlen(fmtbuf)); } else { +#ifdef OPENLOG_R + openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata); + syslog_r(pri, &sdata, "%.500s", msgbuf); + closelog_r(&sdata); +#else openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility); syslog(pri, "%.500s", fmtbuf); closelog(); +#endif } } |