Skip to content

Commit

Permalink
do not set empty $HOME
Browse files Browse the repository at this point in the history
Make sure to not set an empty $HOME for containers and let it default to
"/".

containers/crun#599 is required to fully
address containers#9378.

Partially-Fixes: containers#9378
Signed-off-by: Valentin Rothberg <[email protected]>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <[email protected]>
  • Loading branch information
vrothberg authored and mheon committed Feb 18, 2021
1 parent bddbe98 commit 32350c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
6 changes: 6 additions & 0 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 32350c7

Please sign in to comment.