From 8188aae1ca5866e3fc7f0cc772d0feed87749554 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Graber?= Date: Fri, 13 Mar 2015 16:43:16 -0400 Subject: [PATCH] Attempt to fix control tty issues on attach MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- src/lxc/attach.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 4504a5b53..4a60cd299 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -1074,6 +1074,21 @@ static int attach_child_main(void* data) if (options->gid != (gid_t)-1) new_gid = options->gid; + /* setup the control tty */ + if (options->stdin_fd) { + if (setsid() < 0) { + SYSERROR("unable to setsid"); + shutdown(ipc_socket, SHUT_RDWR); + rexit(-1); + } + + if (ioctl(options->stdin_fd, TIOCSCTTY, (char *)NULL) < 0) { + SYSERROR("unable to TIOCSTTY"); + shutdown(ipc_socket, SHUT_RDWR); + rexit(-1); + } + } + /* try to set the uid/gid combination */ if ((new_gid != 0 || options->namespaces & CLONE_NEWUSER)) { if (setgid(new_gid) || setgroups(0, NULL)) { -- 2.47.2