Skip to content

Commit aa7713e

Browse files
authored
Remove env vars in shellexec if the value is empty in the overriding map (#2007)
1 parent 7d1c805 commit aa7713e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pkg/shellexec/shellexec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ func StartLocalShellProc(logCtx context.Context, termSize waveobj.TermSize, cmdS
534534
if len(pamEnvs) > 0 {
535535
// We only want to set the XDG variables from the PAM environment, all others should already be correct or may have been overridden by something else out of our control
536536
for k := range pamEnvs {
537-
if _, ok := varsToReplace[k]; ok && len(pamEnvs[k]) > 0 {
537+
if _, ok := varsToReplace[k]; ok {
538538
varsToReplace[k] = pamEnvs[k]
539539
}
540540
}

pkg/util/shellutil/shellutil.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,10 @@ func UpdateCmdEnv(cmd *exec.Cmd, envVars map[string]string) {
244244
envKey := GetEnvStrKey(envStr)
245245
newEnvVal, ok := envVars[envKey]
246246
if ok {
247-
if newEnvVal == "" {
248-
continue
249-
}
250-
newEnv = append(newEnv, envKey+"="+newEnvVal)
251247
found[envKey] = true
248+
if newEnvVal != "" {
249+
newEnv = append(newEnv, envKey+"="+newEnvVal)
250+
}
252251
} else {
253252
newEnv = append(newEnv, envStr)
254253
}

0 commit comments

Comments
 (0)