Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of persistent SSH connections and improve debug logging #197

Merged
merged 4 commits into from
Apr 4, 2023

Conversation

smlx
Copy link
Member

@smlx smlx commented Apr 4, 2023

In some rare cases the ssh-portal could lose track of the TerminalSizeQueue goroutine, which would cause error messages to be spewed on stderr.

This PR fixes that issue by ensuring the goroutine exits once the exec command completes. It also does some minor refactoring and logging improvements.

smlx added 2 commits April 4, 2023 15:38
In the case of SSH ControlMaster connections with a PTY, the SSH
connection can stay up without an active SSH channel (i.e. after the
command execution completes). If this happens the ssh connection context
will not be cancelled, as the connection is still up.

Wrapping the raw SSH context and deferring the cancel of it before
passing it to exec.StreamWithContext() and newTermSizeQueue() ensures
that once command execution completes, the context is cancelled and the
TSQ goroutine will exit immediately.

If the context is not cancelled after command execution completes, the
TSQ goroutine will spin trying to write to a closed winch channel and
spew EOF errors into stderr.
@smlx smlx changed the title chore: improve authorization debug logging Fix handling of persistent SSH connections and improve debug logging Apr 4, 2023
@smlx smlx marked this pull request as ready for review April 4, 2023 12:38
@smlx smlx merged commit 3f917b4 into main Apr 4, 2023
@smlx smlx deleted the debug-authz branch April 4, 2023 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant