Module: check_mk
Branch: master
Commit: bffd95d061f3e43447c7cc66338f6c6e49356797
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bffd95d061f3e4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 14 14:11:35 2012 +0100
ldap: Fixed locking problem in page sync hook
---
checkman/uptime | 2 +-
web/htdocs/userdb.py | 2 ++
web/plugins/userdb/ldap.py | 10 ++++++----
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/checkman/uptime b/checkman/uptime
index 914133f..2fa4d95 100644
--- a/checkman/uptime
+++ b/checkman/uptime
@@ -12,5 +12,5 @@ perfdata:
The uptime in seconds.
inventory:
- One check per system is created if the agent has a action
{<<<uptime>>>}.
+ One check per system is created if the agent has a section
{<<<uptime>>>}.
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 51ca6b6..3533ff5 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -264,6 +264,8 @@ def split_dict(d, keylist, positive):
def save_users(profiles):
custom_values = user_attributes.keys()
+ file('/tmp/a', 'a').write('%d saving users (%s %r)\n' %
(time.time(), html.req.myfile, html.req.vars))
+
# Keys not to put into contact definitions for Check_MK
non_contact_keys = [
"roles",
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index cf44790..44d8b6b 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -524,6 +524,10 @@ def ldap_login(username, password):
return result
def ldap_sync(add_to_changelog, only_username):
+ # Store time of the last sync. Don't store after sync since parallel
+ # requests to e.g. the page hook would cause duplicate calculations
+ file(g_ldap_sync_time_file, 'w').write('%s\n' % time.time())
+
ldap_connect()
# Unused at the moment, always sync all users
@@ -572,7 +576,8 @@ def ldap_sync(add_to_changelog, only_username):
users[user_id] = user # Update the user record
if mode_create:
- wato.log_pending(wato.SYNCRESTART, None, "edit-users", _("LDAP
Connector: Created user %s" % user_id))
+ wato.log_pending(wato.SYNCRESTART, None, "edit-users",
+ _("LDAP Connector: Created user %s" % user_id))
else:
wato.log_pending(wato.SYNCRESTART, None, "edit-users",
_("LDAP Connector: Modified user %s (Added: %s, Removed: %s,
Changed: %s)" %
@@ -580,9 +585,6 @@ def ldap_sync(add_to_changelog, only_username):
save_users(users)
- # Store time of the last sync
- file(g_ldap_sync_time_file, 'w').write('%s\n' % time.time())
-
# Calculates the attributes of the users which are locked for users managed
# by this connector
def ldap_locked_attributes():