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

Propagate sshforward send side connection close #3506

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

aaronlehmann
Copy link
Collaborator

PR #3431 caused connections closed on the remote side of a sshforward session to not always result in the local side reading an EOF from the connection. This change restores that behavior by closing the write side of the forwarded connection after reading an EOF from the stream. Since only the write side is being closed, it doesn't prevent the remote side from continuing to read from the connection.

Copy link
Collaborator

@sipsma sipsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sending this @aaronlehmann, I just verified the original problem in dagger is still gone when running with this change, so we should be all good.

I did realize after my original suggestion that there's probably a slightly preferable change:

if conn, ok := conn.(interface {
	CloseWrite() error
}); ok {
	conn.CloseWrite()
}

Just because this is a public interface and callers could thus provide something besides a UnixConn technically. I tested that too and verified it still works for dagger.

Approving anyways because that's pretty obscure, don't care if we merge as is if you don't have time to test again before the v0.11.1 patch release comes out.

PR moby#3431 caused connections closed on the remote side of a sshforward
session to not always result in the local side reading an EOF from the
connection. This change restores that behavior by closing the write side
of the forwarded connection after reading an EOF from the stream. Since
only the write side is being closed, it doesn't prevent the remote side
from continuing to read from the connection.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
@aaronlehmann
Copy link
Collaborator Author

Updated to your new suggestion.

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand how this works. Afaics conn is always type *sock that is internal wrapper and never implements CloseWrite.

@aaronlehmann
Copy link
Collaborator Author

@tonistiigi: It seems like that wrapping only applies for SSH agent forwarding in ForwardAgent. The usage from MountSSHSocket does not seem to wrap the conn:

go Copy(ctx, conn, stream, stream.CloseSend)

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.

None yet

5 participants