From 7d0ac0376e85640a15ad330d5d878a6a8b34cc43 Mon Sep 17 00:00:00 2001 From: Daniel Gollub Date: Fri, 3 Mar 2017 10:35:56 +0100 Subject: [PATCH] Close stdout/stderr/stdin fds in auth-plugin fork The auth-pam plugin gets forked to run in background and kept stdin/stdout/stderr open. This might block the callee of the OpenVPN which expect that it nicely turns into a daemon. Signed-off-by: Daniel Gollub --- src/plugins/auth-pam/auth-pam.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pam.c index d3e2c89d834..e0fbef77058 100644 --- a/src/plugins/auth-pam/auth-pam.c +++ b/src/plugins/auth-pam/auth-pam.c @@ -239,6 +239,21 @@ close_fds_except(int keep) close(i); } } + +#if defined(HAVE_DUP) && defined(HAVE_DUP2) + int fd; + if ((fd = open ("/dev/null", O_RDWR, 0)) != -1) + { + dup2 (fd, 0); + dup2 (fd, 1); + dup2 (fd, 2); + if (fd > 2) + { + close (fd); + } + } +#endif + } /*