summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-10-10 23:06:33 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-10-10 23:06:33 +0000
commit1364b45a80f17d3307f385a850ca3e570048817d (patch)
tree60249e8f58e081c0ae47e664d30fc4394b9fb7ba /usr.sbin
parentba22d240c58a6b0f9cf8394b2da54d61ba6c457c (diff)
Convert FIONBIO to SOCK_NONBLOCK
ok dlg@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/tftp-proxy/tftp-proxy.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/usr.sbin/tftp-proxy/tftp-proxy.c b/usr.sbin/tftp-proxy/tftp-proxy.c
index 95ab0badefa..39da56a42ed 100644
--- a/usr.sbin/tftp-proxy/tftp-proxy.c
+++ b/usr.sbin/tftp-proxy/tftp-proxy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftp-proxy.c,v 1.11 2015/01/16 06:40:22 deraadt Exp $
+/* $OpenBSD: tftp-proxy.c,v 1.12 2015/10/10 23:06:32 guenther Exp $
*
* Copyright (c) 2005 DLS Internet Services
* Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl>
@@ -246,7 +246,8 @@ main(int argc, char *argv[])
if (!debug && daemon(1, 0) == -1)
err(1, "daemon");
- if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pair) == -1)
+ if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, PF_UNSPEC, pair)
+ == -1)
lerr(1, "socketpair");
pw = getpwnam(NOPRIV_USER);
@@ -319,9 +320,6 @@ main(int argc, char *argv[])
proxy_listener_events();
- if (ioctl(pair[1], FIONBIO, &on) == -1)
- lerr(1, "ioctl(FIONBIO)");
-
event_set(&child->pop_ev, pair[1], EV_READ | EV_PERSIST,
unprivproc_pop, NULL);
event_set(&child->push_ev, pair[1], EV_WRITE,
@@ -370,9 +368,6 @@ proxy_privproc(int s, struct passwd *pw)
logger = &syslogger;
}
- if (ioctl(s, FIONBIO, &on) == -1)
- lerr(1, "ioctl(FIONBIO)");
-
if (chroot(CHROOT_DIR) == -1)
lerr(1, "chroot to %s", CHROOT_DIR);
@@ -434,13 +429,11 @@ privproc_pop(int fd, short events, void *arg)
if (rep == NULL)
lerr(1, "reply calloc");
- rep->fd = socket(req.src.ss_family, SOCK_DGRAM, IPPROTO_UDP);
+ rep->fd = socket(req.src.ss_family, SOCK_DGRAM | SOCK_NONBLOCK,
+ IPPROTO_UDP);
if (rep->fd == -1)
lerr(1, "privproc socket");
- if (ioctl(rep->fd, FIONBIO, &on) == -1)
- err(1, "privproc ioctl(FIONBIO)");
-
if (setsockopt(rep->fd, SOL_SOCKET, SO_BINDANY,
&on, sizeof(on)) == -1)
lerr(1, "privproc setsockopt(BINDANY)");
@@ -557,7 +550,8 @@ proxy_listen(const char *addr, const char *port, int family)
errx(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;
@@ -575,9 +569,6 @@ proxy_listen(const char *addr, const char *port, int family)
if (l == NULL)
err(1, "listener alloc");
- if (ioctl(s, FIONBIO, &on) == -1)
- err(1, "ioctl(FIONBIO)");
-
switch (res->ai_family) {
case AF_INET:
l->cmsg2dst = proxy_dst4;