-
Notifications
You must be signed in to change notification settings - Fork 462
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
fixed/finished basic pty support, added an example, and included tests #25
Conversation
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
…ndow size on it Signed-off-by: Jeff Lindsay <progrium@gmail.com>
Last commit was a fix I added in working on a more complex example. You always end up writing the call to your "resizeWindow" function twice, once initially, once in the channel range. This PR changes behavior to where the window change channel has the initial window size in it, so you can just implement your range and that's it. |
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
Just added a new example that turns SSH into a "docker run" bridge ... in ~100 lines! Still no signals, but many containers work and I learned how to resolve some bugs in cmd.io, namely gliderlabs/cmd#58 and gliderlabs/cmd#59 |
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
I'm not sure how we want to handle this, but the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only changes I think this could really use is some fixes around users sending multiple pty-req messages.
session.go
Outdated
@@ -152,6 +152,9 @@ func (sess *session) handleRequests(reqs <-chan *gossh.Request) { | |||
var kv = struct{ Key, Value string }{} | |||
gossh.Unmarshal(req.Payload, &kv) | |||
sess.env = append(sess.env, fmt.Sprintf("%s=%s", kv.Key, kv.Value)) | |||
if req.WantReply { | |||
req.Reply(true, nil) | |||
} | |||
case "pty-req": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should this handle multiple pty-req messages before the exec/shell? Right now I think this will overwrite the pty, but if that's what we want, we need to be more careful about closing sess.winch because that could be double-closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the simplest solution is to ignore/deny (reply false) any more pty requests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or perhaps once pty
is set, it ignores the rest. I can imagine the callback denying for some reason and then the client fixing and trying again. No idea if that's a realistic scenario with known SSH clients, but it makes sense implementation wise and resolves this issue.
gossh "golang.org/x/crypto/ssh" | ||
) | ||
|
||
func (srv *Server) serveOnce(l net.Listener) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is a nice hack. I'll hopefully be able to cobble together something a bit more robust when the Shutdown pr goes in.
@@ -5,7 +5,6 @@ import ( | |||
"net" | |||
) | |||
|
|||
// Signal as in RFC 4254 Section 6.10. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this comment was removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's duplicated a few lines below. Since this portion is copy and pasted directly from the crypto/ssh implementation, I went and looked and they don't double reference. So as is with this commit it matches.
@belak regarding |
…ess.pty once Signed-off-by: Jeff Lindsay <progrium@gmail.com>
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
cc @belak for review
Missing support for terminal modes, and still need signals, but omg tests.