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.
This commit is contained in:
Todd C. Miller
2010-05-21 14:50:26 -04:00
parent 529bfcf674
commit 16c2769ed9

View File

@@ -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)