File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,19 @@ func isAcceptableAlgo(algo string) bool {
310
310
return false
311
311
}
312
312
313
+ // WithBannerError is an error wrapper type that can be returned from an authentication
314
+ // function to additionally write out a banner error message.
315
+ type WithBannerError struct {
316
+ Err error
317
+ Message string
318
+ }
319
+
320
+ func (e WithBannerError ) Unwrap () error {
321
+ return e .Err
322
+ }
323
+
324
+ func (e WithBannerError ) Error () string { return e .Err .Error () }
325
+
313
326
func checkSourceAddress (addr net.Addr , sourceAddrs string ) error {
314
327
if addr == nil {
315
328
return errors .New ("ssh: no address known for client, but source-address match required" )
@@ -668,6 +681,13 @@ userAuthLoop:
668
681
break userAuthLoop
669
682
}
670
683
684
+ var w WithBannerError
685
+ if errors .As (authErr , & w ) && w .Message != "" {
686
+ bannerMsg := & userAuthBannerMsg {Message : w .Message }
687
+ if err := s .transport .writePacket (Marshal (bannerMsg )); err != nil {
688
+ return nil , err
689
+ }
690
+ }
671
691
if errors .Is (authErr , ErrDenied ) {
672
692
var failureMsg userAuthFailureMsg
673
693
if config .ImplictAuthMethod != "" {
You can’t perform that action at this time.
0 commit comments