diff --git a/libpod/define/exec_codes.go b/libpod/define/exec_codes.go index a84730e722..46a8e9d86a 100644 --- a/libpod/define/exec_codes.go +++ b/libpod/define/exec_codes.go @@ -29,6 +29,10 @@ func TranslateExecErrorToExitCode(originalEC int, err error) int { if errors.Is(err, ErrOCIRuntimeNotFound) { return ExecErrorCodeNotFound } + if errors.Is(err, ErrInvalidArg) { + return ExecErrorCodeGeneric + } + return originalEC } diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index efb9e13acc..c290fa3981 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -32,11 +32,7 @@ var _ = Describe("Podman exec", func() { // With no command session = podmanTest.Podman([]string{"exec", "test1"}) session.WaitWithDefaultTimeout() - expectedStatus := 255 - if IsRemote() { - expectedStatus = 125 - } - Expect(session).Should(ExitWithError(expectedStatus, "must provide a non-empty command to start an exec session: invalid argument")) + Expect(session).Should(ExitWithError(125, "must provide a non-empty command to start an exec session: invalid argument")) }) It("podman container exec simple command", func() { diff --git a/test/system/075-exec.bats b/test/system/075-exec.bats index f24d34d534..53f0c20b55 100644 --- a/test/system/075-exec.bats +++ b/test/system/075-exec.bats @@ -33,6 +33,9 @@ load helpers run_podman 127 exec $cid /no/such/command is "$output" ".*such file or dir" "podman exec /no/such/command" + run_podman 125 exec $cid + is "$output" ".*must provide a non-empty command to start an exec session" "podman exec must include a command" + # Done. Tell the container to stop. # The '-d' is because container exit is racy: the exec process itself # could get caught and killed by cleanup, causing this step to exit 137