From 32350c758ddfef52a53e7d74d4a68785bc54aaef Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 16 Feb 2021 14:15:21 +0100 Subject: [PATCH] do not set empty $HOME Make sure to not set an empty $HOME for containers and let it default to "/". https://github.com/containers/crun/pull/599 is required to fully address #9378. Partially-Fixes: #9378 Signed-off-by: Valentin Rothberg Signed-off-by: Matthew Heon --- libpod/container_internal_linux.go | 2 +- test/system/030-run.bats | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 952cc42d1b..8a55f01b15 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -457,7 +457,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { break } } - if !hasHomeSet { + if !hasHomeSet && execUser.Home != "" { c.config.Spec.Process.Env = append(c.config.Spec.Process.Env, fmt.Sprintf("HOME=%s", execUser.Home)) } diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 98e34238ef..49fa92f571 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -623,4 +623,10 @@ json-file | f fi } +@test "podman run - do not set empty HOME" { + # Regression test for #9378. + run_podman run --rm --user 100 $IMAGE printenv + is "$output" ".*HOME=/.*" +} + # vim: filetype=sh