add run-as to run hook in other user context

This commit is contained in:
Stefan Schubert 2023-07-05 19:50:07 +02:00
parent f187592147
commit af3ceffdac
No known key found for this signature in database
GPG key ID: B88EC486BDF3E5AD
5 changed files with 47 additions and 0 deletions

View file

@ -575,6 +575,9 @@ func handleHook(h *hook.Hook, r *hook.Request) (string, error) {
}
cmd := exec.Command(cmdPath)
if h.RunAs != "" {
setUser(cmd, h.RunAs)
}
cmd.Dir = h.CommandWorkingDirectory
cmd.Args, errors = h.ExtractCommandArguments(r)