The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7732
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From a32272e33376a801165b7bacd56beac40156fc9d Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Thu, 6 Aug 2020 11:29:01 +0200 Subject: [PATCH] exec: fix OpenPtyInDevpts() Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- lxd/instance_exec.go | 5 ++++- shared/util_linux.go | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lxd/instance_exec.go b/lxd/instance_exec.go index 5ca8006228..da59162df3 100644 --- a/lxd/instance_exec.go +++ b/lxd/instance_exec.go @@ -132,10 +132,13 @@ func (s *execWs) Do(op *operations.Operation) error { if s.req.Interactive { ttys = make([]*os.File, 1) ptys = make([]*os.File, 1) - ptys[0], ttys[0], err = shared.OpenPtyInDevpts(int(s.devptsFd.Fd()), s.rootUid, s.rootGid) + if s.devptsFd != nil { + ptys[0], ttys[0], err = shared.OpenPtyInDevpts(int(s.devptsFd.Fd()), s.rootUid, s.rootGid) s.devptsFd.Close() s.devptsFd = nil + } else { + ptys[0], ttys[0], err = shared.OpenPty(s.rootUid, s.rootGid) } if err != nil { return err diff --git a/shared/util_linux.go b/shared/util_linux.go index eaba564795..ee689dd8aa 100644 --- a/shared/util_linux.go +++ b/shared/util_linux.go @@ -439,7 +439,11 @@ func OpenPtyInDevpts(devpts_fd int, uid, gid int64) (*os.File, *os.File, error) } pty = os.NewFile(ptyFd, fmt.Sprintf("/dev/pts/%d", id)) - } else if devpts_fd < 0 { + } else { + if devpts_fd >= 0 { + return nil, nil, fmt.Errorf("TIOCGPTPEER required but not available") + } + // Get the pty side. id := 0 _, _, errno = unix.Syscall(unix.SYS_IOCTL, uintptr(ptx.Fd()), unix.TIOCGPTN, uintptr(unsafe.Pointer(&id)))
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel