mirror of
https://github.com/opencontainers/runc.git
synced 2025-09-26 19:41:35 +08:00
test: check whether runc set a correct default home env or not
Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
@@ -352,3 +352,17 @@ EOF
|
||||
[ ${#lines[@]} -eq 1 ]
|
||||
[[ ${lines[0]} = *"exec /run.sh: no such file or directory"* ]]
|
||||
}
|
||||
|
||||
# https://github.com/opencontainers/runc/issues/4688
|
||||
@test "runc exec check default home" {
|
||||
# --user can't work in rootless containers that don't have idmap.
|
||||
[ $EUID -ne 0 ] && requires rootless_idmap
|
||||
echo 'tempuser:x:2000:2000:tempuser:/home/tempuser:/bin/sh' >>rootfs/etc/passwd
|
||||
|
||||
runc run -d --console-socket "$CONSOLE_SOCKET" test
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
runc exec -u 2000 test sh -c "echo \$HOME"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${lines[0]}" = "/home/tempuser" ]
|
||||
}
|
||||
|
@@ -219,3 +219,19 @@ EOF
|
||||
[ ${#lines[@]} -eq 1 ]
|
||||
[[ ${lines[0]} = "exec /run.sh: no such file or directory" ]]
|
||||
}
|
||||
|
||||
# https://github.com/opencontainers/runc/issues/4688
|
||||
@test "runc run check default home" {
|
||||
# cannot start containers as another user in rootless setup without idmap
|
||||
[ $EUID -ne 0 ] && requires rootless_idmap
|
||||
echo 'tempuser:x:2000:2000:tempuser:/home/tempuser:/bin/sh' >>rootfs/etc/passwd
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
update_config ' .process.cwd = "/root"
|
||||
| .process.user.uid = 2000
|
||||
| .process.args |= ["sh", "-c", "echo $HOME"]'
|
||||
|
||||
runc run test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${lines[0]}" = "/home/tempuser" ]
|
||||
}
|
||||
|
Reference in New Issue
Block a user