Merge pull request #852 from Icinga:fix/icinga_agent_version_detection

Fix: Icinga Agent version detection by using the icinga2 binary instead of the registry values

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
This commit is contained in:
Lord Hepipud 2026-01-30 16:38:43 +01:00 committed by GitHub
commit 07611cc8cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -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

View file

@ -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;