Module: check_mk
Branch: master
Commit: fb753c68610b40eb57056f8a5fbc46ff9a0088e4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fb753c68610b40…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 20 09:40:07 2012 +0200
Fix problem in auth.php after prefixing permissions with general.
---
web/htdocs/index.py | 6 +++++-
web/plugins/wato/auth.py | 8 ++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index 29f6a5f..ccd09e5 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -228,6 +228,11 @@ def handler(req, profiling = True):
os.chmod(profilefile + ".py", 0755)
return apache.OK
+ # Make sure all plugins are avaiable as early as possible. At least
+ # we need the plugins (i.e. the permissions declared in these) at the
+ # time before the first login for generating auth.php.
+ load_all_plugins()
+
# Detect mobile devices
if html.has_var("mobile"):
html.mobile = not not html.var("mobile")
@@ -247,7 +252,6 @@ def handler(req, profiling = True):
# here. Automation calls bybass the normal authentication stuff
if req.myfile == "automation":
try:
- load_all_plugins()
handler()
except Exception, e:
html.write(str(e))
diff --git a/web/plugins/wato/auth.py b/web/plugins/wato/auth.py
index 5a0e450..de524f3 100644
--- a/web/plugins/wato/auth.py
+++ b/web/plugins/wato/auth.py
@@ -59,17 +59,17 @@
g_auth_base_dir = defaults.var_dir + '/wato/auth'
-def parse_php(data, lvl = 1):
+def format_php(data, lvl = 1):
s = ''
if isinstance(data, tuple) or isinstance(data, list):
s += 'array(\n'
for item in data:
- s += ' ' * lvl + parse_php(item, lvl + 1) + ',\n'
+ s += ' ' * lvl + format_php(item, lvl + 1) + ',\n'
s += ' ' * (lvl - 1) + ')'
elif isinstance(data, dict):
s += 'array(\n'
for key, val in data.iteritems():
- s += ' ' * lvl + parse_php(key, lvl + 1) + ' => ' +
parse_php(val, lvl + 1) + ',\n'
+ s += ' ' * lvl + format_php(key, lvl + 1) + ' => ' +
format_php(val, lvl + 1) + ',\n'
s += ' ' * (lvl - 1) + ')'
elif isinstance(data, str):
s += '\'%s\'' % data.replace('\'',
'\\\'')
@@ -181,7 +181,7 @@ function may($username, $need_permission) {
}
?>
-''' % (parse_php(users), parse_php(role_permissions),
parse_php(folder_permissions)))
+''' % (format_php(users), format_php(role_permissions),
format_php(folder_permissions)))
def create_auth_file(users):
make_nagios_directory(g_auth_base_dir)