Build fix for Windows

fixes #8260
This commit is contained in:
Michael Friedrich 2015-02-09 14:04:00 +01:00
parent 5a0fbfd80b
commit 278c6ae52b
3 changed files with 12 additions and 11 deletions

View File

@ -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")

View File

@ -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);

View File

@ -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.");