summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2015-08-20 11:06:36 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2015-08-20 11:06:36 +0000
commit1907f5948f59e1902b12b35822dd8dc2f95ecce2 (patch)
tree035f09e364be79b546128327ff052ed213ce7daf
parent356d3d725be52f5a2f83d4c1a10f563c11ffd697 (diff)
avoid ioctl FIONBIO by passing SOCK_NONBLOCK to the things we get
sockets out of. for guenther@
-rw-r--r--usr.sbin/identd/identd.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/usr.sbin/identd/identd.c b/usr.sbin/identd/identd.c
index 4882364b1eb..2540844b673 100644
--- a/usr.sbin/identd/identd.c
+++ b/usr.sbin/identd/identd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: identd.c,v 1.30 2015/08/20 10:54:35 dlg Exp $ */
+/* $OpenBSD: identd.c,v 1.31 2015/08/20 11:06:35 dlg Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
@@ -189,7 +189,6 @@ usage(void)
struct timeval timeout = { TIMEOUT_DEFAULT, 0 };
int debug = 0;
int noident = 0;
-int on = 1;
int unknown_err = 0;
int hideall = 0;
@@ -272,7 +271,8 @@ main(int argc, char *argv[])
if (geteuid() != 0)
errx(1, "need root privileges");
- if (socketpair(AF_UNIX, SOCK_SEQPACKET, PF_UNSPEC, pair) == -1)
+ if (socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_NONBLOCK,
+ PF_UNSPEC, pair) == -1)
err(1, "socketpair");
pw = getpwnam(IDENTD_USER);
@@ -313,9 +313,6 @@ main(int argc, char *argv[])
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
lerr(1, "signal(SIGPIPE)");
- if (ioctl(sibling, FIONBIO, &on) == -1)
- lerr(1, "sibling ioctl(FIONBIO)");
-
if (parent) {
SIMPLEQ_INIT(&sc.parent.replies);
@@ -627,6 +624,7 @@ identd_listen(const char *addr, const char *port, int family)
struct addrinfo hints, *res, *res0;
int error, s;
const char *cause = NULL;
+ int on = 1;
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
@@ -638,7 +636,8 @@ identd_listen(const char *addr, const char *port, int family)
lerrx(1, "%s/%s: %s", addr, port, gai_strerror(error));
for (res = res0; res != NULL; res = res->ai_next) {
- s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ s = socket(res->ai_family, res->ai_socktype | SOCK_NONBLOCK,
+ res->ai_protocol);
if (s == -1) {
cause = "socket";
continue;
@@ -657,9 +656,6 @@ identd_listen(const char *addr, const char *port, int family)
continue;
}
- if (ioctl(s, FIONBIO, &on) == -1)
- err(1, "listener ioctl(FIONBIO)");
-
if (listen(s, 5) == -1)
err(1, "listen");
@@ -695,7 +691,7 @@ identd_accept(int fd, short events, void *arg)
int s;
len = sizeof(ss);
- s = accept(fd, sa(&ss), &len);
+ s = accept4(fd, sa(&ss), &len, SOCK_NONBLOCK);
if (s == -1) {
switch (errno) {
case EINTR:
@@ -712,9 +708,6 @@ identd_accept(int fd, short events, void *arg)
}
}
- if (ioctl(s, FIONBIO, &on) == -1)
- lerr(1, "client ioctl(FIONBIO)");
-
c = calloc(1, sizeof(*c));
if (c == NULL) {
lwarn("client alloc");