Repository navigation
[v1] send exit-status from the example servers - #686
Merged
Merged
Conversation
The SFTP subsystem's exit status is sent by whoever owns the SSH channel, since Server and RequestServer only see an io.ReadWriteCloser. The example servers never sent it, and some clients (restic, for example) wait for it before they consider the session finished. Send it after Serve returns, the same way the server integration tests already do.
puellanivis
approved these changes
Oct 19, 2026
| if err != nil { | ||
| exitStatus = 1 | ||
| } | ||
| channel.SendRequest("exit-status", false, ssh.Marshal(struct{ Status uint32 }{exitStatus})) |
Collaborator
There was a problem hiding this comment.
One would figure that these standardized and defined request packets would be kept somewhere that everyone could use them consistently…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #321.
ServerandRequestServeronly see anio.ReadWriteCloser, so theexit-statuschannel request has to come from whoever owns the SSH channel, the same wayserver_integration_test.goalready does it. The two example servers never sent it, and some clients (restic, for example) wait for it before they consider the session finished. This sends it afterServereturns: 0 on a clean exit (nilorio.EOF), 1 otherwise.I checked both examples with a small client that opens the subsystem, half-closes the channel like OpenSSH's
sftpdoes, and waits for the request: master closes the channel without anexit-status, and with this change both sendexit-status 0.Since the library can't send this itself, I think #321 can be closed once the examples show how to do it.