From b873a5167c51c3cc83ace34cae2c36f88a469144 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 15 Jan 2025 22:42:07 -0800 Subject: [PATCH] tests/int: add hooks argv[0] test Looking into old opened runc issues, I noticed #1663 is there without any resolution, and wrote this simple test checking if we mangle hook's argv[0] in any way. Apparently we're good, but the test actually makes sense to have. Signed-off-by: Kir Kolyshkin --- tests/integration/hooks.bats | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/integration/hooks.bats b/tests/integration/hooks.bats index e9d62b0e6c5..8b53a780d67 100644 --- a/tests/integration/hooks.bats +++ b/tests/integration/hooks.bats @@ -63,3 +63,20 @@ function teardown() { runc run ct1 [ "$status" -eq 0 ] } + +# https://github.com/opencontainers/runc/issues/1663 +@test "runc run [hook's argv is preserved]" { + # Check that argv[0] and argv[1] passed to the hook's binary + # exactly as set in config.json. + update_config '.hooks |= {"startContainer": [{"path": "/bin/busybox", "args": ["cat", "/nosuchfile"]}]}' + runc run ct1 + [ "$status" -ne 0 ] + [[ "$output" == *"cat: can't open"*"/nosuchfile"* ]] + + # Busybox also accepts commands where argv[0] is "busybox", + # and argv[1] is applet name. Test this as well. + update_config '.hooks |= {"startContainer": [{"path": "/bin/busybox", "args": ["busybox", "cat", "/nosuchfile"]}]}' + runc run ct1 + [ "$status" -ne 0 ] + [[ "$output" == *"cat: can't open"*"/nosuchfile"* ]] +}