From: yasuoka Date: Mon, 4 Sep 2023 23:55:23 +0000 (+0000) Subject: Revert previous. It caused the stdio of the modules be NONBLOCK. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ab3cfbd93ee5e74ffd697abd0bb8b3f50b340dcd;p=openbsd Revert previous. It caused the stdio of the modules be NONBLOCK. Generally programs don't expect that. --- diff --git a/usr.sbin/radiusd/radiusd.c b/usr.sbin/radiusd/radiusd.c index 143cd0d1af0..b6d08ebbb99 100644 --- a/usr.sbin/radiusd/radiusd.c +++ b/usr.sbin/radiusd/radiusd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd.c,v 1.29 2023/09/04 10:50:52 yasuoka Exp $ */ +/* $OpenBSD: radiusd.c,v 1.30 2023/09/04 23:55:23 yasuoka Exp $ */ /* * Copyright (c) 2013 Internet Initiative Japan Inc. @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -918,7 +919,7 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name) { struct radiusd_module *module = NULL; pid_t pid; - int pairsock[] = { -1, -1 }; + int ival, pairsock[] = { -1, -1 }; const char *av[3]; ssize_t n; struct imsg imsg; @@ -928,8 +929,7 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name) fatal("Out of memory"); module->radiusd = radiusd; - if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, PF_UNSPEC, - pairsock) == -1) { + if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pairsock) == -1) { log_warn("Could not load module `%s'(%s): pipe()", name, path); goto on_error; } @@ -956,6 +956,16 @@ radiusd_module_load(struct radiusd *radiusd, const char *path, const char *name) close(pairsock[1]); module->fd = pairsock[0]; + if ((ival = fcntl(module->fd, F_GETFL)) == -1) { + log_warn("Could not load module `%s': fcntl(F_GETFL)", + name); + goto on_error; + } + if (fcntl(module->fd, F_SETFL, ival | O_NONBLOCK) == -1) { + log_warn("Could not load module `%s': fcntl(F_SETFL,O_NONBLOCK)", + name); + goto on_error; + } strlcpy(module->name, name, sizeof(module->name)); module->pid = pid; imsg_init(&module->ibuf, module->fd);