Module: check_mk
Branch: master
Commit: b6f0f98410079bc7b852e42c1b931542831fddf3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b6f0f98410079b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jun 18 10:03:00 2014 +0200
FIX Reducing size of auth.php (needed for authorisation in NagVis) in large environments
In environments with a large user base or a large folder structure, the auth.php file
which
is being generated while modifying users, roles and activating the pending changes, the
file
could get very large. This change reduces the size of the file in such a case
dramatically.
---
.werks/821 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 18 +++++++++++++-----
web/plugins/userdb/hook_auth.py | 9 ++++++++-
4 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/.werks/821 b/.werks/821
new file mode 100644
index 0000000..44c60ac
--- /dev/null
+++ b/.werks/821
@@ -0,0 +1,10 @@
+Title: Reducing size of auth.php (needed for authorisation in NagVis) in large
environments
+Level: 1
+Component: wato
+Version: 1.2.5i4
+Date: 1403078473
+Class: fix
+
+In environments with a large user base or a large folder structure, the auth.php file
which
+is being generated while modifying users, roles and activating the pending changes, the
file
+could get very large. This change reduces the size of the file in such a case
dramatically.
diff --git a/ChangeLog b/ChangeLog
index 45beef1..a7b0e3f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,7 @@
* 0987 New button for updating DNS cache...
* 0813 FIX: LDAP: Improved slightly missleading logging of LDAP sync actions...
* 0935 FIX: CPU utilization: increased maximum value to 10000...
+ * 0821 FIX: Reducing size of auth.php (needed for authorisation in NagVis) in large
environments...
Reporting & Availability:
* 0985 Availability: display phases of freqent state changes as "chaos"...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 04ec06d..edf2644 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -1060,12 +1060,20 @@ def get_folder_permissions_of_users(users):
users = userdb.load_users()
for username in users.iterkeys():
- permissions[username] = {}
+ perms = {}
for folder_path, folder in folders.iteritems():
- permissions[username][folder_path] = {
- 'read': check_folder_permissions(folder, 'read', False,
username, users) == True,
- 'write': check_folder_permissions(folder, 'write', False,
username, users) == True,
- }
+ readable = check_folder_permissions(folder, 'read', False, username,
users) == True
+ writable = check_folder_permissions(folder, 'write', False, username,
users) == True
+
+ if readable or writable:
+ perms[folder_path] = {}
+ if readable:
+ perms[folder_path]['read'] = True
+ if writable:
+ perms[folder_path]['write'] = True
+
+ if perms:
+ permissions[username] = perms
return permissions
def check_folder_permissions(folder, how, exception=True, user = None, users = None):
diff --git a/web/plugins/userdb/hook_auth.py b/web/plugins/userdb/hook_auth.py
index 15392c6..771807c 100644
--- a/web/plugins/userdb/hook_auth.py
+++ b/web/plugins/userdb/hook_auth.py
@@ -112,7 +112,14 @@ function get_folder_permissions($username) {
if(!isset($mk_folders[$username])) {
return array();
} else {
- return $mk_folders[$username];
+ $permissions = $mk_folders[$username];
+ foreach ($permissions as $folder => $perms) {
+ if (!isset($perms['read']))
+ $perms['read'] = false;
+ elseif (!isset($perms['write']))
+ $perms['write'] = false;
+ }
+ return $permissions;
}
}