diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-09-17 22:25:22 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-09-17 22:25:22 +0000 |
commit | e2635e65d09c2f9f68bfa925c9cf833bbd20b540 (patch) | |
tree | 0192d120f22d544d442d7c02e746d8681d2f1fcf /usr.sbin/syslogd | |
parent | 4fa4c8bf030969cc5d680c9720e24a22f74a7991 (diff) |
When writing local output, syslogd ignores EAGAIN. Unfortunately
it has closed the file descriptor before checking the errno. So
f_file contained a bad file descriptor that could be reused at the
next open. Keep the file open if errno is EAGAIN. Move the close(2)
down where the old file descriptor in f_file is overwritten in all
cases.
OK deraadt@ jca@
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 1b66f5b9f6a..47cebbd2645 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.246 2017/09/12 15:17:20 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.247 2017/09/17 22:25:21 bluhm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -2045,7 +2045,6 @@ fprintlog(struct filed *f, int flags, char *msg) break; } - (void)close(f->f_file); /* * Check for errors on TTY's or program pipes. * Errors happen due to loss of tty or died programs. @@ -2056,7 +2055,10 @@ fprintlog(struct filed *f, int flags, char *msg) * This can happen when logging to a locked tty. */ break; - } else if ((e == EIO || e == EBADF) && + } + + (void)close(f->f_file); + if ((e == EIO || e == EBADF) && f->f_type != F_FILE && f->f_type != F_PIPE && !retryonce) { f->f_file = priv_open_tty(f->f_un.f_fname); |