diff options
author | pnv1 <pnv1@yandex-team.ru> | 2022-02-28 19:16:31 +0300 |
---|---|---|
committer | pnv1 <pnv1@yandex-team.ru> | 2022-02-28 19:16:31 +0300 |
commit | 789b46c5738ab07280568a1f9cfdbd12c8f0a3a2 (patch) | |
tree | 1d5709c3284d91487b904324b7753e5d972b03f4 | |
parent | 54def65c1501ce7d94424e4346eb9e1faa981a64 (diff) | |
download | ydb-789b46c5738ab07280568a1f9cfdbd12c8f0a3a2.tar.gz |
Save config file with correct permissions, KIKIMR-14173
ref:cf8b743a80717d0bdce9abbd1e7acbcd348f56eb
-rw-r--r-- | ydb/public/lib/ydb_cli/common/profile_manager.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ydb/public/lib/ydb_cli/common/profile_manager.cpp b/ydb/public/lib/ydb_cli/common/profile_manager.cpp index 2dc09ecf61..cbb21ba307 100644 --- a/ydb/public/lib/ydb_cli/common/profile_manager.cpp +++ b/ydb/public/lib/ydb_cli/common/profile_manager.cpp @@ -151,7 +151,14 @@ private: if (!configFilePath.Parent().Exists()) { configFilePath.Parent().MkDirs(); } - TFileOutput resultConfigFile(configFilePath); + if (TFileStat(configFilePath).Mode & (S_IRGRP | S_IROTH)) { + int chmodResult = Chmod(configFilePath.GetPath().c_str(), S_IRUSR | S_IWUSR); + if (chmodResult) { + Cerr << "Couldn't change permissions for the file \"" << configFilePath.GetPath() << "\"" << Endl; + exit(chmodResult); + } + } + TFileOutput resultConfigFile(TFile(configFilePath, CreateAlways | WrOnly | AWUser | ARUser)); resultConfigFile << YAML::Dump(Config); } catch (const std::exception& e) { |