Skip to content

Commit

Permalink
Merge pull request #7343 from mheon/update_defaultenv
Browse files Browse the repository at this point in the history
Ensure DefaultEnvVariables is used in Specgen
  • Loading branch information
openshift-merge-robot authored Aug 19, 2020
2 parents 7e2a1b3 + a7e864e commit 45b3d61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions pkg/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 45b3d61

Please sign in to comment.