Skip to content
Closed
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
23 changes: 23 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type Session interface {
// which considers quoting not just whitespace.
Command() []string

// Subsystem returns subsystem name if one was asked for, else empty string.
Subsystem() string

// RawCommand returns the exact command that was provided by the user.
RawCommand() string

Expand Down Expand Up @@ -108,6 +111,7 @@ type session struct {
winch chan Window
env []string
ptyCb PtyCallback
subsystem string
sessReqCb SessionRequestCallback
rawCmd string
ctx Context
Expand Down Expand Up @@ -191,6 +195,10 @@ func (sess *session) Command() []string {
return append([]string(nil), cmd...)
}

func (sess *session) Subsystem() string {
return sess.subsystem
}

func (sess *session) Pty() (Pty, <-chan Window, bool) {
if sess.pty != nil {
return *sess.pty, sess.winch, true
Expand Down Expand Up @@ -235,6 +243,21 @@ func (sess *session) handleRequests(reqs <-chan *gossh.Request) {
sess.handled = true
req.Reply(true, nil)

go func() {
sess.handler(sess)
sess.Exit(0)
}()
case "subsystem":
if sess.handled {
req.Reply(false, nil)
continue
}
sess.handled = true
req.Reply(true, nil)

var payload = struct{ Value string }{}
gossh.Unmarshal(req.Payload, &payload)
sess.subsystem = payload.Value
go func() {
sess.handler(sess)
sess.Exit(0)
Expand Down