diff --git a/lib/cli/nodesetupcommand.cpp b/lib/cli/nodesetupcommand.cpp index db9f6bf0b..2428f557a 100644 --- a/lib/cli/nodesetupcommand.cpp +++ b/lib/cli/nodesetupcommand.cpp @@ -335,16 +335,9 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm, } /* fix permissions: root -> icinga daemon user */ - std::vector 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")