| 350 | |
| 351 | |
| 352 | int Client::main(const std::vector<std::string> & /*args*/) |
| 353 | try |
| 354 | { |
| 355 | setupSignalHandler(); |
| 356 | |
| 357 | output_stream << std::fixed << std::setprecision(3); |
| 358 | error_stream << std::fixed << std::setprecision(3); |
| 359 | |
| 360 | registerFormats(); |
| 361 | registerFunctions(); |
| 362 | registerAggregateFunctions(); |
| 363 | |
| 364 | processConfig(); |
| 365 | adjustSettings(client_context); |
| 366 | |
| 367 | initTTYBuffer( |
| 368 | toProgressOption(config().getString("progress", "default")), toProgressOption(config().getString("progress-table", "default"))); |
| 369 | initKeystrokeInterceptor(); |
| 370 | |
| 371 | /// Includes delayed_interactive. |
| 372 | if (is_interactive) |
| 373 | { |
| 374 | clearTerminal(); |
| 375 | showClientVersion(); |
| 376 | } |
| 377 | |
| 378 | #if USE_JWT_CPP && USE_SSL |
| 379 | if (config().getBool("login", false)) |
| 380 | { |
| 381 | login(); |
| 382 | } |
| 383 | #endif |
| 384 | |
| 385 | bool asked_password = false; |
| 386 | bool asked_2fa = false; |
| 387 | for (;;) |
| 388 | { |
| 389 | try |
| 390 | { |
| 391 | connect(); |
| 392 | break; |
| 393 | } |
| 394 | catch (const Exception & e) |
| 395 | { |
| 396 | auto code = e.code(); |
| 397 | |
| 398 | bool should_ask_password = !asked_password && is_interactive && |
| 399 | (code == ErrorCodes::AUTHENTICATION_FAILED || code == ErrorCodes::REQUIRED_PASSWORD) && |
| 400 | !config().has("password") && !config().getBool("ask-password", false) && |
| 401 | !config().has("ssh-key-file"); |
| 402 | |
| 403 | if (should_ask_password) |
| 404 | { |
| 405 | asked_password = true; |
| 406 | config().setBool("ask-password", true); |
| 407 | continue; |
| 408 | } |
| 409 |
nothing calls this directly
no test coverage detected