summaryrefslogtreecommitdiff
path: root/cmd/podman/system/unshare.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-06-02 04:24:01 -0400
committerGitHub <noreply@github.com>2022-06-02 04:24:01 -0400
commit2958aee08389aa5e89794f5e5b4f30ac3328d071 (patch)
tree3fa18d5bf4759bfe6281725760141e3cc65f1c49 /cmd/podman/system/unshare.go
parentf27f9de5e668afb50073f125f25f8f61618a5742 (diff)
parent4a834655118a83898a20b20663dfd048855fbf5f (diff)
downloadpodman-2958aee08389aa5e89794f5e5b4f30ac3328d071.tar.gz
podman-2958aee08389aa5e89794f5e5b4f30ac3328d071.tar.bz2
podman-2958aee08389aa5e89794f5e5b4f30ac3328d071.zip
Merge pull request #14417 from Luap99/machine-ssh
podman machine ssh: set correct exit code
Diffstat (limited to 'cmd/podman/system/unshare.go')
-rw-r--r--cmd/podman/system/unshare.go21
1 files changed, 2 insertions, 19 deletions
diff --git a/cmd/podman/system/unshare.go b/cmd/podman/system/unshare.go
index 0ae5b81ad..1ed08eac3 100644
--- a/cmd/podman/system/unshare.go
+++ b/cmd/podman/system/unshare.go
@@ -2,10 +2,10 @@ package system
import (
"os"
- "os/exec"
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v4/cmd/podman/registry"
+ "github.com/containers/podman/v4/cmd/podman/utils"
"github.com/containers/podman/v4/pkg/domain/entities"
"github.com/containers/podman/v4/pkg/rootless"
"github.com/pkg/errors"
@@ -60,22 +60,5 @@ func unshare(cmd *cobra.Command, args []string) error {
}
err := registry.ContainerEngine().Unshare(registry.Context(), args, unshareOptions)
- if err != nil {
- if exitError, ok := err.(*exec.ExitError); ok {
- // the user command inside the unshare env has failed
- // we set the exit code, do not return the error to the user
- // otherwise "exit status X" will be printed
- registry.SetExitCode(exitError.ExitCode())
- return nil
- }
- // cmd.Run() can return fs.ErrNotExist, fs.ErrPermission or exec.ErrNotFound
- // follow podman run/exec standard with the exit codes
- if errors.Is(err, os.ErrNotExist) || errors.Is(err, exec.ErrNotFound) {
- registry.SetExitCode(127)
- } else if errors.Is(err, os.ErrPermission) {
- registry.SetExitCode(126)
- }
- return err
- }
- return nil
+ return utils.HandleOSExecError(err)
}