Skip to content

Commit 710ae85

Browse files
authored
fix: env error (#3056)
Signed-off-by: redscholar <blacktiledhouse@gmail.com>
1 parent b7102ea commit 710ae85

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

pkg/connector/local_connector.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ func (c *localConnector) ExecuteCommand(ctx context.Context, cmd string) ([]byte
125125
klog.V(5).InfoS("exec local command", "cmd", cmd)
126126
// in
127127
command := c.Cmd.CommandContext(ctx, "sudo", "-SE", c.shell, "-c", cmd)
128-
command.SetEnv([]string{"SUDO_USER=" + c.User})
128+
// Append SUDO_USER to existing environment variables instead of replacing them
129+
command.SetEnv(append(os.Environ(), "SUDO_USER="+c.User))
129130
if c.Password != "" {
130131
command.SetStdin(bytes.NewBufferString(c.Password + "\n"))
131132
}

0 commit comments

Comments
 (0)