-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Problem
Icinga for Windows uses registry keys for its uninstallation (Icinga agent).
To determine what to uninstall, registry keys under HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* (and HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*) are searched.
Each key found tests for the DisplayName -eq 'Icinga 2'.
Since any program can write keys into this registry path, they can actually cause problems.
I've just had the problem that one program added its key but had no DisplayName attribute.
When comparing DisplayName this portion of the code simply fails/crashes, i.e. Get-IcingaAgentInstallation always fails.
Simplified:
Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'fails
Proposed solution
Before testing DisplayName -eq 'Icinga 2' the code should also test if the attribute DisplayName exists for the given registry key in the first place.
Related part of the code:
icinga-powershell-framework/lib/core/icingaagent/getters/Get-IcingaAgentInstallation.psm1
Lines 3 to 19 in 854ef78
| [string]$architecture = ''; | |
| if ([IntPtr]::Size -eq 4) { | |
| $architecture = "x86"; | |
| $regPath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'; | |
| } else { | |
| $architecture = "x86_64"; | |
| $regPath = @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'); | |
| } | |
| $RegistryData = Get-ItemProperty $regPath; | |
| $IcingaData = $null; | |
| foreach ($entry in $RegistryData) { | |
| if ($entry.DisplayName -eq 'Icinga 2') { | |
| $IcingaData = $entry; | |
| break; | |
| } | |
| } |