diff --git a/cli/connhelper/commandconn/commandconn.go b/cli/connhelper/commandconn/commandconn.go index 7e03741fad..4c5783fb3b 100644 --- a/cli/connhelper/commandconn/commandconn.go +++ b/cli/connhelper/commandconn/commandconn.go @@ -41,7 +41,9 @@ func New(ctx context.Context, cmd string, args ...string) (net.Conn, error) { // we assume that args never contains sensitive information logrus.Debugf("commandconn: starting %s with %v", cmd, args) c.cmd.Env = os.Environ() + c.cmd.SysProcAttr = &syscall.SysProcAttr{} setPdeathsig(c.cmd) + createSession(c.cmd) c.stdin, err = c.cmd.StdinPipe() if err != nil { return nil, err diff --git a/cli/connhelper/commandconn/commandconn_linux.go b/cli/connhelper/commandconn/pdeathsig_linux.go similarity index 55% rename from cli/connhelper/commandconn/commandconn_linux.go rename to cli/connhelper/commandconn/pdeathsig_linux.go index 7d8b122e32..1cdd788cc0 100644 --- a/cli/connhelper/commandconn/commandconn_linux.go +++ b/cli/connhelper/commandconn/pdeathsig_linux.go @@ -6,7 +6,5 @@ import ( ) func setPdeathsig(cmd *exec.Cmd) { - cmd.SysProcAttr = &syscall.SysProcAttr{ - Pdeathsig: syscall.SIGKILL, - } + cmd.SysProcAttr.Pdeathsig = syscall.SIGKILL } diff --git a/cli/connhelper/commandconn/commandconn_nolinux.go b/cli/connhelper/commandconn/pdeathsig_nolinux.go similarity index 100% rename from cli/connhelper/commandconn/commandconn_nolinux.go rename to cli/connhelper/commandconn/pdeathsig_nolinux.go diff --git a/cli/connhelper/commandconn/session_unix.go b/cli/connhelper/commandconn/session_unix.go new file mode 100644 index 0000000000..6448500d63 --- /dev/null +++ b/cli/connhelper/commandconn/session_unix.go @@ -0,0 +1,13 @@ +// +build !windows + +package commandconn + +import ( + "os/exec" +) + +func createSession(cmd *exec.Cmd) { + // for supporting ssh connection helper with ProxyCommand + // https://github.com/docker/cli/issues/1707 + cmd.SysProcAttr.Setsid = true +} diff --git a/cli/connhelper/commandconn/session_windows.go b/cli/connhelper/commandconn/session_windows.go new file mode 100644 index 0000000000..b926074500 --- /dev/null +++ b/cli/connhelper/commandconn/session_windows.go @@ -0,0 +1,8 @@ +package commandconn + +import ( + "os/exec" +) + +func createSession(cmd *exec.Cmd) { +}