]> 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 07:42:05 +0000 (08:42 +0100)
fixes #11204

lib/cli/nodesetupcommand.cpp

index db9f6bf0bd77cb069f8eb73a73986bba6d867619..2428f557a64c751ff71cda23e49fba28031f929a 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")