fix: use golang.org/x/sys/execabs (#224)
Closes https://github.com/ooni/probe-engine/issues/1195
This commit is contained in:
@@ -7,9 +7,10 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/execabs"
|
||||
)
|
||||
|
||||
func fatalOnError(err error) {
|
||||
@@ -70,7 +71,7 @@ func main() {
|
||||
options = append(options, *entry.Input)
|
||||
}
|
||||
log.Printf("run: go %s", strings.Join(options, " "))
|
||||
cmd := exec.Command("go", options...)
|
||||
cmd := execabs.Command("go", options...)
|
||||
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
||||
err = cmd.Run()
|
||||
fatalOnError(err)
|
||||
|
||||
@@ -7,12 +7,13 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/execabs"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/resolver"
|
||||
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored"
|
||||
@@ -295,7 +296,7 @@ func TestHijackHTTP(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("expected an error here")
|
||||
}
|
||||
var exitErr *exec.ExitError
|
||||
var exitErr *execabs.ExitError
|
||||
if !errors.As(err, &exitErr) {
|
||||
t.Fatal("not the error type we expected")
|
||||
}
|
||||
@@ -335,7 +336,7 @@ func TestHijackHTTPS(t *testing.T) {
|
||||
t.Fatal("expected an error here")
|
||||
}
|
||||
t.Log(err)
|
||||
var exitErr *exec.ExitError
|
||||
var exitErr *execabs.ExitError
|
||||
if !errors.As(err, &exitErr) {
|
||||
t.Fatal("not the error type we expected")
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/execabs"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/apex/log/handlers/cli"
|
||||
"github.com/miekg/dns"
|
||||
@@ -243,7 +244,7 @@ func mustx(err error, message string, osExit func(int)) {
|
||||
if err != nil {
|
||||
var (
|
||||
exitcode = 1
|
||||
exiterr *exec.ExitError
|
||||
exiterr *execabs.ExitError
|
||||
)
|
||||
if errors.As(err, &exiterr) {
|
||||
exitcode = exiterr.ExitCode()
|
||||
|
||||
@@ -4,9 +4,10 @@ package shellx
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/execabs"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/google/shlex"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
||||
@@ -22,7 +23,7 @@ type runconfig struct {
|
||||
|
||||
func run(config runconfig) error {
|
||||
config.loginfof("exec: %s %s", config.name, strings.Join(config.args, " "))
|
||||
cmd := exec.Command(config.name, config.args...)
|
||||
cmd := execabs.Command(config.name, config.args...)
|
||||
cmd.Stdout = config.stdout
|
||||
cmd.Stderr = config.stderr
|
||||
err := cmd.Run()
|
||||
|
||||
Reference in New Issue
Block a user