mirror of
https://github.com/containers/podman.git
synced 2025-06-22 18:08:11 +08:00
Close the stdin/tty when using podman as a restAPI.
Currently the service is attempting to prompt on shortname expansion if you run with a terminal. This change will cause the service to default to no terminal and not prompt. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -5,6 +5,7 @@ package system
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
api "github.com/containers/podman/v2/pkg/api/server"
|
api "github.com/containers/podman/v2/pkg/api/server"
|
||||||
@ -13,6 +14,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entities.PodmanConfig) error {
|
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
|
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)
|
rt, err := infra.GetRuntime(context.Background(), flags, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user