X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=rpc%2Fdial.go;h=945a75ff86c365fd1e251e205a0b68efbd2b3aef;hb=367edc1286a52d96fcfef6f98330148cad8a64e1;hp=f300370aba3f75eb7ff55b7fc9eb0be2c15d9871;hpb=583a2695a3ddc9c98e0a03d9f1bad8df30afe887;p=safcm%2Fsafcm.git diff --git a/rpc/dial.go b/rpc/dial.go index f300370..945a75f 100644 --- a/rpc/dial.go +++ b/rpc/dial.go @@ -32,7 +32,7 @@ import ( "ruderich.org/simon/safcm/remote" ) -func (c *Conn) DialSSH(user, host string) error { +func (c *Conn) DialSSH(user, host, sshConfig string) error { if c.events == nil { return fmt.Errorf("cannot reuse Conn") } @@ -48,8 +48,14 @@ func (c *Conn) DialSSH(user, host string) error { // Help debugging by showing executed shell commands opts += "x" } - c.cmd = exec.Command("ssh", remote, "/bin/sh", opts) - c.remote = remote + + c.sshRemote = remote + if sshConfig != "" { + c.sshOpts = append(c.sshOpts, "-F", sshConfig) + } + c.cmd = exec.Command("ssh", + append(append([]string{}, c.sshOpts...), + c.sshRemote, "/bin/sh", opts)...) stdin, err := c.cmd.StdinPipe() if err != nil { @@ -113,7 +119,7 @@ compat_sha512sum() { sha512sum "$1" } ` - case "freebsd": + case "freebsd", "openbsd": compat = ` dir_stat='41777 0 0' file_stat="100700 $(id -u) $(id -g)" @@ -181,6 +187,8 @@ f() { rm "$tmp" # Make file executable chmod 0700 "$x" + # Some BSD create files with group wheel in /tmp + chgrp "$(id -g)" "$x" fi exec "$x" sync @@ -249,10 +257,12 @@ f path = strings.TrimSuffix(path, "\n") c.debugf("DialSSH: uploading new remote to %q at %q", - c.remote, path) + c.sshRemote, path) - cmd := exec.Command("ssh", c.remote, - fmt.Sprintf("cat > %q", path)) + cmd := exec.Command("ssh", + append(append([]string{}, c.sshOpts...), + c.sshRemote, + fmt.Sprintf("cat > %q", path))...) cmd.Stdin = bytes.NewReader(helper) err = c.handleStderrAsEvents(cmd) if err != nil { @@ -274,7 +284,7 @@ f } func connGetGoos(stdin io.Writer, stdout *bufio.Reader) (string, error) { - _, err := fmt.Fprintln(stdin, "uname -o") + _, err := fmt.Fprintln(stdin, "uname") if err != nil { return "", err } @@ -287,12 +297,14 @@ func connGetGoos(stdin io.Writer, stdout *bufio.Reader) (string, error) { // NOTE: Adapt helper uploading in dialSSH() when adding new systems var goos string switch x { - case "GNU/Linux": + case "Linux": goos = "linux" case "FreeBSD": goos = "freebsd" + case "OpenBSD": + goos = "openbsd" default: - return "", fmt.Errorf("unsupported OS %q (`uname -o`)", x) + return "", fmt.Errorf("unsupported OS %q (`uname`)", x) } return goos, nil }