mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-04 15:35:38 +00:00
cmd/tailscale: make ssh command prefer Windows ssh.exe over PATH
use C:\Windows\System32\OpenSSH\ssh.exe (#4933)
Change-Id: Iad73b27b23b746de2c7e994572a54e7e1c370588
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
(cherry picked from commit 1d04e01d1e
)
This commit is contained in:
parent
2b4140ee46
commit
d6e7f41151
@ -11,7 +11,6 @@
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -63,7 +62,7 @@ func runSSH(ctx context.Context, args []string) error {
|
|||||||
hostForSSH = v
|
hostForSSH = v
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh, err := exec.LookPath("ssh")
|
ssh, err := findSSH()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO(bradfitz): use Go's crypto/ssh client instead
|
// TODO(bradfitz): use Go's crypto/ssh client instead
|
||||||
// of failing. But for now:
|
// of failing. But for now:
|
||||||
|
@ -10,9 +10,14 @@
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func findSSH() (string, error) {
|
||||||
|
return exec.LookPath("ssh")
|
||||||
|
}
|
||||||
|
|
||||||
func execSSH(ssh string, argv []string) error {
|
func execSSH(ssh string, argv []string) error {
|
||||||
if err := syscall.Exec(ssh, argv, os.Environ()); err != nil {
|
if err := syscall.Exec(ssh, argv, os.Environ()); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func findSSH() (string, error) {
|
||||||
|
return "", errors.New("Not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
func execSSH(ssh string, argv []string) error {
|
func execSSH(ssh string, argv []string) error {
|
||||||
return errors.New("Not implemented")
|
return errors.New("Not implemented")
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,21 @@
|
|||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func findSSH() (string, error) {
|
||||||
|
// use C:\Windows\System32\OpenSSH\ssh.exe since unexpected behavior
|
||||||
|
// occured with ssh.exe provided by msys2/cygwin and other environments.
|
||||||
|
if systemRoot := os.Getenv("SystemRoot"); systemRoot != "" {
|
||||||
|
exe := filepath.Join(systemRoot, "System32", "OpenSSH", "ssh.exe")
|
||||||
|
if st, err := os.Stat(exe); err == nil && !st.IsDir() {
|
||||||
|
return exe, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return exec.LookPath("ssh")
|
||||||
|
}
|
||||||
|
|
||||||
func execSSH(ssh string, argv []string) error {
|
func execSSH(ssh string, argv []string) error {
|
||||||
// Don't use syscall.Exec on Windows, it's not fully implemented.
|
// Don't use syscall.Exec on Windows, it's not fully implemented.
|
||||||
cmd := exec.Command(ssh, argv[1:]...)
|
cmd := exec.Command(ssh, argv[1:]...)
|
||||||
|
Loading…
Reference in New Issue
Block a user