diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-04-02 19:55:11 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-04-02 19:55:11 +0000 |
commit | a55e1169da61fa81974081006c42e49a98442ad9 (patch) | |
tree | 27c59a7798c5a2653352ebda8993a82a4f045e21 /usr.sbin | |
parent | fdde865858c3237682a6b0ab261839d3b408b949 (diff) |
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')
-rw-r--r-- | usr.sbin/syslogd/privsep.c | 4 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 12 | ||||
-rw-r--r-- | usr.sbin/syslogd/ttymsg.c | 3 |
3 files changed, 10 insertions, 9 deletions
diff --git a/usr.sbin/syslogd/privsep.c b/usr.sbin/syslogd/privsep.c index 7700a11a78b..a3cfc170de0 100644 --- a/usr.sbin/syslogd/privsep.c +++ b/usr.sbin/syslogd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.59 2015/10/20 12:40:19 bluhm Exp $ */ +/* $OpenBSD: privsep.c,v 1.60 2016/04/02 19:55:10 krw Exp $ */ /* * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org> @@ -446,7 +446,7 @@ open_pipe(char *cmd) } /* make the fd on syslogd's side nonblocking */ - if ((flags = fcntl(fd[1], F_GETFL, 0)) == -1) { + if ((flags = fcntl(fd[1], F_GETFL)) == -1) { warnx("fcntl"); return (-1); } 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); } diff --git a/usr.sbin/syslogd/ttymsg.c b/usr.sbin/syslogd/ttymsg.c index ef50b3927e2..e899c786973 100644 --- a/usr.sbin/syslogd/ttymsg.c +++ b/usr.sbin/syslogd/ttymsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttymsg.c,v 1.9 2015/10/23 16:28:52 bluhm Exp $ */ +/* $OpenBSD: ttymsg.c,v 1.10 2016/04/02 19:55:10 krw Exp $ */ /* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */ /* @@ -36,7 +36,6 @@ #include <dirent.h> #include <errno.h> #include <event.h> -#include <fcntl.h> #include <paths.h> #include <signal.h> #include <stdio.h> |