summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authoryasuoka <yasuoka@openbsd.org>2015-10-27 04:18:36 +0000
committeryasuoka <yasuoka@openbsd.org>2015-10-27 04:18:36 +0000
commit1df00c4650477e471eb25a085cd34fcd93dbf5bd (patch)
treefed520a7bcf733dfed931344fe5c861b9a40f09a /usr.sbin
parentAdd a man page for eigrpd.conf. (diff)
downloadwireguard-openbsd-1df00c4650477e471eb25a085cd34fcd93dbf5bd.tar.xz
wireguard-openbsd-1df00c4650477e471eb25a085cd34fcd93dbf5bd.zip
Fix radiusd module to set O_NONBLOCK properly.
diff from Yuuichi Someya.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/radiusd/radiusd.c14
-rw-r--r--usr.sbin/radiusd/radiusd_module.c9
2 files changed, 14 insertions, 9 deletions
diff --git a/usr.sbin/radiusd/radiusd.c b/usr.sbin/radiusd/radiusd.c
index 5f8e0672f98..0c1a2ff62e5 100644
--- a/usr.sbin/radiusd/radiusd.c
+++ b/usr.sbin/radiusd/radiusd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radiusd.c,v 1.9 2015/10/19 22:07:37 yasuoka Exp $ */
+/* $OpenBSD: radiusd.c,v 1.10 2015/10/27 04:18:36 yasuoka Exp $ */
/*
* Copyright (c) 2013 Internet Initiative Japan Inc.
@@ -930,7 +930,7 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name)
{
struct radiusd_module *module = NULL;
pid_t pid;
- int on, pairsock[] = { -1, -1 };
+ int ival, pairsock[] = { -1, -1 };
const char *av[3];
ssize_t n;
struct imsg imsg;
@@ -967,9 +967,13 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name)
close(pairsock[1]);
module->fd = pairsock[0];
- on = 1;
- if (fcntl(module->fd, O_NONBLOCK, &on) == -1) {
- log_warn("Could not load module `%s': fcntl(,O_NONBLOCK)",
+ if ((ival = fcntl(module->fd, F_GETFL, 0)) < 0) {
+ log_warn("Could not load module `%s': fcntl(F_GETFL)",
+ name);
+ goto on_error;
+ }
+ if (fcntl(module->fd, F_SETFL, ival | O_NONBLOCK) < 0) {
+ log_warn("Could not load module `%s': fcntl(F_SETFL,O_NONBLOCK)",
name);
goto on_error;
}
diff --git a/usr.sbin/radiusd/radiusd_module.c b/usr.sbin/radiusd/radiusd_module.c
index c82bc9cbee3..e3a5e577dcc 100644
--- a/usr.sbin/radiusd/radiusd_module.c
+++ b/usr.sbin/radiusd/radiusd_module.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radiusd_module.c,v 1.6 2015/10/19 09:47:37 yasuoka Exp $ */
+/* $OpenBSD: radiusd_module.c,v 1.7 2015/10/27 04:18:36 yasuoka Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -100,10 +100,11 @@ void
module_start(struct module_base *base)
{
#ifdef USE_LIBEVENT
- int on;
+ int ival;
- on = 1;
- if (fcntl(base->ibuf.fd, O_NONBLOCK, &on) == -1)
+ if ((ival = fcntl(base->ibuf.fd, F_GETFL, 0)) < 0)
+ err(1, "Failed to F_GETFL");
+ if (fcntl(base->ibuf.fd, F_SETFL, ival | O_NONBLOCK) < 0)
err(1, "Failed to setup NONBLOCK");
event_set(&base->ev, base->ibuf.fd, EV_READ, module_on_event, base);
event_add(&base->ev, NULL);