From 4d410b7cb7191c2fdc4ff975136390b0a172a371 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 15 Apr 2020 16:17:11 -0400 Subject: Ensure that Streams are set to defaults for HTTP attach If not overridden, we should use the attach configuration given when the exec session was first created. Also, setting streams should not conflict with a TTY - the two are allowed together with Attach and should be allowed together here. Signed-off-by: Matthew Heon --- libpod/container_exec.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libpod/container_exec.go b/libpod/container_exec.go index 9698ecd19..8ae9df1ae 100644 --- a/libpod/container_exec.go +++ b/libpod/container_exec.go @@ -158,9 +158,6 @@ func (c *Container) ExecCreate(config *ExecConfig) (string, error) { if len(config.Command) == 0 { return "", errors.Wrapf(define.ErrInvalidArg, "must provide a non-empty command to start an exec session") } - if config.Terminal && (config.AttachStdin || config.AttachStdout || config.AttachStderr) { - return "", errors.Wrapf(define.ErrInvalidArg, "cannot specify streams to attach to when exec session has a pseudoterminal") - } // Verify that we are in a good state to continue if !c.ensureState(define.ContainerStateRunning) { @@ -362,6 +359,13 @@ func (c *Container) ExecHTTPStartAndAttach(sessionID string, httpCon net.Conn, h return err } + if streams == nil { + streams = new(HTTPAttachStreams) + streams.Stdin = session.Config.AttachStdin + streams.Stdout = session.Config.AttachStdout + streams.Stderr = session.Config.AttachStderr + } + pid, attachChan, err := c.ociRuntime.ExecContainerHTTP(c, session.ID(), execOpts, httpCon, httpBuf, streams, cancel) if err != nil { return err -- cgit v1.2.3-54-g00ecf