From b7f923dd0167e9513f89c831dbf77e7d011e10c0 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 8 Nov 2015 14:19:06 +0100 Subject: [PATCH] 'api setup' must not override existing certificate and api-users.conf file fixes #10560 --- lib/cli/apisetuputility.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/cli/apisetuputility.cpp b/lib/cli/apisetuputility.cpp index 585432955..0582476f9 100644 --- a/lib/cli/apisetuputility.cpp +++ b/lib/cli/apisetuputility.cpp @@ -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 << "'."; -- 2.49.0