mirror of
https://github.com/containers/podman
synced 2024-10-20 17:23:30 +00:00
Check if stdin is a term in --interactive --tty mode
If you are attempting to run a container in interactive mode, and want a --tty, then there must be a terminal in use. Docker exits right away when a user specifies to use a --interactive and --TTY but the stdin is not a tty. Currently podman will pull the image and then fail much later. Podman will continue to run but will print an warning message. Discussion in : https://github.com/containers/podman/issues/8916 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
af91f27d85
commit
00949d0bd8
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -106,6 +107,11 @@ func run(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// TODO: Breaking change should be made fatal in next major Release
|
||||
if cliVals.TTY && cliVals.Interactive && !terminal.IsTerminal(int(os.Stdin.Fd())) {
|
||||
logrus.Warnf("The input device is not a TTY. The --tty and --interactive flags might not work properly")
|
||||
}
|
||||
|
||||
if af := cliVals.Authfile; len(af) > 0 {
|
||||
if _, err := os.Stat(af); err != nil {
|
||||
return err
|
||||
|
|
|
@ -668,4 +668,15 @@ json-file | f
|
|||
is "$output" ".*HOME=/.*"
|
||||
}
|
||||
|
||||
@test "podman run --tty -i failure with no tty" {
|
||||
run_podman run --tty -i --rm $IMAGE echo hello < /dev/null
|
||||
is "$output" ".*The input device is not a TTY.*"
|
||||
|
||||
run_podman run --tty=false -i --rm $IMAGE echo hello < /dev/null
|
||||
is "$output" "hello"
|
||||
|
||||
run_podman run --tty -i=false --rm $IMAGE echo hello < /dev/null
|
||||
is "$output" "hello"
|
||||
}
|
||||
|
||||
# vim: filetype=sh
|
||||
|
|
Loading…
Reference in a new issue