summaryrefslogtreecommitdiff
path: root/bin/bbstoreaccounts/bbstoreaccounts.cpp
diff options
context:
space:
mode:
authorIleana Dumitrescu <ileanadumi95@protonmail.com>2022-04-07 16:09:31 +0300
committerIleana Dumitrescu <ileanadumi95@protonmail.com>2022-04-07 16:09:31 +0300
commit959373df08e55cb41506f3ef2a1535fe55b73501 (patch)
tree13207dbc4036a7a0b225f69315328dd56ae3d533 /bin/bbstoreaccounts/bbstoreaccounts.cpp
parent657715ed754d69235aac62cd36f514f6dc65aab8 (diff)
New upstream version 0.13~~git20220405.g7703ac8
Diffstat (limited to 'bin/bbstoreaccounts/bbstoreaccounts.cpp')
-rw-r--r--bin/bbstoreaccounts/bbstoreaccounts.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/bin/bbstoreaccounts/bbstoreaccounts.cpp b/bin/bbstoreaccounts/bbstoreaccounts.cpp
index 6a173680..1d4252fd 100644
--- a/bin/bbstoreaccounts/bbstoreaccounts.cpp
+++ b/bin/bbstoreaccounts/bbstoreaccounts.cpp
@@ -130,19 +130,35 @@ int main(int argc, const char *argv[])
// Read in the configuration file
std::string errs;
- std::auto_ptr<Configuration> config(
+ std::auto_ptr<Configuration> apConfig(
Configuration::LoadAndVerify
(configFilename, &BackupConfigFileVerify, errs));
- if(config.get() == 0 || !errs.empty())
+ if(apConfig.get() == 0 || !errs.empty())
{
BOX_ERROR("Invalid configuration file " << configFilename <<
":" << errs);
}
+#ifndef WIN32
+ // Handle changing to a different user, to match bbstored, to ensure that files don't end up
+ // owned by the wrong user.
+ const Configuration &serverConfig(
+ apConfig->GetSubConfiguration("Server"));
+
+ if(serverConfig.KeyExists("User"))
+ {
+ // Config file specifies an user -- look up
+ UnixUser daemonUser(serverConfig.GetKeyValue("User").c_str());
+
+ // Change the process ID
+ daemonUser.ChangeProcessUser(); // temporary=false
+ }
+#endif
+
// Initialise the raid file controller
RaidFileController &rcontroller(RaidFileController::GetController());
- rcontroller.Initialise(config->GetKeyValue("RaidFileConf").c_str());
+ rcontroller.Initialise(apConfig->GetKeyValue("RaidFileConf").c_str());
// Then... check we have two arguments
if(argc < 2)
@@ -158,7 +174,7 @@ int main(int argc, const char *argv[])
}
std::string command = argv[0];
- BackupStoreAccountsControl control(*config, machineReadableOutput);
+ BackupStoreAccountsControl control(*apConfig, machineReadableOutput);
// Now do the command.
if(command == "create")