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 <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2020-12-18 12:56:48 -08:00
parent 77b5d8ab5a
commit 8bd3b8786b
+30
View File
@@ -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 ]
}