Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (ns *NodeSession) allocateTerminal(ctx context.Context, termType string, s
go ns.updateTerminalSize(ctx, s)
}
go func() {
if _, err := io.Copy(os.Stderr, stderr); err != nil {
if _, err := io.Copy(ns.nodeClient.TC.Stderr, stderr); err != nil {
log.Debugf("Error reading remote STDERR: %v", err)
}
}()
Expand Down Expand Up @@ -551,7 +551,7 @@ func (ns *NodeSession) runCommand(ctx context.Context, mode types.SessionPartici
// fallback to non-interactive mode
if interactive && !ns.terminal.IsAttached() {
interactive = false
fmt.Fprintf(os.Stderr, "TTY will not be allocated on the server because stdin is not a terminal\n")
fmt.Fprintf(ns.nodeClient.TC.Stderr, "TTY will not be allocated on the server because stdin is not a terminal\n")
}

// Start a interactive session ("exec" request with a TTY).
Expand Down
11 changes: 10 additions & 1 deletion lib/web/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@ func (t *TerminalHandler) handler(ws *websocket.Conn, r *http.Request) {
t.log.Debug("Closing websocket stream")
}

type stderrWriter struct {
stream *TerminalStream
}

func (s stderrWriter) Write(b []byte) (int, error) {
s.stream.writeError(string(b))
return len(b), nil
}

// makeClient builds a *client.TeleportClient for the connection.
func (t *TerminalHandler) makeClient(ctx context.Context, stream *TerminalStream, clientAddr string) (*client.TeleportClient, error) {
ctx, span := tracing.DefaultProvider().Tracer("terminal").Start(ctx, "terminal/makeClient")
Expand All @@ -421,7 +430,7 @@ func (t *TerminalHandler) makeClient(ctx context.Context, stream *TerminalStream
clientConfig.ForwardAgent = client.ForwardAgentLocal
clientConfig.Namespace = apidefaults.Namespace
clientConfig.Stdout = stream
clientConfig.Stderr = stream
clientConfig.Stderr = stderrWriter{stream: stream}
clientConfig.Stdin = stream
clientConfig.SiteName = t.sessionData.ClusterName
if err := clientConfig.ParseProxyHost(t.proxyHostPort); err != nil {
Expand Down