Module: check_mk
Branch: master
Commit: 634d2521edd944a98a89adbf7f6672ec7fcfde93
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=634d2521edd944…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Sep 3 11:56:50 2015 +0200
#2578 FIX Fix exception in case a user has a non-existant role
Such a situation might be caused by manual configurations or other non-standard
operation.
---
.werks/2578 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/config.py | 14 +++++++++++---
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/.werks/2578 b/.werks/2578
new file mode 100644
index 0000000..f78497a
--- /dev/null
+++ b/.werks/2578
@@ -0,0 +1,11 @@
+Title: Fix exception in case a user has a non-existant role
+Level: 2
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1441274165
+
+Such a situation might be caused by manual configurations or other non-standard
+operation.
diff --git a/ChangeLog b/ChangeLog
index 8c4ffcf..5a5a327 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -197,6 +197,7 @@
* 1289 FIX: Fixed missing table headers in hostgroup view
* 2551 FIX: Fixed locking issues when editing dashboards...
* 2426 FIX: pnptemplate: fixed template for netapp_api_volumes
+ * 2578 FIX: Fix exception in case a user has a non-existant role...
WATO:
* 2365 Removed old deprecated notification global options for plain emails...
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index 88b103b..ad0e2d0 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -299,7 +299,7 @@ def roles_of_user(user):
roles[br] = {}
if user in multisite_users:
- return multisite_users[user]["roles"]
+ return existing_role_ids(multisite_users[user]["roles"])
elif user in admin_users:
return [ "admin" ]
elif user in guest_users:
@@ -309,12 +309,20 @@ def roles_of_user(user):
elif os.path.exists(config_dir + "/" + user +
"/automation.secret"):
return [ "guest" ] # unknown user with automation account
elif 'roles' in default_user_profile:
- return default_user_profile['roles']
+ return existing_role_ids(default_user_profile['roles'])
elif default_user_role:
- return [ default_user_role ]
+ return existing_role_ids([ default_user_role ])
else:
return []
+
+def existing_role_ids(role_ids):
+ return [
+ role_id for role_id in role_ids
+ if role_id in roles
+ ]
+
+
def alias_of_user(user):
if user in multisite_users:
return multisite_users[user].get("alias", user)