P0: exit-status for subsystem, improved error msgs, integration test suite
Some checks failed
Test / test (push) Has been cancelled
Test / build (push) Has been cancelled

This commit is contained in:
Warren
2026-06-20 16:40:29 +08:00
parent 5b439dfbef
commit 45d050c0b3
2 changed files with 260 additions and 3 deletions

View File

@@ -106,7 +106,7 @@ impl SshServer {
upload_hook_config_clone,
)
{
error!("Connection error: {}", e);
error!("SSH connection error: {}", e);
}
});
}
@@ -666,6 +666,10 @@ fn handle_ssh_service_loop(
if !has_exec && packet.payload.len() >= 5 {
let channel_id =
u32::from_be_bytes([packet.payload[1], packet.payload[2], packet.payload[3], packet.payload[4]]);
// ⭐⭐⭐⭐⭐ P0: Send exit-status 0 for subsystem channels
let exit_status_packet = channel_manager.build_channel_exit_status(channel_id, 0)?;
let encrypted_exit = EncryptedPacket::new(&exit_status_packet.payload, encryption_ctx, true)?;
encrypted_exit.write(stream)?;
let close_packet = channel_manager.build_channel_close(channel_id)?;
let encrypted_response =
EncryptedPacket::new(&close_packet.payload, encryption_ctx, true)?;
@@ -673,7 +677,10 @@ fn handle_ssh_service_loop(
}
}
Some(&pt) if pt == PacketType::SSH_MSG_DISCONNECT as u8 => {
info!("Received SSH_MSG_DISCONNECT");
let reason_code = if packet.payload.len() >= 5 {
u32::from_be_bytes([packet.payload[1], packet.payload[2], packet.payload[3], packet.payload[4]])
} else { 0 };
info!("Received SSH_MSG_DISCONNECT (reason={})", reason_code);
break;
}
Some(&pt) if pt == PacketType::SSH_MSG_CHANNEL_WINDOW_ADJUST as u8 => {
@@ -688,7 +695,8 @@ fn handle_ssh_service_loop(
}
}
_ => {
warn!("Unknown packet type: {:?}", packet.payload.first());
let pt = packet.payload.first().copied().unwrap_or(0);
warn!("Unknown/unhandled packet type: {} (0x{:02x}), payload_len={}", pt, pt, packet.payload.len());
}
}