Skip to content

Commit 0750d87

Browse files
committed
Use mitm std for attachShell for debug mode.
1 parent b1372c9 commit 0750d87

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

execd.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func attachCmd(cmd *exec.Cmd, stdout io.Writer, stderr io.Writer, stdin io.Reade
8787
return &wg, nil
8888
}
8989

90-
func attachShell(cmd *exec.Cmd, ch ssh.Channel) (*sync.WaitGroup, error) {
90+
func attachShell(cmd *exec.Cmd, stdout io.Writer, stdin io.Reader) (*sync.WaitGroup, error) {
9191
var wg sync.WaitGroup
9292
wg.Add(2)
9393

@@ -97,11 +97,11 @@ func attachShell(cmd *exec.Cmd, ch ssh.Channel) (*sync.WaitGroup, error) {
9797
return nil, err
9898
}
9999
go func() {
100-
io.Copy(ch, cmdPty)
100+
io.Copy(stdout, cmdPty)
101101
wg.Done()
102102
}()
103103
go func() {
104-
io.Copy(cmdPty, ch)
104+
io.Copy(cmdPty, stdin)
105105
wg.Done()
106106
}()
107107

@@ -357,8 +357,7 @@ func handleChannel(conn *ssh.ServerConn, newChan ssh.NewChannel, execHandler []s
357357
}
358358
cmd.Env = append(cmd.Env, "USER="+conn.Permissions.Extensions["user"])
359359
}
360-
// TODO: Pass in stdout/stdin to support our mitm'ing above
361-
done, err := attachShell(cmd, ch)
360+
done, err := attachShell(cmd, stdout, ch)
362361
if assert("attachShell", err) {
363362
return
364363
}

0 commit comments

Comments
 (0)