mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Ask for password interactively
This commit is contained in:
parent
b0427c2e3c
commit
cdbff57e6c
@ -327,7 +327,29 @@ try
|
||||
showClientVersion();
|
||||
}
|
||||
|
||||
connect();
|
||||
try
|
||||
{
|
||||
connect();
|
||||
}
|
||||
catch (const Exception & e)
|
||||
{
|
||||
if (e.code() == DB::ErrorCodes::AUTHENTICATION_FAILED)
|
||||
{
|
||||
if (!config().getString("password", "").empty())
|
||||
throw;
|
||||
|
||||
if (!is_interactive)
|
||||
throw;
|
||||
|
||||
String prompt = fmt::format("Password for user ({}): ", config().getString("user", ""));
|
||||
String password;
|
||||
if (auto * result = readpassphrase(prompt, buf, sizeof(buf), 0))
|
||||
password = result;
|
||||
|
||||
config().setString("password", password);
|
||||
connect();
|
||||
}
|
||||
}
|
||||
|
||||
/// Show warnings at the beginning of connection.
|
||||
if (is_interactive && !config().has("no-warnings"))
|
||||
|
Loading…
Reference in New Issue
Block a user