Fix: "node setup" tries to chown() files before they're created

fixes #11204
This commit is contained in:
Gunnar Beutner 2016-02-23 08:41:48 +01:00
parent 5b30c9ed2c
commit 74d1d68893
1 changed files with 8 additions and 10 deletions

View File

@ -335,16 +335,9 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
}
/* fix permissions: root -> icinga daemon user */
std::vector<String> files;
files.push_back(ca);
files.push_back(key);
files.push_back(cert);
BOOST_FOREACH(const String& file, files) {
if (!Utility::SetFileOwnership(file, user, group)) {
Log(LogWarning, "cli")
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << file << "'. Verify it yourself!";
}
if (!Utility::SetFileOwnership(key, user, group)) {
Log(LogWarning, "cli")
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << key << "'. Verify it yourself!";
}
Log(LogInformation, "cli", "Requesting a signed certificate from the master.");
@ -354,6 +347,11 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
return 1;
}
if (!Utility::SetFileOwnership(ca, user, group)) {
Log(LogWarning, "cli")
<< "Cannot set ownership for user '" << user << "' group '" << group << "' on file '" << ca << "'. Verify it yourself!";
}
/* fix permissions (again) when updating the signed certificate */
if (!Utility::SetFileOwnership(cert, user, group)) {
Log(LogWarning, "cli")