diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-05 09:37:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-05 09:37:59 +0200 |
commit | 47971909ae7a54c3a0b0fe4ebe33197c9e291657 (patch) | |
tree | b67689e7e2cc0e8c3ace91d31c3bf276b0784978 /cmd/podman | |
parent | 6260677012080aa6aa52ead7ec54261d8d6017a0 (diff) | |
parent | 34e82f81bdbdd26b82501bc2d27d18aaab5747dd (diff) | |
download | podman-47971909ae7a54c3a0b0fe4ebe33197c9e291657.tar.gz podman-47971909ae7a54c3a0b0fe4ebe33197c9e291657.tar.bz2 podman-47971909ae7a54c3a0b0fe4ebe33197c9e291657.zip |
Merge pull request #7125 from QiWang19/fd-validate
validate fds --preserve-fds
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/containers/exec.go | 7 | ||||
-rw-r--r-- | cmd/podman/containers/run.go | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/cmd/podman/containers/exec.go b/cmd/podman/containers/exec.go index da450054f..e301ca588 100644 --- a/cmd/podman/containers/exec.go +++ b/cmd/podman/containers/exec.go @@ -10,6 +10,7 @@ import ( "github.com/containers/podman/v2/libpod/define" "github.com/containers/podman/v2/pkg/domain/entities" envLib "github.com/containers/podman/v2/pkg/env" + "github.com/containers/podman/v2/pkg/rootless" "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -110,6 +111,12 @@ func exec(_ *cobra.Command, args []string) error { execOpts.Envs = envLib.Join(execOpts.Envs, cliEnv) + for fd := 3; fd < int(3+execOpts.PreserveFDs); fd++ { + if !rootless.IsFdInherited(fd) { + return errors.Errorf("file descriptor %d is not available - the preserve-fds option requires that file descriptors must be passed", fd) + } + } + if !execDetach { streams := define.AttachStreams{} streams.OutputStream = os.Stdout diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index 39d2c157e..a84cb6814 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -126,6 +126,11 @@ func run(cmd *cobra.Command, args []string) error { if err := createInit(cmd); err != nil { return err } + for fd := 3; fd < int(3+runOpts.PreserveFDs); fd++ { + if !rootless.IsFdInherited(fd) { + return errors.Errorf("file descriptor %d is not available - the preserve-fds option requires that file descriptors must be passed", fd) + } + } imageName := args[0] if !cliVals.RootFS { |