Repository navigation
Description
Goal
A server that never answers a shell, exec or SFTP subsystem request no longer blocks the connection forever, and output or an exit status that arrives before the reply is not lost.
Context
Follow-up of #1665 (PR #1675): the review noticed two gaps in the shared request-reply wait.
wait_for_request_reply(crates/ssh-transport/src/transport.rs:150-158) skips every message exceptSuccess/Failure/Close/Eof(Some(_) => continue). Data or an exit status sent before the reply is discarded.- The wait has no time limit. It is used by
open_shell(~line 316) and the exec open path (~line 488);open_sftphas its own wait loop (~line 366) with the same two gaps. A server that never replies hangs the caller.
OpenSSH and Dropbear send the reply first, so this is a robustness gap against unusual servers, not a current regression. Spec 0005 §4.1/§4.4 describe the refusal behaviour.
Requirements
- Messages that arrive before the reply (
Data,ExtendedData,ExitStatus,ExitSignal) are buffered and handed to the channel consumer after the reply isAccepted, in order. - The reply wait has a time limit (default 30 s, a named constant). On expiry the call fails with the existing
SessionClosed-style error that fits a timeout, with no new error code unless needed; if a new code is needed it is added to the error table, the frontend code list and all locales. open_sftpuses the same helper (or the same limit and buffering).- A refused or closed reply still never yields a working channel.
Acceptance Criteria
- Unit test with the scripted
ReplySource:Data, thenExitStatus, thenSuccessreturns Accepted and the buffered messages are available in order. - Unit test: no reply within the limit returns a timeout error (tokio paused time, no real wait).
- Unit test:
Failureafter buffered data still givesRefused;Closebefore the reply still givesClosed. -
open_shell, exec andopen_sftpfail with an error, not a hang, against a server that never replies (in-process test server case). - Existing
request_reply_testsand real-server tests stay green - Relevant automated tests pass
Technical Notes
Affected: crates/ssh-transport/src/transport.rs, in-process test server crates/ssh-transport/tests/fixtures/test_server.rs. The change only waits and buffers, so it adds no new path to a server; the filter engine and approval flow are untouched. Update spec 0005 if a timeout error text becomes visible. Add a changelog fragment only if the user-visible failure text changes.
Files: crates/ssh-transport/src/transport.rs, crates/ssh-transport/tests/fixtures/test_server.rs, crates/ssh-transport/tests/sudo_password.rs, docs/specs/0005-ssh-module.md
Spec impact: update 0005
Open questions
- Replay mechanism: buffer in a
Vec<ChannelMsg>that the consumers drain first (recommended), or a wrapper channel type. Choose the smaller diff. - Timeout value: 30 s recommended; make it a constant, not a setting.
Activity