From 3c1cff927c2ced5b3c9792fca73cc4d9c7dcdd17 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Mon, 12 Aug 2024 01:19:39 +0200 Subject: [PATCH] log more --- src/main.rs | 1 + ssh-connection/src/lib.rs | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3e2cee8..c77d542 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,6 +112,7 @@ async fn handle_connection( ChannelRequestKind::PtyReq { .. } => {} ChannelRequestKind::Shell => {} ChannelRequestKind::Exec { .. } => {} + ChannelRequestKind::Env { .. } => {} }; if req.want_reply { state.do_operation( diff --git a/ssh-connection/src/lib.rs b/ssh-connection/src/lib.rs index d215366..5688b97 100644 --- a/ssh-connection/src/lib.rs +++ b/ssh-connection/src/lib.rs @@ -61,6 +61,10 @@ pub enum ChannelRequestKind { Exec { command: Vec, }, + Env { + name: String, + value: Vec, + }, } impl ChannelNumber { @@ -165,8 +169,6 @@ impl ServerChannelsState { let our_channel = self.validate_channel(our_channel)?; let data = packet.string()?; - let _ = self.channel(our_channel)?; - self.channel_updates.push_back(ChannelUpdate { number: our_channel, kind: ChannelUpdateKind::Data { @@ -174,6 +176,16 @@ impl ServerChannelsState { }, }); } + Packet::SSH_MSG_CHANNEL_EOF => { + // + let our_channel = packet.u32()?; + let our_channel = self.validate_channel(our_channel)?; + + self.channel_updates.push_back(ChannelUpdate { + number: our_channel, + kind: ChannelUpdateKind::Eof, + }); + } Packet::SSH_MSG_CHANNEL_CLOSE => { // let our_channel = packet.u32()?; @@ -241,6 +253,17 @@ impl ServerChannelsState { command: command.to_owned(), } } + "env" => { + let name = packet.utf8_string()?; + let value = packet.string()?; + + info!(?our_channel, ?name, value = ?String::from_utf8_lossy(value), "Setting environment variable"); + + ChannelRequestKind::Env { + name: name.to_owned(), + value: value.to_owned(), + } + } "signal" => { debug!(?our_channel, "Received signal"); // Ignore signals, something we can do.