Skip to content

Commit

Permalink
Fix issue with relative paths and command execution
Browse files Browse the repository at this point in the history
  • Loading branch information
dexpota committed Aug 25, 2019
1 parent 0aa7395 commit d3fd9bd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/url"
"os"
"os/exec"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -328,6 +329,13 @@ func handleHook(h *hook.Hook, rid string, headers, query, payload *map[string]in

// check the command exists
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 {
log.Printf("unable to locate command: '%s'", h.ExecuteCommand)

Expand Down

0 comments on commit d3fd9bd

Please sign in to comment.