aboutsummaryrefslogtreecommitdiff
path: root/pkg/env
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-07-31 13:52:14 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-08-20 12:16:53 -0400
commit23348e7f313a570c513772a88db7f2741c8242ba (patch)
tree533378923a35ce3d92119b96adce2cf77a5b32ef /pkg/env
parentdbcb6f5892852ecf846faeef10d9b0237c472f99 (diff)
downloadpodman-23348e7f313a570c513772a88db7f2741c8242ba.tar.gz
podman-23348e7f313a570c513772a88db7f2741c8242ba.tar.bz2
podman-23348e7f313a570c513772a88db7f2741c8242ba.zip
Ensure DefaultEnvVariables is used in Specgen
When we rewrote Podman's pkg/spec, one of the things that was lost was our use of a set of default environment variables, that ensure all containers have at least $PATH and $TERM set. While we're in the process of re-adding it, change it from a variable to a function, so we can ensure the Join function does not overwrite it and corrupt the defaults. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/env')
-rw-r--r--pkg/env/env.go14
1 files changed, 8 insertions, 6 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 {