]> granicus.if.org Git - sudo/commitdiff
Close the I/O pipes aftering dup2()ing them to std{in,out,err}.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 21 May 2010 18:50:26 +0000 (14:50 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 21 May 2010 18:50:26 +0000 (14:50 -0400)
Fixes extra fds being present in the command when it is part of a pipeline.

src/script.c

index 7fea47ed344a71782fde302c5af6896921780bf6..caef0dc9b65d8554271ab1acee06f7659894366a 100644 (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)