From c01cf5bf349516db36da9dcabafcf2f223f5e564 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Fri, 30 Jan 2026 16:37:05 +0100 Subject: [PATCH] Fixes Icinga Agent version detection by using the icinga2 binary instead of the registry values --- doc/100-General/10-Changelog.md | 1 + .../getters/Get-IcingaAgentInstallation.psm1 | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 86a30a0..e193966 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -21,6 +21,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#814](https://github.com/Icinga/icinga-powershell-framework/pull/814) Fixes random chars function to truly generate unpredictable character sequences and to replace `Get-Random` which is not entirely secure * [#815](https://github.com/Icinga/icinga-powershell-framework/pull/815) Fixes a possible crash for `Test-IcingaAddTypeExist`, causing the Icinga for Windows installation to fail when third party components are checked which are malfunctioning * [#816](https://github.com/Icinga/icinga-powershell-framework/issues/816) Fixes plugin execution error while using any `%IfNotMatch`/`%IfNotLike`/`%IfMatch`/`%IfLike` check function for strings containing special characters like `:` +* [#820](https://github.com/Icinga/icinga-powershell-framework/issues/820) Fixes the version detection of the installed Icinga Agent by looking on the local installed `icinga2.exe` instead of fully relying on the registry version, printing an error in case the versions do not match * [#829](https://github.com/Icinga/icinga-powershell-framework/pull/829) Fixes `Set-IcingaCacheData` to properly remove cache files in case `$null` is passed as value * [#833](https://github.com/Icinga/icinga-powershell-framework/issues/833) Fixes registry lookup for Icinga Agent installation to check if the required `DisplayName` attribute is defined before checking * [#834](https://github.com/Icinga/icinga-powershell-framework/issues/834) Fixes security catalog compilation error on non-english Windows versions, while properly skipping checks on system SID's and improves security by always adding the `SeDenyNetworkLogonRight` and `SeDenyInteractiveLogonRight` privilege section for the JEA user SID diff --git a/lib/core/icingaagent/getters/Get-IcingaAgentInstallation.psm1 b/lib/core/icingaagent/getters/Get-IcingaAgentInstallation.psm1 index a730de0..6d1ec4a 100644 --- a/lib/core/icingaagent/getters/Get-IcingaAgentInstallation.psm1 +++ b/lib/core/icingaagent/getters/Get-IcingaAgentInstallation.psm1 @@ -36,10 +36,28 @@ function Get-IcingaAgentInstallation() }; } + # Sometimes it can happen that the DisplayVersion in the registry is not correct + # (e.g. after manual upgrades or installation failures), so we try to fetch the version from the binary itself + $IcingaVersion = $IcingaData.DisplayVersion; + + try { + [string]$IcingaBinary = Join-Path -Path $IcingaData.InstallLocation -ChildPath 'sbin\icinga2.exe'; + + if (Test-Path -Path $IcingaBinary) { + $IcingaVersion = (Get-Item -Path $IcingaBinary).VersionInfo.FileVersion; + } + + if ($IcingaVersion -ne $IcingaData.DisplayVersion) { + Write-IcingaConsoleError 'The Icinga version retrieved from the registry ({0}) differs from the version retrieved from the binary ({1}). Please make sure the installation went through and the Icinga Agent is properly updated.' -Objects $IcingaData.DisplayVersion, $IcingaVersion; + } + } catch { + Write-IcingaConsoleError 'Failed to determine Icinga version from binary located at "{0}": {1}' -Objects $IcingaBinary, $_.Exception.Message; + } + return @{ 'Installed' = $TRUE; 'RootDir' = $IcingaData.InstallLocation; - 'Version' = (Split-IcingaVersion $IcingaData.DisplayVersion); + 'Version' = (Split-IcingaVersion $IcingaVersion); 'Architecture' = $architecture; 'Uninstaller' = $IcingaData.UninstallString.Replace("MsiExec.exe ", ""); 'InstallDate' = $IcingaData.InstallDate;