ssh/tailssh: handle terminal opcodes
Updates #3802 #4146 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@ -19,7 +19,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -353,6 +352,10 @@ func (srv *server) handleAcceptedSSH(ctx context.Context, s ssh.Session, ci *ssh
|
||||
}
|
||||
}
|
||||
|
||||
// Take control of the PTY so that we can configure it below.
|
||||
// See https://github.com/tailscale/tailscale/issues/4146
|
||||
s.DisablePTYEmulation()
|
||||
|
||||
cmd, stdin, stdout, stderr, err := srv.launchProcess(ctx, s, ci, lu)
|
||||
if err != nil {
|
||||
logf("start failed: %v", err.Error())
|
||||
@ -376,14 +379,7 @@ func (srv *server) handleAcceptedSSH(ctx context.Context, s ssh.Session, ci *ssh
|
||||
stdin.Close()
|
||||
}()
|
||||
go func() {
|
||||
// Write to s.Channel directly, avoiding gliderlab/ssh's (*session).Write
|
||||
// call that translates newline endings, which we don't need.
|
||||
// See https://github.com/tailscale/tailscale/issues/4146.
|
||||
// TODO(bradfitz,maisem): remove this reflect hackery once gliderlab/ssh changes
|
||||
// are all in.
|
||||
// s is an gliderlabs/ssh.(*session); write to its Channel field.
|
||||
sshChan := reflect.ValueOf(s).Elem().FieldByName("Channel").Interface().(io.Writer)
|
||||
_, err := io.Copy(sshChan, stdout)
|
||||
_, err := io.Copy(s, stdout)
|
||||
if err != nil {
|
||||
// TODO: don't log in the success case.
|
||||
logf("ssh: stdout copy: %v", err)
|
||||
|
Reference in New Issue
Block a user