From d3058db06885273788ee4745834e3263ef0db344 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 18 Dec 2020 12:56:48 -0800 Subject: [PATCH] test: add case for GH #2086 Commit 5e0e67d7 ("fix permission denied") modified some code but did not provide a test case. This is a test case that was tested to fail before and succeed after the above commit. For more details, see https://github.com/opencontainers/runc/pull/2086 Signed-off-by: Kir Kolyshkin --- tests/integration/cwd.bats | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/integration/cwd.bats diff --git a/tests/integration/cwd.bats b/tests/integration/cwd.bats new file mode 100644 index 00000000000..fbc5eefb727 --- /dev/null +++ b/tests/integration/cwd.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats + +load helpers + +function setup() { + teardown_busybox + setup_busybox +} + +function teardown() { + teardown_busybox +} + +# Test case for https://github.com/opencontainers/runc/pull/2086 +@test "runc exec --user with no access to cwd" { + requires root + + chown 42 rootfs/root + chmod 700 rootfs/root + + update_config ' .process.cwd = "/root" + | .process.user.uid = 42 + | .process.args |= ["sleep", "1h"]' + + runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox + [ "$status" -eq 0 ] + + runc exec --user 0 test_busybox true + [ "$status" -eq 0 ] +}