Module: check_mk
Branch: master
Commit: cdf1163ceae6469172f7d60d7c6a1daed3c3443e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cdf1163ceae646…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Oct 9 12:10:17 2013 +0200
FIX: Trying to prevent auth.php errors while file is being updated
---
ChangeLog | 3 ++-
web/plugins/userdb/hook_auth.py | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e29eb9c..1367601 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,7 +27,6 @@
* FIX: add missing service icons to view "All Services with this descr..."
* FIX: ldap attribute plugins: fixed crash when parameters are None
* FIX: avoid duplicate output of log message in log tables
- * Added title of tests to LDAP diagnose table
WATO:
* Rule "State and count of processes": New configuration options:
@@ -35,6 +34,8 @@
* FIX: The rule "State and count of processes" is no longer available
in "Parameters for inventorized check". This rule was solely
intented for "Manual checks" configuration
+ * FIX: Trying to prevent auth.php errors while file is being updated
+ * Added title of tests to LDAP diagnose table
1.2.3i2:
Core:
diff --git a/web/plugins/userdb/hook_auth.py b/web/plugins/userdb/hook_auth.py
index 977a8ac..a1c36ec 100644
--- a/web/plugins/userdb/hook_auth.py
+++ b/web/plugins/userdb/hook_auth.py
@@ -90,7 +90,9 @@ def create_php_file(callee, users, role_permissions, folder_permissions):
for username in users:
users[username].setdefault('language', config.default_language)
- file(g_auth_base_dir + '/auth.php', 'w').write('''<?php
+ # First write a temp file and then do a move to prevent syntax errors
+ # when reading half written files during creating that new file
+ file(g_auth_base_dir + '/auth.php.tmp', 'w').write('''<?php
// Created by Multisite UserDB Hook (%s)
global $mk_users, $mk_roles, $mk_folders;
$mk_users = %s;
@@ -183,6 +185,8 @@ function may($username, $need_permission) {
?>
''' % (callee, format_php(users), format_php(role_permissions), format_php(folder_permissions)))
+ # Now really replace the file
+ os.rename(g_auth_base_dir + '/auth.php.tmp', g_auth_base_dir + '/auth.php');
def create_auth_file(callee, users):
make_nagios_directory(g_auth_base_dir)