From a2ac5ec287354cddb5df681578bba5d55b2cc442 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 29 Apr 2022 16:28:58 +0100 Subject: [PATCH] SSH proxy: separate stdout from stderr. In the initial version of SSH proxying that only opened direct-tcpip channels, this wasn't important. But as of commit 6f7c52dccee36f6, we now support invoking a command or subsystem on the proxy SSH server, and those _can_ generate stderr data which we must now separate from stdout. Happily, we have a perfectly sensible thing to _do_ with it: the same thing we'd do with stderr coming from a local proxy subprocess, to wit, pass it to log_proxy_stderr so that it can appear in the terminal window (if configured to) and the Event Log. --- proxy/sshproxy.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/proxy/sshproxy.c b/proxy/sshproxy.c index 057cd4b6..7e217bd2 100644 --- a/proxy/sshproxy.c +++ b/proxy/sshproxy.c @@ -255,8 +255,15 @@ static size_t sshproxy_output(Seat *seat, SeatOutputType type, const void *data, size_t len) { SshProxy *sp = container_of(seat, SshProxy, seat); - bufchain_add(&sp->ssh_to_socket, data, len); - try_send_ssh_to_socket(sp); + switch (type) { + case SEAT_OUTPUT_STDOUT: + bufchain_add(&sp->ssh_to_socket, data, len); + try_send_ssh_to_socket(sp); + break; + case SEAT_OUTPUT_STDERR: + log_proxy_stderr(sp->plug, &sp->psb, data, len); + break; + } return bufchain_size(&sp->ssh_to_socket); }