fix: wildcard on commands
This commit is contained in:
parent
69a3f853bd
commit
9690ec1b00
@ -9,6 +9,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -26,6 +27,22 @@ var (
|
|||||||
cmdNotAllowed = []byte("Command not allowed.")
|
cmdNotAllowed = []byte("Command not allowed.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var commandShell []string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
|
path, err := exec.LookPath("bash")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
path, err = exec.LookPath("sh")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
commandShell = []string{path, "-c"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// command handles the requests for VCS related commands: git, svn and mercurial
|
// command handles the requests for VCS related commands: git, svn and mercurial
|
||||||
func command(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func command(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// Upgrades the connection to a websocket and checks for fb.Errors.
|
// Upgrades the connection to a websocket and checks for fb.Errors.
|
||||||
@ -87,6 +104,10 @@ func command(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
|||||||
path = filepath.Clean(path)
|
path = filepath.Clean(path)
|
||||||
buff := new(bytes.Buffer)
|
buff := new(bytes.Buffer)
|
||||||
|
|
||||||
|
if len(commandShell) == 0 {
|
||||||
|
command = append(commandShell, command...)
|
||||||
|
}
|
||||||
|
|
||||||
// Sets up the command executation.
|
// Sets up the command executation.
|
||||||
cmd := exec.Command(command[0], command[1:]...)
|
cmd := exec.Command(command[0], command[1:]...)
|
||||||
cmd.Dir = path
|
cmd.Dir = path
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user