aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpnv1 <pnv1@yandex-team.ru>2022-02-28 19:16:31 +0300
committerpnv1 <pnv1@yandex-team.ru>2022-02-28 19:16:31 +0300
commit789b46c5738ab07280568a1f9cfdbd12c8f0a3a2 (patch)
tree1d5709c3284d91487b904324b7753e5d972b03f4
parent54def65c1501ce7d94424e4346eb9e1faa981a64 (diff)
downloadydb-789b46c5738ab07280568a1f9cfdbd12c8f0a3a2.tar.gz
Save config file with correct permissions, KIKIMR-14173
ref:cf8b743a80717d0bdce9abbd1e7acbcd348f56eb
-rw-r--r--ydb/public/lib/ydb_cli/common/profile_manager.cpp9
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) {