From 1f72560438e9488384966823309ba9341daba2a2 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Wed, 29 Jan 2025 14:50:07 +0000 Subject: [PATCH] feat(ssh): validate terminal emulator support --- src/ssh.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ssh.rs b/src/ssh.rs index 6ccf7ac..56a19f4 100644 --- a/src/ssh.rs +++ b/src/ssh.rs @@ -119,7 +119,7 @@ impl Handler for SshSession { Err(eyre!("Failed to initialize App for session")) } - #[instrument(skip(self, _session), level = "trace")] + #[instrument(skip(self, session), level = "trace")] async fn pty_request( &mut self, channel_id: ChannelId, @@ -129,10 +129,16 @@ impl Handler for SshSession { pix_width: u32, pix_height: u32, modes: &[(Pty, u32)], - _session: &mut Session, + session: &mut Session, ) -> Result<(), Self::Error> { - tracing::info!("Received pty request from channel {channel_id}"); + tracing::info!("Received pty request from channel {channel_id}; terminal: {term}"); tracing::debug!("dims: {col_width} * {row_height}, pixel: {pix_width} * {pix_height}"); + + if !term.contains("xterm") { + session.channel_failure(channel_id)?; + return Err(eyre!("Unsupported terminal type: {term}")); + } + Ok(()) }