mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
runc exec -p: fix adding HOME to nil env
Before commit7dc24868, when process.env was nil, prepareEnv returned a flag telling HOME is not set, and it was added. Commit7dc24868moved the functionality of adding HOME into prepareEnv but did not properly handle nil case. As a result, runc exec -p with process.json having no env set resulted in an exec with no HOME set. Fix this, and add unit and integration tests. Fixes:7dc24868("libct: switch to numeric UID/GID/groups") Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -126,3 +126,20 @@ _EOF_
|
||||
[[ "$output" != *'TERM='* ]]
|
||||
[[ "$output" != *'PATH='* ]]
|
||||
}
|
||||
|
||||
@test "env HOME is set for runc exec -p with no process.env" {
|
||||
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# "env" is not set.
|
||||
cat <<_EOF_ >process.json
|
||||
{
|
||||
"args": ["/bin/env"],
|
||||
"cwd": "/"
|
||||
}
|
||||
_EOF_
|
||||
runc exec -p process.json test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
# Env should have HOME set from container's /etc/passwd.
|
||||
[[ "$output" == *'HOME=/root'* ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user