From b55167e04dd5a90dcbce61ea1f14867dbabea39b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 9 Jan 2025 16:53:05 -0800 Subject: [PATCH] tests/int/exec --user: check default HOME Historically, when HOME is not explicitly set in process.Env, and UID to run as doesn't have a corresponding entry in container's /etc/passwd, runc sets HOME=/ as a fallback. Add the corresponding check, for the sake of backward compatibility preservation. Signed-off-by: Kir Kolyshkin --- tests/integration/exec.bats | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/integration/exec.bats b/tests/integration/exec.bats index a92a23780..8e96f3ddd 100644 --- a/tests/integration/exec.bats +++ b/tests/integration/exec.bats @@ -126,6 +126,18 @@ function teardown() { runc exec --user 1000:1000 test_busybox id [ "$status" -eq 0 ] [[ "${output}" == "uid=1000 gid=1000"* ]] + + # Check the default value of HOME ("/") is set even in case when + # - HOME is not set in process.Env, and + # - there is no entry in container's /etc/passwd for a given UID. + # + # NOTE this is not a standard runtime feature, but rather + # a historical de facto behavior we're afraid to change. + + # shellcheck disable=SC2016 + runc exec --user 1000 test_busybox sh -u -c 'echo $HOME' + [ "$status" -eq 0 ] + [[ "$output" = "/" ]] } # https://github.com/opencontainers/runc/issues/3674.