Remove the process default ENV

With the change in #3542 it breaks $PATH handling for images becuase our
default spec always sets a PATH on the process's .Env.

This removes the default and adds an Opt to add this back.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2019-08-19 18:18:58 +00:00
parent fc9335d75c
commit 7379fa6631
2 changed files with 7 additions and 1 deletions

View File

@ -141,7 +141,6 @@ func populateDefaultUnixSpec(ctx context.Context, s *Spec, id string) error {
Path: defaultRootfsPath, Path: defaultRootfsPath,
}, },
Process: &specs.Process{ Process: &specs.Process{
Env: defaultUnixEnv,
Cwd: "/", Cwd: "/",
NoNewPrivileges: true, NoNewPrivileges: true,
User: specs.User{ User: specs.User{

View File

@ -151,6 +151,13 @@ func WithEnv(environmentVariables []string) SpecOpts {
} }
} }
// WithDefaultPathEnv sets the $PATH environment variable to the
// default PATH defined in this package.
func WithDefaultPathEnv(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, defaultUnixEnv)
return nil
}
// replaceOrAppendEnvValues returns the defaults with the overrides either // replaceOrAppendEnvValues returns the defaults with the overrides either
// replaced by env key or appended to the list // replaced by env key or appended to the list
func replaceOrAppendEnvValues(defaults, overrides []string) []string { func replaceOrAppendEnvValues(defaults, overrides []string) []string {