]> granicus.if.org Git - icinga2/commitdiff
Fix: "node setup" tries to chown() files before they're created
authorGunnar Beutner <gunnar@beutner.name>
Tue, 23 Feb 2016 07:41:48 +0000 (08:41 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 23 Feb 2016 08:52:36 +0000 (09:52 +0100)
fixes #11204

lib/cli/nodesetupcommand.cpp

index ee265bb64c551e8b9c08dd035172526ac189e8d8..dbbec0b50ea0db582fbb5d293a6e7ee5012b39cb 100644 (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")