summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-17 14:09:46 +0000
committerGitHub <noreply@github.com>2020-12-17 14:09:46 +0000
commit7592f8fbb4fc61c2c897469ef747a400334f525d (patch)
tree041276129dd36e04c0fff40a32d529f3df37ca6a
parentd29101340414da5649ba0452d184fa7d17ccc8c1 (diff)
parentb96c3489d04331b2283ef637e348870c83763f85 (diff)
downloadpodman-7592f8fbb4fc61c2c897469ef747a400334f525d.tar.gz
podman-7592f8fbb4fc61c2c897469ef747a400334f525d.tar.bz2
podman-7592f8fbb4fc61c2c897469ef747a400334f525d.zip
Merge pull request #8717 from rhatdan/stdin
Close the stdin/tty when using podman as a restAPI.
-rw-r--r--cmd/podman/system/service_abi.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/podman/system/service_abi.go b/cmd/podman/system/service_abi.go
index 8c52616be..ed35fbb04 100644
--- a/cmd/podman/system/service_abi.go
+++ b/cmd/podman/system/service_abi.go
@@ -5,6 +5,7 @@ package system
import (
"context"
"net"
+ "os"
"strings"
api "github.com/containers/podman/v2/pkg/api/server"
@@ -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 {
@@ -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