mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
podman exec CID without command should exit 125
Fixes: https://github.com/containers/podman/issues/22329 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -29,6 +29,10 @@ func TranslateExecErrorToExitCode(originalEC int, err error) int {
|
|||||||
if errors.Is(err, ErrOCIRuntimeNotFound) {
|
if errors.Is(err, ErrOCIRuntimeNotFound) {
|
||||||
return ExecErrorCodeNotFound
|
return ExecErrorCodeNotFound
|
||||||
}
|
}
|
||||||
|
if errors.Is(err, ErrInvalidArg) {
|
||||||
|
return ExecErrorCodeGeneric
|
||||||
|
}
|
||||||
|
|
||||||
return originalEC
|
return originalEC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +32,7 @@ var _ = Describe("Podman exec", func() {
|
|||||||
// With no command
|
// With no command
|
||||||
session = podmanTest.Podman([]string{"exec", "test1"})
|
session = podmanTest.Podman([]string{"exec", "test1"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
expectedStatus := 255
|
Expect(session).Should(ExitWithError(125, "must provide a non-empty command to start an exec session: invalid argument"))
|
||||||
if IsRemote() {
|
|
||||||
expectedStatus = 125
|
|
||||||
}
|
|
||||||
Expect(session).Should(ExitWithError(expectedStatus, "must provide a non-empty command to start an exec session: invalid argument"))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman container exec simple command", func() {
|
It("podman container exec simple command", func() {
|
||||||
|
@ -33,6 +33,9 @@ load helpers
|
|||||||
run_podman 127 exec $cid /no/such/command
|
run_podman 127 exec $cid /no/such/command
|
||||||
is "$output" ".*such file or dir" "podman exec /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.
|
# Done. Tell the container to stop.
|
||||||
# The '-d' is because container exit is racy: the exec process itself
|
# 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
|
# could get caught and killed by cleanup, causing this step to exit 137
|
||||||
|
Reference in New Issue
Block a user