Skip to content

Commit 5d7824b

Browse files
authored
Merge pull request #685 from Icinga:fix/exception_on_stopping_jea_process
Fix: Exceptions in certain cases while trying to stop the JEA process Fixes an issue while trying to stop the JEA process in certain cases, which results in an error during installation but has no other effect on the environment
2 parents a2ba312 + e7356a7 commit 5d7824b

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1414
### Bugfixes
1515

1616
* [#683](https://github.com/Icinga/icinga-powershell-framework/pull/683) Fixes JEA installer to exclude domain from user name length check, which can easily exceed the Windows 20 digits username limit
17+
* [#685](https://github.com/Icinga/icinga-powershell-framework/pull/685) Fixes an issue while trying to stop the JEA process in certain cases, which results in an error during installation but has no other effect on the environment
1718
* [#686](https://github.com/Icinga/icinga-powershell-framework/pull/686) Fixes certutil error handling and message output in case the icingaforwindows.pfx could not be created
1819

1920
### Enhancements

lib/core/jea/Get-IcingaJEAServicePid.psm1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ function Get-IcingaJEAServicePid()
77
$JeaPid = $JeaPid.Replace("`r`n", '').Replace("`n", '').Replace(' ', '');
88
}
99

10+
if ([string]::IsNullOrEmpty($JeaPid) -Or $JeaPid -eq '0' -Or $JeaPid -eq 0) {
11+
return $null;
12+
}
13+
1014
return $JeaPid;
1115
}

lib/core/windows/Restart-IcingaWindowsService.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function Restart-IcingaWindowsService()
55
Stop-IcingaService -Service 'icingapowershell';
66

77
if ((Test-IcingaJEAServiceRunning -JeaPid $JeaPid)) {
8-
Stop-Process -Id $JeaPid -Force;
8+
Stop-IcingaJEAProcess -JeaPid $JeaPid;
99
}
1010

1111
Restart-IcingaService -Service 'icingapowershell';
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
function Stop-IcingaJEAProcess()
2+
{
3+
param (
4+
[string]$JeaPid = $null
5+
);
6+
7+
if ([string]::IsNullOrEmpty($JeaPid)) {
8+
[string]$JeaPid = Get-IcingaJEAServicePid;
9+
}
10+
11+
if ([string]::IsNullOrEmpty($JeaPid)) {
12+
return;
13+
}
14+
15+
if ($JeaPid -eq '0' -Or $JeaPid -eq 0) {
16+
return;
17+
}
18+
19+
$JeaPowerShellProcess = Get-Process -Id $JeaPid -ErrorAction SilentlyContinue;
20+
if ($null -eq $JeaPowerShellProcess) {
21+
return;
22+
}
23+
24+
if ($JeaPowerShellProcess.ProcessName -ne 'wsmprovhost') {
25+
return;
26+
}
27+
28+
try {
29+
Stop-Process -Id $JeaPid -Force -ErrorAction Stop;
30+
} catch {
31+
Write-IcingaConsoleError 'Unable to stop the JEA process "wsmprovhost" caused by the following error: "{0}".' -Objects $_.Exception.Message;
32+
}
33+
}

0 commit comments

Comments
 (0)