Skip to content

Commit

Permalink
ssh: disable wantReply in some requests to comply with OpenSSH
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyaluk committed Sep 3, 2019
1 parent 9756ffd commit f54c30f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
10 changes: 2 additions & 8 deletions ssh/agent/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ import (
// ForwardToAgent or ForwardToRemote should be called to route
// the authentication requests.
func RequestAgentForwarding(session *ssh.Session) error {
ok, err := session.SendRequest("[email protected]", true, nil)
if err != nil {
return err
}
if !ok {
return errors.New("forwarding request denied")
}
return nil
_, err := session.SendRequest("[email protected]", false, nil)
return err
}

// ForwardToAgent routes authentication requests to the given keyring.
Expand Down
5 changes: 1 addition & 4 deletions ssh/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ func (s *Session) Setenv(name, value string) error {
Name: name,
Value: value,
}
ok, err := s.ch.SendRequest("env", true, Marshal(&msg))
if err == nil && !ok {
err = errors.New("ssh: setenv failed")
}
_, err := s.ch.SendRequest("env", false, Marshal(&msg))
return err
}

Expand Down
5 changes: 1 addition & 4 deletions ssh/streamlocal.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ func (l *unixListener) Close() error {
m := streamLocalChannelForwardMsg{
l.socketPath,
}
ok, _, err := l.conn.SendRequest("[email protected]", true, Marshal(&m))
if err == nil && !ok {
err = errors.New("ssh: [email protected] failed")
}
_, _, err := l.conn.SendRequest("[email protected]", false, Marshal(&m))
return err
}

Expand Down
5 changes: 1 addition & 4 deletions ssh/tcpip.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,7 @@ func (l *tcpListener) Close() error {

// this also closes the listener.
l.conn.forwards.remove(l.laddr)
ok, _, err := l.conn.SendRequest("cancel-tcpip-forward", true, Marshal(&m))
if err == nil && !ok {
err = errors.New("ssh: cancel-tcpip-forward failed")
}
_, _, err := l.conn.SendRequest("cancel-tcpip-forward", false, Marshal(&m))
return err
}

Expand Down

0 comments on commit f54c30f

Please sign in to comment.