From: Michael Friedrich Date: Mon, 6 May 2019 08:19:56 +0000 (+0200) Subject: CLI: Fix updates for NodeName/ZoneName constants X-Git-Tag: v2.11.0-rc1~116^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4197bc9bcd957a1edcf5cec80a9d03fcc4b6c313;p=icinga2 CLI: Fix updates for NodeName/ZoneName constants fixes #7117 --- diff --git a/lib/cli/nodesetupcommand.cpp b/lib/cli/nodesetupcommand.cpp index 20cb512cd..ad21f1d72 100644 --- a/lib/cli/nodesetupcommand.cpp +++ b/lib/cli/nodesetupcommand.cpp @@ -210,13 +210,13 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v Utility::RenameFile(tempApiPath, apipath); /* update constants.conf with NodeName = CN + TicketSalt = random value */ - if (cn != Utility::GetFQDN()) { + if (endpointName != Utility::GetFQDN()) { Log(LogWarning, "cli") - << "CN '" << cn << "' does not match the default FQDN '" << Utility::GetFQDN() << "'. Requires update for NodeName constant in constants.conf!"; + << "CN/Endpoint name '" << endpointName << "' does not match the default FQDN '" << Utility::GetFQDN() << "'. Requires update for NodeName constant in constants.conf!"; } - NodeUtility::UpdateConstant("NodeName", cn); - NodeUtility::UpdateConstant("ZoneName", cn); + NodeUtility::UpdateConstant("NodeName", endpointName); + NodeUtility::UpdateConstant("ZoneName", zoneName); String salt = RandomString(16); @@ -500,13 +500,14 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm, NodeUtility::GenerateNodeIcingaConfig(endpointName, zoneName, parentZoneName, vm["endpoint"].as >(), globalZones); /* update constants.conf with NodeName = CN */ - if (cn != Utility::GetFQDN()) { + if (endpointName != Utility::GetFQDN()) { Log(LogWarning, "cli") - << "CN '" << cn << "' does not match the default FQDN '" << Utility::GetFQDN() << "'. Requires an update for the NodeName constant in constants.conf!"; + << "CN/Endpoint name '" << endpointName << "' does not match the default FQDN '" + << Utility::GetFQDN() << "'. Requires an update for the NodeName constant in constants.conf!"; } - NodeUtility::UpdateConstant("NodeName", cn); - NodeUtility::UpdateConstant("ZoneName", vm["zone"].as()); + NodeUtility::UpdateConstant("NodeName", endpointName); + NodeUtility::UpdateConstant("ZoneName", zoneName); if (!ticket.IsEmpty()) { String ticketPath = ApiListener::GetCertsDir() + "/ticket"; diff --git a/lib/cli/nodewizardcommand.cpp b/lib/cli/nodewizardcommand.cpp index 07e7314ee..33243851f 100644 --- a/lib/cli/nodewizardcommand.cpp +++ b/lib/cli/nodewizardcommand.cpp @@ -86,7 +86,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, * 8. copy key information to /var/lib/icinga2/certs * 9. enable ApiListener feature * 10. generate zones.conf with endpoints and zone objects - * 11. set NodeName = cn in constants.conf + * 11. set NodeName = cn and ZoneName in constants.conf * 12. disable conf.d directory? * 13. reload icinga2, or tell the user to */ @@ -544,14 +544,14 @@ wizard_global_zone_loop_start: /* Generate node configuration. */ NodeUtility::GenerateNodeIcingaConfig(endpointName, zoneName, parentZoneName, endpoints, globalZones); - if (cn != Utility::GetFQDN()) { + if (endpointName != Utility::GetFQDN()) { Log(LogWarning, "cli") - << "CN '" << cn << "' does not match the default FQDN '" + << "CN/Endpoint name '" << endpointName << "' does not match the default FQDN '" << Utility::GetFQDN() << "'. Requires update for NodeName constant in constants.conf!"; } - NodeUtility::UpdateConstant("NodeName", cn); - NodeUtility::UpdateConstant("ZoneName", cn); + NodeUtility::UpdateConstant("NodeName", endpointName); + NodeUtility::UpdateConstant("ZoneName", zoneName); if (!ticket.IsEmpty()) { String ticketPath = ApiListener::GetCertsDir() + "/ticket"; @@ -777,8 +777,8 @@ wizard_global_zone_loop_start: NodeUtility::CreateBackupFile(NodeUtility::GetConstantsConfPath()); - NodeUtility::UpdateConstant("NodeName", cn); - NodeUtility::UpdateConstant("ZoneName", cn); + NodeUtility::UpdateConstant("NodeName", endpointName); + NodeUtility::UpdateConstant("ZoneName", zoneName); String salt = RandomString(16);