Skip to content

Commit

Permalink
Merge pull request #5027 from laurazard/run-hooks-reexec-env-var
Browse files Browse the repository at this point in the history
hooks: set expected environment when executing
  • Loading branch information
vvoland authored Apr 18, 2024
2 parents 78089c5 + 5011759 commit b982833
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cli-plugins/manager/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package manager

import (
"encoding/json"
"os"
"os/exec"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -113,7 +114,10 @@ func (p *Plugin) RunHook(cmdName string, flags map[string]string) ([]byte, error
return nil, wrapAsPluginError(err, "failed to marshall hook data")
}

hookCmdOutput, err := exec.Command(p.Path, p.Name, HookSubcommandName, string(hDataBytes)).Output()
pCmd := exec.Command(p.Path, p.Name, HookSubcommandName, string(hDataBytes))
pCmd.Env = os.Environ()
pCmd.Env = append(pCmd.Env, ReexecEnvvar+"="+os.Args[0])
hookCmdOutput, err := pCmd.Output()
if err != nil {
return nil, wrapAsPluginError(err, "failed to execute plugin hook subcommand")
}
Expand Down

0 comments on commit b982833

Please sign in to comment.