|
@@ -283,7 +283,9 @@ func confirmKeyAck(key PublicKey, c packetConn) (bool, error) {
|
|
|
}
|
|
}
|
|
|
switch packet[0] {
|
|
switch packet[0] {
|
|
|
case msgUserAuthBanner:
|
|
case msgUserAuthBanner:
|
|
|
- // TODO(gpaul): add callback to present the banner to the user
|
|
|
|
|
|
|
+ if err := handleBannerResponse(c, packet); err != nil {
|
|
|
|
|
+ return false, err
|
|
|
|
|
+ }
|
|
|
case msgUserAuthPubKeyOk:
|
|
case msgUserAuthPubKeyOk:
|
|
|
var msg userAuthPubKeyOkMsg
|
|
var msg userAuthPubKeyOkMsg
|
|
|
if err := Unmarshal(packet, &msg); err != nil {
|
|
if err := Unmarshal(packet, &msg); err != nil {
|
|
@@ -325,7 +327,9 @@ func handleAuthResponse(c packetConn) (bool, []string, error) {
|
|
|
|
|
|
|
|
switch packet[0] {
|
|
switch packet[0] {
|
|
|
case msgUserAuthBanner:
|
|
case msgUserAuthBanner:
|
|
|
- // TODO: add callback to present the banner to the user
|
|
|
|
|
|
|
+ if err := handleBannerResponse(c, packet); err != nil {
|
|
|
|
|
+ return false, nil, err
|
|
|
|
|
+ }
|
|
|
case msgUserAuthFailure:
|
|
case msgUserAuthFailure:
|
|
|
var msg userAuthFailureMsg
|
|
var msg userAuthFailureMsg
|
|
|
if err := Unmarshal(packet, &msg); err != nil {
|
|
if err := Unmarshal(packet, &msg); err != nil {
|
|
@@ -340,6 +344,24 @@ func handleAuthResponse(c packetConn) (bool, []string, error) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func handleBannerResponse(c packetConn, packet []byte) error {
|
|
|
|
|
+ var msg userAuthBannerMsg
|
|
|
|
|
+ if err := Unmarshal(packet, &msg); err != nil {
|
|
|
|
|
+ return err
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ transport, ok := c.(*handshakeTransport)
|
|
|
|
|
+ if !ok {
|
|
|
|
|
+ return nil
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if transport.bannerCallback != nil {
|
|
|
|
|
+ return transport.bannerCallback(msg.Message)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return nil
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// KeyboardInteractiveChallenge should print questions, optionally
|
|
// KeyboardInteractiveChallenge should print questions, optionally
|
|
|
// disabling echoing (e.g. for passwords), and return all the answers.
|
|
// disabling echoing (e.g. for passwords), and return all the answers.
|
|
|
// Challenge may be called multiple times in a single session. After
|
|
// Challenge may be called multiple times in a single session. After
|
|
@@ -385,7 +407,9 @@ func (cb KeyboardInteractiveChallenge) auth(session []byte, user string, c packe
|
|
|
// like handleAuthResponse, but with less options.
|
|
// like handleAuthResponse, but with less options.
|
|
|
switch packet[0] {
|
|
switch packet[0] {
|
|
|
case msgUserAuthBanner:
|
|
case msgUserAuthBanner:
|
|
|
- // TODO: Print banners during userauth.
|
|
|
|
|
|
|
+ if err := handleBannerResponse(c, packet); err != nil {
|
|
|
|
|
+ return false, nil, err
|
|
|
|
|
+ }
|
|
|
continue
|
|
continue
|
|
|
case msgUserAuthInfoRequest:
|
|
case msgUserAuthInfoRequest:
|
|
|
// OK
|
|
// OK
|