From 7a64ce35db378e69b813aab7f026f11fbaf7e7f9 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 5 Aug 2020 13:48:01 -0400 Subject: Ensure that exec errors write exit codes to the DB In local Podman, the frontend interprets the error and exit code given by the Exec API to determine the appropriate exit code to set for Podman itself; special cases like a missing executable receive special exit codes. Exec for the remote API, however, has to do this inside Libpod itself, as Libpod will be directly queried (via the Inspect API for exec sessions) to get the exit code. This was done correctly when the exec session started properly, but we did not properly handle cases where the OCI runtime fails before the exec session can properly start. Making two error returns that would otherwise not set exit code actually do so should resolve the issue. Fixes #6893 Signed-off-by: Matthew Heon --- test/system/075-exec.bats | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/system') diff --git a/test/system/075-exec.bats b/test/system/075-exec.bats index b2c49510a..aa6e2bd28 100644 --- a/test/system/075-exec.bats +++ b/test/system/075-exec.bats @@ -19,6 +19,15 @@ load helpers run_podman exec $cid sh -c "cat /$rand_filename" is "$output" "$rand_content" "Can exec and see file in running container" + + # Specially defined situations: exec a dir, or no such command. + # We don't check the full error message because runc & crun differ. + run_podman 126 exec $cid /etc + is "$output" ".*permission denied" "podman exec /etc" + run_podman 127 exec $cid /no/such/command + is "$output" ".*such file or dir" "podman exec /no/such/command" + + # Done run_podman exec $cid rm -f /$rand_filename run_podman wait $cid -- cgit v1.2.3-54-g00ecf