Skip to content

Commit 84ace18

Browse files
committed
18194 FIX Host check command: crash when using "Use a custom check plug-in" option
When setting the "Use a custom check plug-in" option for the Host check command ruleset and then logging in as a normal monitoring user without the permission to configure this option, this would lead to a crash to both the UI and the REST API. Now this option is still being display but not editable by users without permission. SUP-23384 Change-Id: Id709889822f854f3010324944b64507828769a55
1 parent dffecb5 commit 84ace18

2 files changed

Lines changed: 34 additions & 7 deletions

File tree

.werks/18194.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[//]: # (werk v2)
2+
# Host check command: crash when using "Use a custom check plug-in" option
3+
4+
key | value
5+
---------- | ---
6+
date | 2025-07-23T07:31:03+00:00
7+
version | 2.4.0p9
8+
class | fix
9+
edition | cre
10+
component | wato
11+
level | 1
12+
compatible | yes
13+
14+
When setting the "Use a custom check plug-in" option for the Host check command ruleset
15+
and then logging in as a normal monitoring user without the permission to configure this
16+
option, this would lead to a crash to both the UI and the REST API.
17+
18+
Now this option is still being display but not editable by users without permission.

cmk/gui/wato/_check_mk_configuration.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3778,18 +3778,26 @@ def _host_check_commands_host_check_command_choices() -> list[CascadingDropdownC
37783778
),
37793779
),
37803780
]
3781+
if edition(cmk.utils.paths.omd_root) is Edition.CSE:
3782+
return choices
37813783

3782-
if (
3783-
user.may("wato.add_or_modify_executables")
3784-
and edition(cmk.utils.paths.omd_root) is not Edition.CSE
3785-
):
3786-
choices.append(("custom", _("Use a custom check plug-in..."), PluginCommandLine()))
3787-
3784+
choices.append(
3785+
(
3786+
"custom",
3787+
_("Use a custom check plug-in..."),
3788+
PluginCommandLine(read_only=not user.may("wato.add_or_modify_executables")),
3789+
)
3790+
)
37883791
return choices
37893792

37903793

3791-
def PluginCommandLine() -> ValueSpec:
3794+
def PluginCommandLine(read_only: bool = False) -> ValueSpec:
37923795
def _validate_custom_check_command_line(value, varprefix):
3796+
if read_only:
3797+
raise MKUserError(
3798+
varprefix,
3799+
_("You are not allowed to change the command line of a custom check plug-in."),
3800+
)
37933801
if "--pwstore=" in value:
37943802
raise MKUserError(
37953803
varprefix, _("You are not allowed to use passwords from the password store here.")
@@ -3805,6 +3813,7 @@ def _validate_custom_check_command_line(value, varprefix):
38053813
)
38063814
+ monitoring_macro_help(),
38073815
size="max",
3816+
read_only=read_only,
38083817
validate=_validate_custom_check_command_line,
38093818
)
38103819

0 commit comments

Comments
 (0)