aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrgayazov <brgayazov@yandex-team.com>2022-10-25 19:21:42 +0300
committerbrgayazov <brgayazov@yandex-team.com>2022-10-25 19:21:42 +0300
commitd510268ad2a0e4e4247b76c65af8d943af0c9194 (patch)
tree7e2fb7e1bb49abde26b6f617440df07e41b8dec5
parent763101f49e6c3b2a99037f15c4dfe94d80725f62 (diff)
downloadydb-d510268ad2a0e4e4247b76c65af8d943af0c9194.tar.gz
Fixed saving user without password
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_profile.cpp9
-rw-r--r--ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp2
2 files changed, 9 insertions, 2 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_profile.cpp b/ydb/public/lib/ydb_cli/commands/ydb_profile.cpp
index 3e2b1c88cd1..544b293401c 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_profile.cpp
+++ b/ydb/public/lib/ydb_cli/commands/ydb_profile.cpp
@@ -259,7 +259,11 @@ namespace {
} else if (config.ParseResult->Has("sa-key-file")) {
PutAuthMethod( profile, "sa-key-file", config.ParseResult->Get("sa-key-file"));
} else if (config.ParseResult->Has("user")) {
- PutAuthStatic( profile, config.ParseResult->Get("user"), config.ParseResult->Get("password-file"), true );
+ TString pass;
+ if (config.ParseResult->Has("password-file")) {
+ pass = config.ParseResult->Get("password-file");
+ }
+ PutAuthStatic( profile, config.ParseResult->Get("user"), pass, true );
} else {
return false;
}
@@ -461,6 +465,9 @@ void TCommandProfileCommon::ValidateAuth(TConfig& config) {
(size_t)UseMetadataCredentials +
(size_t)(config.ParseResult->Has("sa-key-file")) +
(size_t)(config.ParseResult->Has("user") || config.ParseResult->Has("password-file"));
+ if (!config.ParseResult->Has("user") && config.ParseResult->Has("password-file")) {
+ throw TMisuseException() << "You cannot enter password-file without user";
+ }
if (authMethodCount > 1) {
TStringBuilder str;
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp b/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp
index 6f5461fb1b8..d8f7425cfe1 100644
--- a/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp
+++ b/ydb/public/lib/ydb_cli/commands/ydb_root_common.cpp
@@ -485,7 +485,7 @@ bool TClientCommandRootCommon::GetCredentialsFromProfile(std::shared_ptr<IProfil
void TClientCommandRootCommon::ParseCredentials(TConfig& config) {
size_t explicitAuthMethodCount = (size_t)(!TokenFile.empty()) + (size_t)(!YCTokenFile.empty())
+ (size_t)UseMetadataCredentials + (size_t)(!SaKeyFile.empty())
- + (size_t)(!UserName.empty() || !PasswordFile.empty());
+ + (size_t)(!UserName.empty() || !PasswordFile.empty() || DoNotAskForPassword);
switch (explicitAuthMethodCount) {
case 0: