mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
parent
5a0fbfd80b
commit
278c6ae52b
@ -591,7 +591,7 @@ bool NodeUtility::CheckAgainstBlackAndWhiteList(const String& type, const String
|
|||||||
/*
|
/*
|
||||||
* We generally don't overwrite files without backup before
|
* 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))
|
if (!Utility::PathExists(target))
|
||||||
return false;
|
return false;
|
||||||
@ -607,7 +607,8 @@ bool NodeUtility::CreateBackupFile(const String& target, mode_t mode)
|
|||||||
Utility::CopyFile(target, backup);
|
Utility::CopyFile(target, backup);
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
chmod(backup.CStr(), mode);
|
if (is_private)
|
||||||
|
chmod(backup.CStr(), 0600);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
Log(LogInformation, "cli")
|
Log(LogInformation, "cli")
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
static std::vector<Dictionary::Ptr> GetNodes(void);
|
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);
|
static bool WriteNodeConfigObjects(const String& filename, const Array::Ptr& objects);
|
||||||
|
|
||||||
|
@ -243,9 +243,9 @@ wizard_master_host:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Utility::PathExists(node_key))
|
if (Utility::PathExists(node_key))
|
||||||
NodeUtility::CreateBackupFile(node_key, 0600);
|
NodeUtility::CreateBackupFile(node_key, true);
|
||||||
if (Utility::PathExists(node_cert))
|
if (Utility::PathExists(node_cert))
|
||||||
NodeUtility::CreateBackupFile(node_cert, 0640);
|
NodeUtility::CreateBackupFile(node_cert);
|
||||||
|
|
||||||
if (PkiUtility::NewCert(cn, node_key, Empty, node_cert) > 0) {
|
if (PkiUtility::NewCert(cn, node_key, Empty, node_cert) > 0) {
|
||||||
Log(LogCritical, "cli")
|
Log(LogCritical, "cli")
|
||||||
@ -270,7 +270,7 @@ wizard_master_host:
|
|||||||
String trusted_cert = PkiUtility::GetPkiPath() + "/trusted-master.crt";
|
String trusted_cert = PkiUtility::GetPkiPath() + "/trusted-master.crt";
|
||||||
|
|
||||||
if (Utility::PathExists(trusted_cert))
|
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) {
|
if (PkiUtility::SaveCert(master_host, master_port, node_key, node_cert, trusted_cert) > 0) {
|
||||||
Log(LogCritical, "cli")
|
Log(LogCritical, "cli")
|
||||||
@ -300,9 +300,9 @@ wizard_ticket:
|
|||||||
String target_ca = pki_path + "/ca.crt";
|
String target_ca = pki_path + "/ca.crt";
|
||||||
|
|
||||||
if (Utility::PathExists(target_ca))
|
if (Utility::PathExists(target_ca))
|
||||||
NodeUtility::CreateBackupFile(target_ca, 0640);
|
NodeUtility::CreateBackupFile(target_ca);
|
||||||
if (Utility::PathExists(node_cert))
|
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) {
|
if (PkiUtility::RequestCertificate(master_host, master_port, node_key, node_cert, target_ca, trusted_cert, ticket) > 0) {
|
||||||
Log(LogCritical, "cli")
|
Log(LogCritical, "cli")
|
||||||
@ -447,9 +447,9 @@ wizard_ticket:
|
|||||||
<< "Generating new CSR in '" << csr << "'.";
|
<< "Generating new CSR in '" << csr << "'.";
|
||||||
|
|
||||||
if (Utility::PathExists(key))
|
if (Utility::PathExists(key))
|
||||||
NodeUtility::CreateBackupFile(key, 0600);
|
NodeUtility::CreateBackupFile(key, true);
|
||||||
if (Utility::PathExists(csr))
|
if (Utility::PathExists(csr))
|
||||||
NodeUtility::CreateBackupFile(csr, 0640);
|
NodeUtility::CreateBackupFile(csr);
|
||||||
|
|
||||||
if (PkiUtility::NewCert(cn, key, csr, "") > 0) {
|
if (PkiUtility::NewCert(cn, key, csr, "") > 0) {
|
||||||
Log(LogCritical, "cli", "Failed to create certificate signing request.");
|
Log(LogCritical, "cli", "Failed to create certificate signing request.");
|
||||||
@ -463,7 +463,7 @@ wizard_ticket:
|
|||||||
<< "Signing CSR with CA and writing certificate to '" << cert << "'.";
|
<< "Signing CSR with CA and writing certificate to '" << cert << "'.";
|
||||||
|
|
||||||
if (Utility::PathExists(cert))
|
if (Utility::PathExists(cert))
|
||||||
NodeUtility::CreateBackupFile(cert, 0640);
|
NodeUtility::CreateBackupFile(cert);
|
||||||
|
|
||||||
if (PkiUtility::SignCsr(csr, cert) != 0) {
|
if (PkiUtility::SignCsr(csr, cert) != 0) {
|
||||||
Log(LogCritical, "cli", "Could not sign CSR.");
|
Log(LogCritical, "cli", "Could not sign CSR.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user