summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2016-04-02 19:55:10 +0000
committerkrw <krw@openbsd.org>2016-04-02 19:55:10 +0000
commit7bb95e134aa2b81e0734e7d94e7e653651bac06c (patch)
tree4ef6e7b7433b2a620ee52ee5170432f62e7556f1 /usr.sbin/syslogd
parentEliminate the need to explicitly invoke syscalls via their _thread_sys_* (diff)
downloadwireguard-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')
-rw-r--r--usr.sbin/syslogd/privsep.c4
-rw-r--r--usr.sbin/syslogd/syslogd.c12
-rw-r--r--usr.sbin/syslogd/ttymsg.c3
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>