[icinga-checkins] icinga.org: icinga2/feature/collector-3446: Build fix for Windows

git at icinga.org git at icinga.org
Mon Feb 9 15:08:02 CET 2015


Module: icinga2
Branch: feature/collector-3446
Commit: 278c6ae52b1b27916f84c8fb09df428c62445bf8
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=278c6ae52b1b27916f84c8fb09df428c62445bf8

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Mon Feb  9 14:04:00 2015 +0100

Build fix for Windows

fixes #8260

---

 lib/cli/nodeutility.cpp       |    5 +++--
 lib/cli/nodeutility.hpp       |    2 +-
 lib/cli/nodewizardcommand.cpp |   16 ++++++++--------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/cli/nodeutility.cpp b/lib/cli/nodeutility.cpp
index 5fd1191..648e4e0 100644
--- a/lib/cli/nodeutility.cpp
+++ b/lib/cli/nodeutility.cpp
@@ -591,7 +591,7 @@ bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String
 /*
  * We generally don't overwrite files without backup before
  */
-bool NodeUtility::CreateBackupFile(const String& target, mode_t mode)
+bool NodeUtility::CreateBackupFile(const String& target, bool is_private)
 {
 	if (!Utility::PathExists(target))
 		return false;
@@ -607,7 +607,8 @@ bool NodeUtility::CreateBackupFile(const String& target, mode_t mode)
 	Utility::CopyFile(target, backup);
 
 #ifndef _WIN32
-	chmod(backup.CStr(), mode);
+	if (is_private)
+		chmod(backup.CStr(), 0600);
 #endif /* _WIN32 */
 
 	Log(LogInformation, "cli")
diff --git a/lib/cli/nodeutility.hpp b/lib/cli/nodeutility.hpp
index f414b5a..c881e88 100644
--- a/lib/cli/nodeutility.hpp
+++ b/lib/cli/nodeutility.hpp
@@ -51,7 +51,7 @@ public:
 
 	static std::vector<Dictionary::Ptr> GetNodes(void);
 
-	static bool CreateBackupFile(const String& target, mode_t mode = 0640);
+	static bool CreateBackupFile(const String& target, bool is_private = false);
 
 	static bool WriteNodeConfigObjects(const String& filename, const Array::Ptr& objects);
 
diff --git a/lib/cli/nodewizardcommand.cpp b/lib/cli/nodewizardcommand.cpp
index 09e3d5d..cfc1e68 100644
--- a/lib/cli/nodewizardcommand.cpp
+++ b/lib/cli/nodewizardcommand.cpp
@@ -243,9 +243,9 @@ wizard_master_host:
 		}
 
 		if (Utility::PathExists(node_key))
-			NodeUtility::CreateBackupFile(node_key, 0600);
+			NodeUtility::CreateBackupFile(node_key, true);
 		if (Utility::PathExists(node_cert))
-			NodeUtility::CreateBackupFile(node_cert, 0640);
+			NodeUtility::CreateBackupFile(node_cert);
 
 		if (PkiUtility::NewCert(cn, node_key, Empty, node_cert) > 0) {
 			Log(LogCritical, "cli")
@@ -270,7 +270,7 @@ wizard_master_host:
 		String trusted_cert = PkiUtility::GetPkiPath() + "/trusted-master.crt";
 
 		if (Utility::PathExists(trusted_cert))
-			NodeUtility::CreateBackupFile(trusted_cert, 0640);
+			NodeUtility::CreateBackupFile(trusted_cert);
 
 		if (PkiUtility::SaveCert(master_host, master_port, node_key, node_cert, trusted_cert) > 0) {
 			Log(LogCritical, "cli")
@@ -300,9 +300,9 @@ wizard_ticket:
 		String target_ca = pki_path + "/ca.crt";
 
 		if (Utility::PathExists(target_ca))
-			NodeUtility::CreateBackupFile(target_ca, 0640);
+			NodeUtility::CreateBackupFile(target_ca);
 		if (Utility::PathExists(node_cert))
-			NodeUtility::CreateBackupFile(node_cert, 0640);
+			NodeUtility::CreateBackupFile(node_cert);
 
 		if (PkiUtility::RequestCertificate(master_host, master_port, node_key, node_cert, target_ca, trusted_cert, ticket) > 0) {
 			Log(LogCritical, "cli")
@@ -447,9 +447,9 @@ wizard_ticket:
 		    << "Generating new CSR in '" << csr << "'.";
 
 		if (Utility::PathExists(key))
-			NodeUtility::CreateBackupFile(key, 0600);
+			NodeUtility::CreateBackupFile(key, true);
 		if (Utility::PathExists(csr))
-			NodeUtility::CreateBackupFile(csr, 0640);
+			NodeUtility::CreateBackupFile(csr);
 
 		if (PkiUtility::NewCert(cn, key, csr, "") > 0) {
 			Log(LogCritical, "cli", "Failed to create certificate signing request.");
@@ -463,7 +463,7 @@ wizard_ticket:
 		    << "Signing CSR with CA and writing certificate to '" << cert << "'.";
 
 		if (Utility::PathExists(cert))
-			NodeUtility::CreateBackupFile(cert, 0640);
+			NodeUtility::CreateBackupFile(cert);
 
 		if (PkiUtility::SignCsr(csr, cert) != 0) {
 			Log(LogCritical, "cli", "Could not sign CSR.");



More information about the icinga-checkins mailing list