diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-19 15:48:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 15:48:25 +0200 |
commit | 45b3d61c5550f8a998f2117c52b26e53955ba56a (patch) | |
tree | 23b0d866c01cd1340d7fbd4d4f808ab6fdee6b88 | |
parent | 7e2a1b34c30e085275de1c484dc472682876746c (diff) | |
parent | a7e864e6e7de894d4edde4fff00e53dc6a0b5074 (diff) | |
download | podman-45b3d61c5550f8a998f2117c52b26e53955ba56a.tar.gz podman-45b3d61c5550f8a998f2117c52b26e53955ba56a.tar.bz2 podman-45b3d61c5550f8a998f2117c52b26e53955ba56a.zip |
Merge pull request #7343 from mheon/update_defaultenv
Ensure DefaultEnvVariables is used in Specgen
-rw-r--r-- | pkg/env/env.go | 14 | ||||
-rw-r--r-- | pkg/spec/spec.go | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/pkg/env/env.go b/pkg/env/env.go index a16007a50..0d55e5560 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -12,14 +12,16 @@ import ( "github.com/pkg/errors" ) -// DefaultEnvVariables sets $PATH and $TERM. -var DefaultEnvVariables = map[string]string{ - "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", - "TERM": "xterm", -} - const whiteSpaces = " \t" +// DefaultEnvVariables returns a default environment, with $PATH and $TERM set. +func DefaultEnvVariables() map[string]string { + return map[string]string{ + "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "TERM": "xterm", + } +} + // Slice transforms the specified map of environment variables into a // slice. If a value is non-empty, the key and value are joined with '='. func Slice(m map[string]string) []string { diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go index c7a838d4c..893ae3cab 100644 --- a/pkg/spec/spec.go +++ b/pkg/spec/spec.go @@ -321,13 +321,13 @@ func (config *CreateConfig) createConfigToOCISpec(runtime *libpod.Runtime, userM // config. var defaultEnv map[string]string if runtimeConfig == nil { - defaultEnv = env.DefaultEnvVariables + defaultEnv = env.DefaultEnvVariables() } else { defaultEnv, err = env.ParseSlice(runtimeConfig.Containers.Env) if err != nil { return nil, errors.Wrap(err, "Env fields in containers.conf failed ot parse") } - defaultEnv = env.Join(env.DefaultEnvVariables, defaultEnv) + defaultEnv = env.Join(env.DefaultEnvVariables(), defaultEnv) } if err := addRlimits(config, &g); err != nil { |