mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-11 08:04:44 +00:00
Fix issue with relative paths and command execution
This commit is contained in:
parent
0aa7395e21
commit
d3fd9bddd9
1 changed files with 8 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -328,6 +329,13 @@ func handleHook(h *hook.Hook, rid string, headers, query, payload *map[string]in
|
||||||
|
|
||||||
// check the command exists
|
// check the command exists
|
||||||
cmdPath, err := exec.LookPath(h.ExecuteCommand)
|
cmdPath, err := exec.LookPath(h.ExecuteCommand)
|
||||||
|
if err != nil {
|
||||||
|
// give a last chance, maybe is a relative path
|
||||||
|
relativeToCwd := filepath.Join(h.CommandWorkingDirectory, h.ExecuteCommand)
|
||||||
|
// check the command exists
|
||||||
|
cmdPath, err = exec.LookPath(relativeToCwd)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("unable to locate command: '%s'", h.ExecuteCommand)
|
log.Printf("unable to locate command: '%s'", h.ExecuteCommand)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue