mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53: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:
+1
-4
@@ -22,10 +22,7 @@ import (
|
||||
//
|
||||
// Returns the prepared environment.
|
||||
func prepareEnv(env []string, uid int) ([]string, error) {
|
||||
if env == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var homeIsSet bool
|
||||
homeIsSet := false
|
||||
|
||||
// Deduplication code based on dedupEnv from Go 1.22 os/exec.
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ func TestPrepareEnv(t *testing.T) {
|
||||
tests := []struct {
|
||||
env, wantEnv []string
|
||||
}{
|
||||
{
|
||||
env: nil,
|
||||
wantEnv: []string{home},
|
||||
},
|
||||
{
|
||||
env: []string{},
|
||||
wantEnv: []string{home},
|
||||
|
||||
Reference in New Issue
Block a user