diff options
author | 2015-11-25 00:01:21 +0000 | |
---|---|---|
committer | 2015-11-25 00:01:21 +0000 | |
commit | c96b83afdd79382f9cb6af574ddea3e1bdf764f4 (patch) | |
tree | d6e719a0fd2e2bc595ede16f5d138ff5cc8ab59f /lib/libc/gen/syslog_r.c | |
parent | Add sendsyslog2(), which accepts the syslog/openlog "logopt" flag (diff) | |
download | wireguard-openbsd-c96b83afdd79382f9cb6af574ddea3e1bdf764f4.tar.xz wireguard-openbsd-c96b83afdd79382f9cb6af574ddea3e1bdf764f4.zip |
Add a syscall stub for sendsyslog2(2), and use it in syslog_r(3), passing
LOG_CONS to the kernel. As a result, the /dev/console opening code can
be removed.
ok kettenis millert beck
Diffstat (limited to 'lib/libc/gen/syslog_r.c')
-rw-r--r-- | lib/libc/gen/syslog_r.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/lib/libc/gen/syslog_r.c b/lib/libc/gen/syslog_r.c index d5ae4aa88c1..73e237376ad 100644 --- a/lib/libc/gen/syslog_r.c +++ b/lib/libc/gen/syslog_r.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslog_r.c,v 1.10 2015/10/31 02:57:16 deraadt Exp $ */ +/* $OpenBSD: syslog_r.c,v 1.11 2015/11/25 00:01:21 deraadt Exp $ */ /* * Copyright (c) 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -195,24 +195,7 @@ __vsyslog_r(int pri, struct syslog_data *data, * If the sendsyslog() fails, it means that syslogd * is not running. */ - error = sendsyslog(tbuf, cnt); - - /* - * Output the message to the console; try not to block - * as a blocking console should not stop other processes. - * Make sure the error reported is the one from the syslogd failure. - */ - if (error == -1 && (data->log_stat & LOG_CONS) && - (fd = open(_PATH_CONSOLE, O_WRONLY|O_NONBLOCK, 0)) >= 0) { - struct iovec iov[2]; - - iov[0].iov_base = conp; - iov[0].iov_len = cnt > conp - tbuf ? cnt - (conp - tbuf) : 0; - iov[1].iov_base = "\r\n"; - iov[1].iov_len = 2; - (void)writev(fd, iov, 2); - (void)close(fd); - } + error = sendsyslog2(tbuf, cnt, data->log_stat & LOG_CONS); } void |