diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-08-21 21:41:14 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-08-21 21:41:14 +0000 |
commit | c2cdcf41ccf92e65434001bc73d5d81b4c4210dd (patch) | |
tree | b806cd4f2e6e8fcd9ec7d6f315a0aa469b48521d /usr.sbin | |
parent | e9d6f86c3468c07e6b1b12c0dd0b46516528e450 (diff) |
Use waitpid()/EINTR idiom for the specific pid, rather than generic wait(),
in case the parent process was started with a dangling child. This style
ensures any potential parent:child interlock isn't disrupted due to the
"wrong" child being waited on first. Then the other other childs can safely
zombie.
ok millert jca brynet
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/radiusd/radiusd_bsdauth.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.sbin/radiusd/radiusd_bsdauth.c b/usr.sbin/radiusd/radiusd_bsdauth.c index fe85ac514a9..7f03a0c41ee 100644 --- a/usr.sbin/radiusd/radiusd_bsdauth.c +++ b/usr.sbin/radiusd/radiusd_bsdauth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_bsdauth.c,v 1.7 2015/12/05 13:22:32 claudio Exp $ */ +/* $OpenBSD: radiusd_bsdauth.c,v 1.8 2017/08/21 21:41:13 deraadt Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -61,7 +61,7 @@ struct auth_groupcheck_args { size_t grouplen; }; -static void module_bsdauth_main(int, int); +static pid_t module_bsdauth_main(int, int); static void module_bsdauth_config_set(void *, const char *, int, char * const *); static void module_bsdauth_userpass(void *, u_int, const char *, @@ -82,12 +82,13 @@ main(int argc, char *argv[]) struct imsg imsg; ssize_t n; size_t datalen; + pid_t pid; if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pairsock) == -1) err(EXIT_FAILURE, "socketpair"); pipe_chld = pairsock[1]; - module_bsdauth_main(pairsock[0], pairsock[1]); + pid = module_bsdauth_main(pairsock[0], pairsock[1]); /* * Privileged process @@ -201,12 +202,15 @@ group_done: imsg_flush(&ibuf); } imsg_clear(&ibuf); - wait(&status); + while (waitpid(pid, &status, 0) == -1) { + if (errno != EINTR) + break; + } exit(WEXITSTATUS(status)); } -static void +static pid_t module_bsdauth_main(int pipe_prnt, int pipe_chld) { int i; @@ -219,7 +223,7 @@ module_bsdauth_main(int pipe_prnt, int pipe_chld) if (pid > 0) { close(pipe_prnt); - return; + return (pid); } close(pipe_chld); |