[lxc-devel] [lxd/master] exec: make sure to only use TIOCGPTPEER if available

brauner on Github lxc-bot at linuxcontainers.org
Thu Oct 29 19:18:45 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 504 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201029/c069b150/attachment.bin>
-------------- next part --------------
From 0814fd4d1145147f09314b64bd9b9740acb3be79 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 29 Oct 2020 20:17:17 +0100
Subject: [PATCH] exec: make sure to only use TIOCGPTPEER if available
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes: https://discuss.linuxcontainers.org/t/can-not-start-bash-on-a-container/9315
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/instance_exec.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lxd/instance_exec.go b/lxd/instance_exec.go
index 23f7ddbc2d..76db1bfaee 100644
--- a/lxd/instance_exec.go
+++ b/lxd/instance_exec.go
@@ -21,6 +21,7 @@ import (
 	"github.com/lxc/lxd/lxd/instance/instancetype"
 	"github.com/lxc/lxd/lxd/operations"
 	"github.com/lxc/lxd/lxd/response"
+	"github.com/lxc/lxd/lxd/state"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
 	log "github.com/lxc/lxd/shared/log15"
@@ -44,6 +45,7 @@ type execWs struct {
 	controlConnectedDone bool
 	fds                  map[int]string
 	devptsFd             *os.File
+	s                    *state.State
 }
 
 func (s *execWs) Metadata() interface{} {
@@ -133,7 +135,7 @@ func (s *execWs) Do(op *operations.Operation) error {
 		ttys = make([]*os.File, 1)
 		ptys = make([]*os.File, 1)
 
-		if s.devptsFd != nil {
+		if s.devptsFd != nil && s.s.OS.NativeTerminals {
 			ptys[0], ttys[0], err = shared.OpenPtyInDevpts(int(s.devptsFd.Fd()), s.rootUid, s.rootGid)
 			s.devptsFd.Close()
 			s.devptsFd = nil
@@ -504,6 +506,7 @@ func containerExecPost(d *Daemon, r *http.Request) response.Response {
 
 	if post.WaitForWS {
 		ws := &execWs{}
+		ws.s = d.State()
 		ws.fds = map[int]string{}
 
 		if inst.Type() == instancetype.Container {


More information about the lxc-devel mailing list