@@ -166,6 +166,9 @@ type ServerConn struct {
166
166
// unsuccessful, it closes the connection and returns an error. The
167
167
// Request and NewChannel channels must be serviced, or the connection
168
168
// will hang.
169
+ //
170
+ // The returned error may be of type *ServerAuthError for
171
+ // authentication errors.
169
172
func NewServerConn (c net.Conn , config * ServerConfig ) (* ServerConn , <- chan NewChannel , <- chan * Request , error ) {
170
173
fullConf := * config
171
174
fullConf .SetDefaults ()
@@ -292,12 +295,13 @@ func checkSourceAddress(addr net.Addr, sourceAddrs string) error {
292
295
return fmt .Errorf ("ssh: remote address %v is not allowed because of source-address restriction" , addr )
293
296
}
294
297
295
- // ServerAuthError implements the error interface. It appends any authentication
296
- // errors that may occur, and is returned if all of the authentication methods
297
- // provided by the user failed to authenticate.
298
+ // ServerAuthError represents server authentication errors and is
299
+ // sometimes returned by NewServerConn. It appends any authentication
300
+ // errors that may occur, and is returned if all of the authentication
301
+ // methods provided by the user failed to authenticate.
298
302
type ServerAuthError struct {
299
303
// Errors contains authentication errors returned by the authentication
300
- // callback methods. The first entry typically is NoAuthError .
304
+ // callback methods. The first entry is typically ErrNoAuth .
301
305
Errors []error
302
306
}
303
307
@@ -309,11 +313,12 @@ func (l ServerAuthError) Error() string {
309
313
return "[" + strings .Join (errs , ", " ) + "]"
310
314
}
311
315
312
- // NoAuthError is the unique error that is returned if no
316
+ // ErrNoAuth is the error value returned if no
313
317
// authentication method has been passed yet. This happens as a normal
314
318
// part of the authentication loop, since the client first tries
315
319
// 'none' authentication to discover available methods.
316
- var NoAuthError = errors .New ("ssh: no auth passed yet" )
320
+ // It is returned in ServerAuthError.Errors from NewServerConn.
321
+ var ErrNoAuth = errors .New ("ssh: no auth passed yet" )
317
322
318
323
func (s * connection ) serverAuthenticate (config * ServerConfig ) (* Permissions , error ) {
319
324
sessionID := s .transport .getSessionID ()
@@ -369,7 +374,7 @@ userAuthLoop:
369
374
}
370
375
371
376
perms = nil
372
- authErr := NoAuthError
377
+ authErr := ErrNoAuth
373
378
374
379
switch userAuthReq .Method {
375
380
case "none" :
0 commit comments