(connCtx context.Context, remoteName string, debugInfo *ConnectionDebugInfo)
| 420 | } |
| 421 | |
| 422 | func createInteractiveKbdInteractiveChallenge(connCtx context.Context, remoteName string, debugInfo *ConnectionDebugInfo) func(name, instruction string, questions []string, echos []bool) (answers []string, err error) { |
| 423 | return func(name, instruction string, questions []string, echos []bool) (answers []string, outErr error) { |
| 424 | defer func() { |
| 425 | panicErr := panichandler.PanicHandler("sshclient:kbdinteractive-callback", recover()) |
| 426 | if panicErr != nil { |
| 427 | outErr = panicErr |
| 428 | } |
| 429 | }() |
| 430 | if len(questions) != len(echos) { |
| 431 | return nil, fmt.Errorf("bad response from server: questions has len %d, echos has len %d", len(questions), len(echos)) |
| 432 | } |
| 433 | for i, question := range questions { |
| 434 | echo := echos[i] |
| 435 | answer, err := promptChallengeQuestion(connCtx, question, echo, remoteName) |
| 436 | if err != nil { |
| 437 | return nil, ConnectionError{ConnectionDebugInfo: debugInfo, Err: utilds.MakeCodedError(ConnErrCode_UserCancelled, err)} |
| 438 | } |
| 439 | answers = append(answers, answer) |
| 440 | } |
| 441 | return answers, nil |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | func promptChallengeQuestion(connCtx context.Context, question string, echo bool, remoteName string) (answer string, err error) { |
| 446 | // limited to 15 seconds for some reason. this should be investigated more |
no test coverage detected