Module: check_mk
Branch: master
Commit: 1206adc7eda85608e188c30fc3977bd4bc41d7cf
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1206adc7eda856…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 11 14:34:24 2016 +0100
Fixed exception when syncing to slave creates initial WATO config on remote site
---
web/htdocs/config.py | 19 ++++++-------------
web/htdocs/wato.py | 6 ++++++
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index 2025420..2944146 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -285,7 +285,7 @@ def login_super_user():
user_id = None
global user_role_ids
- user_role_ids = []
+ user_role_ids = [ "admin" ]
global user_baserole_ids
user_baserole_ids = [ "admin" ]
@@ -321,12 +321,6 @@ def hide_language(lang):
return lang in hide_languages
def roles_of_user(user):
- # Make sure, builtin roles are present, even if not modified
- # and saved with WATO.
- for br in builtin_role_ids:
- if br not in roles:
- roles[br] = {}
-
if user in multisite_users:
return existing_role_ids(multisite_users[user]["roles"])
elif user in admin_users:
@@ -422,12 +416,6 @@ def get_role_permissions():
# and for each permission loop all roles
# and check wether it has the permission or not
- # Make sure, builtin roles are present, even if not modified
- # and saved with WATO.
- for br in builtin_role_ids:
- if br not in roles:
- roles[br] = {}
-
roleids = roles.keys()
for perm in permissions_by_order:
for role_id in roleids:
@@ -607,4 +595,9 @@ def save_site_config():
def load_plugins(force):
load_web_plugins("config", globals())
+ # Make sure, builtin roles are present, even if not modified and saved with WATO.
+ for br in builtin_role_ids:
+ roles.setdefault(br, {})
+
+
load_plugins(True)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 305012f..1aefb28 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -9491,6 +9491,12 @@ def page_automation():
if secret != get_login_secret():
raise MKAuthException(_("Invalid automation secret."))
+ # The automation page is accessed unauthenticated. After leaving the index.py area
+ # into the page handler we always want to have a user context initialized to keep
+ # the code free from special cases (if no user logged in, then...). So fake the
+ # logged in user here.
+ config.login_super_user()
+
# To prevent mixups in written files we use the same lock here as for
# the normal WATO page processing. This might not be needed for some
# special automation requests, like inventory e.g., but to keep it simple,