]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
terminal: set FD_CLOEXEC on pty file descriptors
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 30 Jun 2018 11:06:08 +0000 (13:06 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 1 Jul 2018 18:00:14 +0000 (20:00 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/lxc/terminal.c

index 338d33cd4758a1e20a0760d149159cab3b5ac5ab..bc61d4e5f4437db5978d0dd34fbf2fec79b269e3 100644 (file)
@@ -584,6 +584,18 @@ static int lxc_terminal_peer_proxy_alloc(struct lxc_terminal *terminal,
                goto on_error;
        }
 
+       ret = fd_cloexec(terminal->proxy.master, true);
+       if (ret < 0) {
+               SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal master");
+               goto on_error;
+       }
+
+       ret = fd_cloexec(terminal->proxy.slave, true);
+       if (ret < 0) {
+               SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal slave");
+               goto on_error;
+       }
+
        ret = lxc_setup_tios(terminal->proxy.slave, &oldtermio);
        if (ret < 0)
                goto on_error;
@@ -881,13 +893,13 @@ int lxc_terminal_create(struct lxc_terminal *terminal)
                goto err;
        }
 
-       ret = fcntl(terminal->master, F_SETFD, FD_CLOEXEC);
+       ret = fd_cloexec(terminal->master, true);
        if (ret < 0) {
                SYSERROR("Failed to set FD_CLOEXEC flag on terminal master");
                goto err;
        }
 
-       ret = fcntl(terminal->slave, F_SETFD, FD_CLOEXEC);
+       ret = fd_cloexec(terminal->slave, true);
        if (ret < 0) {
                SYSERROR("Failed to set FD_CLOEXEC flag on terminal slave");
                goto err;