From: Todd C. Miller Date: Fri, 21 May 2010 18:50:26 +0000 (-0400) Subject: Close the I/O pipes aftering dup2()ing them to std{in,out,err}. X-Git-Tag: SUDO_1_8_0~610 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16c2769ed997d37925017e19d08f89fb64f4f187;p=sudo Close the I/O pipes aftering dup2()ing them to std{in,out,err}. Fixes extra fds being present in the command when it is part of a pipeline. --- diff --git a/src/script.c b/src/script.c index 7fea47ed3..caef0dc9b 100644 --- a/src/script.c +++ b/src/script.c @@ -1283,9 +1283,15 @@ script_run(const char *path, char *argv[], char *envp[], int rbac_enabled) ; /* spin */ } - /* We have guaranteed that the slave fd > 3 */ + /* We have guaranteed that the slave fd is > 2 */ if (script_fds[SFD_SLAVE] != -1) close(script_fds[SFD_SLAVE]); + if (script_fds[SFD_STDIN] != script_fds[SFD_SLAVE]) + close(script_fds[SFD_STDIN]); + if (script_fds[SFD_STDOUT] != script_fds[SFD_SLAVE]) + close(script_fds[SFD_STDOUT]); + if (script_fds[SFD_STDERR] != script_fds[SFD_SLAVE]) + close(script_fds[SFD_STDERR]); #ifdef HAVE_SELINUX if (rbac_enabled)