Skip to content

Commit

Permalink
conditionally send stdin on remote run
Browse files Browse the repository at this point in the history
when running a container remotely, we should only be sending stdin when
running with --interactive; otherwise use nil.

Fixes: containers#4095

Signed-off-by: baude <[email protected]>
  • Loading branch information
baude committed Sep 24, 2019
1 parent 83b2348 commit 61a226f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/adapter/containers_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,12 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode
fmt.Println(cid)
return 0, nil
}
exitChan, errChan, err := r.attach(ctx, os.Stdin, os.Stdout, cid, true, c.String("detach-keys"))
inputStream := os.Stdin
// If -i is not set, clear stdin
if !c.Bool("interactive") {
inputStream = nil
}
exitChan, errChan, err := r.attach(ctx, inputStream, os.Stdout, cid, true, c.String("detach-keys"))
if err != nil {
return exitCode, err
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/varlinkapi/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ func (i *LibpodAPI) Attach(call iopodman.VarlinkCall, name string, detachKeys st
}

// ACK the client upgrade request
call.ReplyAttach()
if err := call.ReplyAttach(); err != nil {
return call.ReplyErrorOccurred(err.Error())
}

reader, writer, _, pw, streams := setupStreams(call)

Expand Down

0 comments on commit 61a226f

Please sign in to comment.