Skip to content

fix(ssh): start the session piping only after send the pty-req #4726

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ssh/server/channels/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ func DefaultSessionHandler() gliderssh.ChannelHandler {

defer agent.Close()

go pipe(sess, client.Channel, agent.Channel, seat)

// TODO: Add middleware to block certain types of requests.
for {
select {
Expand Down Expand Up @@ -239,7 +237,9 @@ func DefaultSessionHandler() gliderssh.ChannelHandler {

sess.Pty = pty

sess.Event(req.Type, pty, seat) //nolint:errcheck
sess.Event(req.Type, pty, seat)

go pipe(sess, client.Channel, agent.Channel, seat)
case WindowChangeRequestType:
var dimensions models.SSHWindowChange

Expand Down
10 changes: 8 additions & 2 deletions ssh/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,19 @@ func (s *Session) NewSeat() (int, error) {

// Events register an event to the session.
func (s *Session) Event(t string, data any, seat int) {
s.Events.WriteJSON(&models.SessionEvent{ //nolint:errcheck
if err := s.Events.WriteJSON(&models.SessionEvent{ //nolint:errcheck
Session: s.UID,
Type: models.SessionEventType(t),
Timestamp: clock.Now(),
Data: data,
Seat: seat,
})
}); err != nil {
log.WithError(err).WithFields(log.Fields{
"event": t,
"data": data,
"seat": seat,
}).Error("failed to register a event")
}
}

func Event[D any](sess *Session, t string, data []byte, seat int) {
Expand Down
Loading