Merge pull request #263 from Code0x58/ssh-external-tidy
Stop quietly ignoring `--ssh-external` on Windows
This commit is contained in:
@@ -154,6 +154,10 @@ func (p *PrepareCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{
|
||||
c.Conf.SSHExternal = p.sshExternal
|
||||
c.Conf.AssumeYes = p.assumeYes
|
||||
|
||||
logrus.Info("Validating Config...")
|
||||
if !c.Conf.Validate() {
|
||||
return subcommands.ExitUsageError
|
||||
}
|
||||
// Set up custom logger
|
||||
logger := util.NewCustomLogger(c.ServerInfo{})
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
@@ -71,6 +72,10 @@ type Config struct {
|
||||
func (c Config) Validate() bool {
|
||||
errs := []error{}
|
||||
|
||||
if runtime.GOOS == "windows" && c.SSHExternal {
|
||||
errs = append(errs, fmt.Errorf("-ssh-external cannot be used on windows"))
|
||||
}
|
||||
|
||||
if len(c.ResultsDir) != 0 {
|
||||
if ok, _ := valid.IsFilePath(c.ResultsDir); !ok {
|
||||
errs = append(errs, fmt.Errorf(
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -150,10 +149,10 @@ func parallelSSHExec(fn func(osTypeInterface) error, timeoutSec ...int) (errs []
|
||||
}
|
||||
|
||||
func sshExec(c conf.ServerInfo, cmd string, sudo bool, log ...*logrus.Entry) (result sshResult) {
|
||||
if isSSHExecNative() {
|
||||
result = sshExecNative(c, cmd, sudo)
|
||||
} else {
|
||||
if conf.Conf.SSHExternal {
|
||||
result = sshExecExternal(c, cmd, sudo)
|
||||
} else {
|
||||
result = sshExecNative(c, cmd, sudo)
|
||||
}
|
||||
|
||||
logger := getSSHLogger(log...)
|
||||
@@ -161,10 +160,6 @@ func sshExec(c conf.ServerInfo, cmd string, sudo bool, log ...*logrus.Entry) (re
|
||||
return
|
||||
}
|
||||
|
||||
func isSSHExecNative() bool {
|
||||
return runtime.GOOS == "windows" || !conf.Conf.SSHExternal
|
||||
}
|
||||
|
||||
func sshExecNative(c conf.ServerInfo, cmd string, sudo bool) (result sshResult) {
|
||||
result.Servername = c.ServerName
|
||||
result.Host = c.Host
|
||||
|
||||
Reference in New Issue
Block a user