]> granicus.if.org Git - icinga2/commitdiff
'api setup' must not override existing certificate and api-users.conf file
authorMichael Friedrich <michael.friedrich@netways.de>
Sun, 8 Nov 2015 13:19:06 +0000 (14:19 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Sun, 8 Nov 2015 13:19:06 +0000 (14:19 +0100)
fixes #10560

lib/cli/apisetuputility.cpp

index 585432955953ecc823573e7fe5436e1f418a1b79..0582476f9ec25132f648871afe5f0b0f2947a829 100644 (file)
@@ -83,6 +83,12 @@ bool ApiSetupUtility::SetupMasterCertificates(const String& cn)
        String key = pki_path + "/" + cn + ".key";
        String csr = pki_path + "/" + cn + ".csr";
 
+       if (Utility::PathExists(key)) {
+               Log(LogInformation, "cli")
+                   << "Private key file '" << key << "' already existing, skipping.";
+               return true;
+       }
+
        Log(LogInformation, "cli")
            << "Generating new CSR in '" << csr << "'.";
 
@@ -153,6 +159,12 @@ bool ApiSetupUtility::SetupMasterApiUser(void)
        String api_password = RandomString(8);
        String apiuserspath = GetConfdPath() + "/api-users.conf";
 
+       if (Utility::PathExists(apiuserspath)) {
+               Log(LogInformation, "cli")
+                   << "API user config file '" << apiuserspath << "' already existing, skipping.";
+               return true;
+       }
+
        Log(LogInformation, "cli")
            << "Adding new ApiUser '" << api_username << "' in '" << apiuserspath << "'.";