From 35b422b074dd06dfea090a65b6072b09600302ff Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 14 Jan 2021 16:16:20 -0500 Subject: [PATCH] 17170: Use exec() to eliminate intermediate arvados-client process. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- cmd/arvados-client/container_gateway.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/cmd/arvados-client/container_gateway.go b/cmd/arvados-client/container_gateway.go index 40f40291f2..a63089d17d 100644 --- a/cmd/arvados-client/container_gateway.go +++ b/cmd/arvados-client/container_gateway.go @@ -58,26 +58,19 @@ Options: return 2 } sshargs = append([]string{ + "ssh", "-o", "ProxyCommand " + selfbin + " connect-ssh -detach-keys=" + shellescape(*detachKeys) + " " + shellescape(target), "-o", "StrictHostKeyChecking no", target}, sshargs...) - cmd := exec.Command("ssh", sshargs...) - cmd.Stdin = stdin - cmd.Stdout = stdout - cmd.Stderr = stderr - err = cmd.Run() - if err == nil { - return 0 - } else if exiterr, ok := err.(*exec.ExitError); !ok { - fmt.Fprintln(stderr, err) - return 1 - } else if status, ok := exiterr.Sys().(syscall.WaitStatus); !ok { + sshbin, err := exec.LookPath("ssh") + if err != nil { fmt.Fprintln(stderr, err) return 1 - } else { - return status.ExitStatus() } + err = syscall.Exec(sshbin, sshargs, os.Environ()) + fmt.Fprintf(stderr, "exec(%q) failed: %s\n", sshbin, err) + return 1 } // connectSSHCommand connects stdin/stdout to a container's gateway -- 2.30.2