diff options
| author | 2016-04-02 19:55:10 +0000 | |
|---|---|---|
| committer | 2016-04-02 19:55:10 +0000 | |
| commit | 7bb95e134aa2b81e0734e7d94e7e653651bac06c (patch) | |
| tree | 4ef6e7b7433b2a620ee52ee5170432f62e7556f1 /usr.sbin/syslogd/syslogd.c | |
| parent | Eliminate the need to explicitly invoke syscalls via their _thread_sys_* (diff) | |
| download | wireguard-openbsd-7bb95e134aa2b81e0734e7d94e7e653651bac06c.tar.xz wireguard-openbsd-7bb95e134aa2b81e0734e7d94e7e653651bac06c.zip | |
Eliminate superfluous 3rd params in fcntl(F_GETFL) calls.
ttymsg.c doesn't need to include fcntl.h.
Tweak standard fd sanitising to be more like the sanitise_stdfd()
used elsewhere, though other uses of 'nullfd' make importing
sanitise_stdfd() itself unappetizing.
Add a die(0) if dup2() fails.
suggestions & ok bluhm@
Diffstat (limited to 'usr.sbin/syslogd/syslogd.c')
| -rw-r--r-- | usr.sbin/syslogd/syslogd.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index aca84696813..da917502a27 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.204 2016/02/17 18:31:28 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.205 2016/04/02 19:55:10 krw Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -436,10 +436,12 @@ main(int argc, char *argv[]) logerror("Couldn't open /dev/null"); die(0); } - for (fd = nullfd + 1; fd <= 2; fd++) { - if (fcntl(fd, F_GETFL, 0) == -1) - if (dup2(nullfd, fd) == -1) + for (fd = nullfd + 1; fd <= STDERR_FILENO; fd++) { + if (fcntl(fd, F_GETFL) == -1 && errno == EBADF) + if (dup2(nullfd, fd) == -1) { logerror("dup2"); + die(0); + } } consfile.f_type = F_CONSOLE; @@ -2651,7 +2653,7 @@ cfline(char *line, char *progblock, char *hostblock) f->f_type = F_FILE; /* Clear O_NONBLOCK flag on f->f_file */ - if ((i = fcntl(f->f_file, F_GETFL, 0)) != -1) { + if ((i = fcntl(f->f_file, F_GETFL)) != -1) { i &= ~O_NONBLOCK; fcntl(f->f_file, F_SETFL, i); } |
