ssh: use a variable rather than type for NoAuthError

Change-Id: Ib61e0bc7d953cefde0436f77fe6a610201043c85
Reviewed-on: https://go-review.googlesource.com/96336
Run-TryBot: Han-Wen Nienhuys <hanwen@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Spencer Tung <spencertung@google.com>
Reviewed-by: Han-Wen Nienhuys <hanwen@google.com>
This commit is contained in:
Han-Wen Nienhuys
2018-02-22 18:24:04 +00:00
parent 432090b8f5
commit 49796115aa
2 changed files with 9 additions and 11 deletions
+2 -2
View File
@@ -614,8 +614,8 @@ func TestClientAuthErrorList(t *testing.T) {
for i, e := range authErrs.Errors {
switch i {
case 0:
if _, ok := e.(*NoAuthError); !ok {
t.Fatalf("errors: got error type %T, want NoAuthError", e)
if e != NoAuthError {
t.Fatalf("errors: got error %v, want NoAuthError", e)
}
case 1:
if e != publicKeyErr {
+7 -9
View File
@@ -297,7 +297,7 @@ func checkSourceAddress(addr net.Addr, sourceAddrs string) error {
// provided by the user failed to authenticate.
type ServerAuthError struct {
// Errors contains authentication errors returned by the authentication
// callback methods.
// callback methods. The first entry typically is NoAuthError.
Errors []error
}
@@ -309,13 +309,11 @@ func (l ServerAuthError) Error() string {
return "[" + strings.Join(errs, ", ") + "]"
}
// NoAuthError is the unique error that is returned if no authentication method
// has been passed yet
type NoAuthError struct{}
func (e *NoAuthError) Error() string {
return "no auth passed yet"
}
// NoAuthError is the unique error that is returned if no
// authentication method has been passed yet. This happens as a normal
// part of the authentication loop, since the client first tries
// 'none' authentication to discover available methods.
var NoAuthError = errors.New("ssh: no auth passed yet")
func (s *connection) serverAuthenticate(config *ServerConfig) (*Permissions, error) {
sessionID := s.transport.getSessionID()
@@ -371,7 +369,7 @@ userAuthLoop:
}
perms = nil
authErr := error(&NoAuthError{})
authErr := NoAuthError
switch userAuthReq.Method {
case "none":