From f0ce62304468e66f64a08fa1964d64aee667c31f Mon Sep 17 00:00:00 2001 From: lifubang Date: Sun, 27 Oct 2024 00:41:44 +0800 Subject: [PATCH] test access stdio in userns container Signed-off-by: lifubang --- tests/integration/userns.bats | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/integration/userns.bats b/tests/integration/userns.bats index 78583ba4d45..ab76b4fc787 100644 --- a/tests/integration/userns.bats +++ b/tests/integration/userns.bats @@ -36,6 +36,27 @@ function teardown() { fi } +@test "runc check stdio permission in userns [terminal=false]" { + update_config ' .process.terminal = false + | .process.args = ["sh", "-c", "echo errormsg > /dev/stderr"]' + + touch log + __runc create test_busybox >log 2>&1 + + runc start test_busybox + [ "$status" -eq 0 ] + + wait_for_container 10 1 test_busybox stopped + + out=$(cat log) + # Keep this to debug is useful once we have a regression about this. + echo "$out" >&2 + + # We should let stdio could be accessed in user ns container. + # Please see https://github.com/opencontainers/runc/issues/4475 + [[ "$out" = "errormsg" ]] +} + @test "userns with simple mount" { update_config ' .process.args += ["-c", "stat /tmp/mount-1/foo.txt"] | .mounts += [{"source": "source-accessible/dir", "destination": "/tmp/mount-1", "options": ["bind"]}] '