summaryrefslogtreecommitdiff
path: root/bin/bbstoreaccounts/bbstoreaccounts.cpp
diff options
context:
space:
mode:
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")