(sess ssh.Session)
| 95 | } |
| 96 | |
| 97 | func (s *Server) handler(sess ssh.Session) { |
| 98 | cmd := s.getCommand(sess) |
| 99 | if ssh.AgentRequested(sess) { |
| 100 | l, err := ssh.NewAgentListener() |
| 101 | if err != nil { |
| 102 | exitWithError(sess, errors.Wrap(err, "start agent")) |
| 103 | return |
| 104 | } |
| 105 | |
| 106 | defer l.Close() |
| 107 | go ssh.ForwardAgentConnections(l, sess) |
| 108 | cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", "SSH_AUTH_SOCK", l.Addr().String())) |
| 109 | } |
| 110 | |
| 111 | // start shell session |
| 112 | var err error |
| 113 | ptyReq, winCh, isPty := sess.Pty() |
| 114 | if isPty { |
| 115 | err = HandlePTY(sess, ptyReq, winCh, cmd, nil) |
| 116 | } else { |
| 117 | err = HandleNonPTY(sess, cmd, nil) |
| 118 | } |
| 119 | |
| 120 | // exit session |
| 121 | exitWithError(sess, err) |
| 122 | } |
| 123 | |
| 124 | func HandleNonPTY(sess ssh.Session, cmd *exec.Cmd, decorateReader func(reader io.Reader) io.Reader) (err error) { |
| 125 | // init pipes |
nothing calls this directly
no test coverage detected