]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
prevent tty fd to be inherited in the container
authorMôshe van der Sterre <me@moshe.nl>
Mon, 20 Apr 2009 20:10:59 +0000 (22:10 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Mon, 20 Apr 2009 20:10:59 +0000 (22:10 +0200)
Set the close on exec flag on the pty fd so they are automatically
closed when execing the container.

Signed-off-by: Môshe van der Sterre <me@moshe.nl>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/conf.c

index 6c3476af090ccece78348d7d574f68f89098772f..5ef350d9b2cd4e36d1f0872a1e64eaa36105102b 100644 (file)
@@ -1738,6 +1738,10 @@ int lxc_create_tty(const char *name, struct lxc_tty_info *tty_info)
                        goto out_free;
                }
 
+                /* Prevent leaking the file descriptors to the container */
+               fcntl(pty_info->master, F_SETFD, FD_CLOEXEC);
+               fcntl(pty_info->slave, F_SETFD, FD_CLOEXEC);
+
                pty_info->busy = 0;
        }