Skip to content

Commit

Permalink
terminal: set FD_CLOEXEC on pty file descriptors
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
  • Loading branch information
Christian Brauner committed Jul 2, 2018
1 parent fae20c2 commit 12925e7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/lxc/terminal.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 12925e7

Please sign in to comment.