Skip to content

Commit 7379fa6

Browse files
committed
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 <[email protected]>
1 parent fc9335d commit 7379fa6

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

oci/spec.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ func populateDefaultUnixSpec(ctx context.Context, s *Spec, id string) error {
141141
Path: defaultRootfsPath,
142142
},
143143
Process: &specs.Process{
144-
Env: defaultUnixEnv,
145144
Cwd: "/",
146145
NoNewPrivileges: true,
147146
User: specs.User{

oci/spec_opts.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ func WithEnv(environmentVariables []string) SpecOpts {
151151
}
152152
}
153153

154+
// WithDefaultPathEnv sets the $PATH environment variable to the
155+
// default PATH defined in this package.
156+
func WithDefaultPathEnv(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
157+
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, defaultUnixEnv)
158+
return nil
159+
}
160+
154161
// replaceOrAppendEnvValues returns the defaults with the overrides either
155162
// replaced by env key or appended to the list
156163
func replaceOrAppendEnvValues(defaults, overrides []string) []string {

0 commit comments

Comments
 (0)