This commit is contained in:
nora 2024-08-12 01:19:39 +02:00
parent 6ff5bbde98
commit 3c1cff927c
2 changed files with 26 additions and 2 deletions

View file

@ -112,6 +112,7 @@ async fn handle_connection(
ChannelRequestKind::PtyReq { .. } => {} ChannelRequestKind::PtyReq { .. } => {}
ChannelRequestKind::Shell => {} ChannelRequestKind::Shell => {}
ChannelRequestKind::Exec { .. } => {} ChannelRequestKind::Exec { .. } => {}
ChannelRequestKind::Env { .. } => {}
}; };
if req.want_reply { if req.want_reply {
state.do_operation( state.do_operation(

View file

@ -61,6 +61,10 @@ pub enum ChannelRequestKind {
Exec { Exec {
command: Vec<u8>, command: Vec<u8>,
}, },
Env {
name: String,
value: Vec<u8>,
},
} }
impl ChannelNumber { impl ChannelNumber {
@ -165,8 +169,6 @@ impl ServerChannelsState {
let our_channel = self.validate_channel(our_channel)?; let our_channel = self.validate_channel(our_channel)?;
let data = packet.string()?; let data = packet.string()?;
let _ = self.channel(our_channel)?;
self.channel_updates.push_back(ChannelUpdate { self.channel_updates.push_back(ChannelUpdate {
number: our_channel, number: our_channel,
kind: ChannelUpdateKind::Data { kind: ChannelUpdateKind::Data {
@ -174,6 +176,16 @@ impl ServerChannelsState {
}, },
}); });
} }
Packet::SSH_MSG_CHANNEL_EOF => {
// <https://datatracker.ietf.org/doc/html/rfc4254#section-5.3>
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 => { Packet::SSH_MSG_CHANNEL_CLOSE => {
// <https://datatracker.ietf.org/doc/html/rfc4254#section-5.3> // <https://datatracker.ietf.org/doc/html/rfc4254#section-5.3>
let our_channel = packet.u32()?; let our_channel = packet.u32()?;
@ -241,6 +253,17 @@ impl ServerChannelsState {
command: command.to_owned(), 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" => { "signal" => {
debug!(?our_channel, "Received signal"); debug!(?our_channel, "Received signal");
// Ignore signals, something we can do. // Ignore signals, something we can do.