diff --git a/cmd.sh b/cmd.sh index f23c8f3..bb4b219 100644 --- a/cmd.sh +++ b/cmd.sh @@ -1,3 +1,3 @@ TAGS=with_gvisor,with_quic,with_wireguard,with_ech,with_utls,with_clash_api,with_grpc # TAGS=with_dhcp,with_low_memory,with_conntrack -go run --tags $(TAGS) ./cmd *@ \ No newline at end of file +go run --tags $TAGS ./cmd $@ \ No newline at end of file diff --git a/config/admin_service_cmd_runner.go b/config/admin_service_cmd_runner.go index e22b6f2..c8b18a5 100644 --- a/config/admin_service_cmd_runner.go +++ b/config/admin_service_cmd_runner.go @@ -9,27 +9,24 @@ import ( ) func ExecuteCmd(executablePath, args string) (string, error) { - err := execCmdImp([]string{"gksu", executablePath, args}) - if err == nil { + if err := execCmdImp([]string{"gksu", executablePath, args}); err == nil { return "Ok", nil } - err := execCmdImp([]string{"pkexec", executablePath, args}) - if err == nil { + if err := execCmdImp([]string{"pkexec", executablePath, args}); err == nil { return "Ok", nil } - err := execCmdImp([]string{"/bin/sh", "-c", "sudo " + executablePath + " " + args}) - if err == nil { + if err := execCmdImp([]string{"/bin/sh", "-c", "sudo " + executablePath + " " + args}); err == nil { return "Ok", nil } - return "", err + return "", fmt.Errorf("Error executing run as root shell command") } -func execCmdImp(cmd []string) error { - cmd := exec.Command(cmd[0], cmd[1:]) +func execCmdImp(commands []string) error { + cmd := exec.Command(commands[0], commands[1:]...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - fmt.Printf("Running command: %v", cmd.String()) + fmt.Printf("Running command: %v", commands) if err := cmd.Run(); err != nil { fmt.Printf("Error: %v\n", err) return err