Module: check_mk
Branch: master
Commit: 0e498fbdd120ab7efd3af6a1fd807eead9481939
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0e498fbdd120ab…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 14 12:16:46 2015 +0200
#2461 FIX Service Discovery: Hiding action buttons to rules when user is not permitted to
rulesets
---
.werks/2461 | 9 +++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 38 ++++++++++++++++++++++----------------
3 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/.werks/2461 b/.werks/2461
new file mode 100644
index 0000000..54a6ef5
--- /dev/null
+++ b/.werks/2461
@@ -0,0 +1,9 @@
+Title: Service Discovery: Hiding action buttons to rules when user is not permitted to
rulesets
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.7i3
+Date: 1436868963
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index fa6ab99..580f3a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -78,6 +78,7 @@
* 2372 FIX: Avoid freezing WATO during bulk discovery if hosts do not respond in a
timely manner
* 1267 FIX: Fixed confirm activating foreign changes dialog...
* 2397 FIX: Fixed wrong confirm text in distributed setup when activating foreign
changes
+ * 2461 FIX: Service Discovery: Hiding action buttons to rules when user is not
permitted to rulesets
Notifications:
* 2313 FIX: notification bulking: fixed exception for plugins which are not
configured with checkboxes, e.g. sms
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 7d07670..61915cc 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -217,10 +217,7 @@ def page_handler():
# Check general permission for this mode
if modeperms != None and not config.may("wato.seeall"):
- for pname in modeperms:
- if '.' not in pname:
- pname = "wato." + pname
- config.need_permission(pname)
+ ensure_mode_permissions(modeperms)
# Do actions (might switch mode)
action_message = None
@@ -232,10 +229,7 @@ def page_handler():
# he needs an explicit access permission for doing changes:
if config.may("wato.seeall"):
if modeperms:
- for pname in modeperms:
- if '.' not in pname:
- pname = "wato." + pname
- config.need_permission(pname)
+ ensure_mode_permissions(modeperms)
result = modefunc("action")
if type(result) == tuple:
@@ -333,6 +327,13 @@ def page_handler():
html.footer()
+def ensure_mode_permissions(modeperms):
+ for pname in modeperms:
+ if '.' not in pname:
+ pname = "wato." + pname
+ config.need_permission(pname)
+
+
def set_current_folder(folder = None):
global g_folder
@@ -2011,7 +2012,8 @@ def mode_edithost(phase, new, cluster):
html.context_button(_("Services"),
make_link([("mode", "inventory"),
("host", hostname)]), "services")
- html.context_button(_("Parameters"),
+ if config.may('wato.rulesets'):
+ html.context_button(_("Parameters"),
make_link([("mode", "object_parameters"),
("host", hostname)]), "rulesets")
if not g_folder.get(".lock_hosts"):
html.context_button(_("Rename %s") % (cluster and
_("Cluster") or _("Host")),
@@ -2893,8 +2895,9 @@ def mode_diag_host(phase):
host_status_button(hostname, "hoststatus")
html.context_button(_("Properties"),
make_link([("mode", "edithost"),
("host", hostname)]), "edit")
- html.context_button(_("Parameters"),
- make_link([("mode", "object_parameters"),
("host", hostname)]), "rulesets")
+ if config.may('wato.rulesets'):
+ html.context_button(_("Parameters"),
+ make_link([("mode", "object_parameters"),
("host", hostname)]), "rulesets")
html.context_button(_("Services"),
make_link([("mode", "inventory"),
("host", hostname)]), "services")
return
@@ -3119,8 +3122,9 @@ def mode_inventory(phase, firsttime):
make_link([("mode", "folder")]),
"back")
host_status_button(hostname, "host")
html.context_button(_("Properties"), make_link([("mode",
"edithost"), ("host", hostname)]), "edit")
- html.context_button(_("Parameters"),
- make_link([("mode", "object_parameters"),
("host", hostname)]), "rulesets")
+ if config.may('wato.rulesets'):
+ html.context_button(_("Parameters"),
+ make_link([("mode",
"object_parameters"), ("host", hostname)]), "rulesets")
if ".nodes" not in host:
# only display for non cluster hosts
html.context_button(_("Diagnostic"),
@@ -3320,7 +3324,7 @@ def show_service_table(host, firsttime):
# Icon for Service parameters. Not for missing services!
table.cell(css='buttons')
- if check_source not in [ "new", "ignored" ]:
+ if check_source not in [ "new", "ignored" ] and
config.may('wato.rulesets'):
# Link to list of all rulesets affecting this service
params_url = make_link([("mode",
"object_parameters"),
("host", hostname),
@@ -3340,7 +3344,9 @@ def show_service_table(host, firsttime):
manpage_url = make_link([("mode", "check_manpage"),
("check_type", ctype)])
html.icon_button(manpage_url, _("View the manual page of the check
plugin"), "check_plugins")
- if check_source == "ignored":
+ can_access_disabled_services_rules = config.may('wato.rulesets')
+
+ if check_source == "ignored" and
can_access_disabled_services_rules:
url = make_link([("mode", "edit_ruleset"),
("varname", "ignored_services"),
("host", hostname),
@@ -3348,7 +3354,7 @@ def show_service_table(host, firsttime):
html.icon_button(url, _("Edit and analyze the disabled services
rules"), "ignore")
# Permanently disable icon
- if check_source in ['new', 'old']:
+ if check_source in ['new', 'old'] and
can_access_disabled_services_rules:
url = make_link([
('mode', 'edit_ruleset'),
('varname', 'ignored_services'),