Skip to content

Commit

Permalink
Merge pull request #8717 from rhatdan/stdin
Browse files Browse the repository at this point in the history
Close the stdin/tty when using podman as a restAPI.
  • Loading branch information
openshift-merge-robot authored Dec 17, 2020
2 parents d291013 + b96c348 commit 7592f8f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/podman/system/service_abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package system
import (
"context"
"net"
"os"
"strings"

api "github.com/containers/podman/v2/pkg/api/server"
Expand All @@ -13,6 +14,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"golang.org/x/sys/unix"
)

func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entities.PodmanConfig) error {
Expand All @@ -34,6 +36,15 @@ func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entiti
listener = &l
}

// Close stdin, so shortnames will not prompt
devNullfile, err := os.Open(os.DevNull)
if err != nil {
return err
}
defer devNullfile.Close()
if err := unix.Dup2(int(devNullfile.Fd()), int(os.Stdin.Fd())); err != nil {
return err
}
rt, err := infra.GetRuntime(context.Background(), flags, cfg)
if err != nil {
return err
Expand Down

0 comments on commit 7592f8f

Please sign in to comment.