Module: check_mk
Branch: master
Commit: 4c8c7efd6d23c9ab629a05110f1a11834492375e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4c8c7efd6d23c9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jan 19 09:38:02 2012 +0100
FIX: Fixed not up-to-date role permission data in roles_saved hook
---
ChangeLog | 1 +
web/htdocs/config.py | 15 ++++++++++-----
web/htdocs/wato.py | 11 +++++++++++
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b448b08..fb499f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -62,6 +62,7 @@
* FIX: Writing single host_contactgroups rules for each selected
contactgroup in host edit dialog
* FIX: Fixed wrong folder contacgroup related permissions in auth.php api
+ * FIX: Fixed not up-to-date role permission data in roles_saved hook
BI:
* improve doc/treasures/check_bi_local.py: local check that creates
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index ab1c968..f0d1362 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -375,12 +375,17 @@ def need_permission(pname):
def get_role_permissions():
role_permissions = {}
+ # Loop all permissions
+ # and for each permission loop all roles
+ # and check wether it has the permission or not
+ roleids = roles.keys()
for perm in permissions_by_order:
- for role in perm['defaults']:
- if not role in role_permissions:
- role_permissions[role] = [ perm['name'] ]
- else:
- role_permissions[role].append(perm['name'])
+ for role_id in roleids:
+ if not role_id in role_permissions:
+ role_permissions[role_id] = []
+
+ if may_with_roles([role_id], perm['name']):
+ role_permissions[role_id].append(perm['name'])
return role_permissions
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 3d9375e..0bbefc9 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7269,6 +7269,11 @@ def load_roles():
try:
vars = { "roles" : roles }
execfile(filename, vars, vars)
+ # Reflect the data in the roles dict kept in the config module Needed
+ # for instant changes in current page while saving modified roles.
+ # Otherwise the hooks would work with old data when using helper
+ # functions from the config module
+ config.roles.update(vars['roles'])
return vars["roles"]
except Exception, e:
@@ -7279,6 +7284,12 @@ def load_roles():
def save_roles(roles):
+ # Reflect the data in the roles dict kept in the config module Needed
+ # for instant changes in current page while saving modified roles.
+ # Otherwise the hooks would work with old data when using helper
+ # functions from the config module
+ config.roles.update(roles)
+
make_nagios_directory(multisite_dir)
filename = multisite_dir + "roles.mk"
out = file(filename, "w")