Module: check_mk
Branch: master
Commit: dc0ed31a00ec0b5e54c3614d58e8a73ddedf5668
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dc0ed31a00ec0b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 6 20:06:54 2014 +0200
#1153 FIX Changed custom user attributes can now be used immediately
IN previous versions changed custom user attributes needed a restart of the
apache process to take effect.
---
.bugs/1089 | 7 +++++--
.bugs/841 | 7 +++++--
.werks/1153 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/userdb.py | 18 +++++++++++++++---
web/plugins/userdb/ldap.py | 16 ++++++++++++++--
6 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/.bugs/1089 b/.bugs/1089
index d3d094f..1f80319 100644
--- a/.bugs/1089
+++ b/.bugs/1089
@@ -1,10 +1,13 @@
Title: New user custom attribute needs apache restart to work
Component: wato
-State: open
+Class: bug
+State: done
Date: 2014-01-30 15:14:42
Targetversion: 1.2.5i1
-Class: bug
If you create a new custom attribute for users then you
need to restart Apache in order to make that attribute visible
in the WATO pages.
+
+2014-08-06 20:05:19: changed state open -> done
+Changed custom attributes are now instantly visible on user profile page and ldap sync
plugin configuration
diff --git a/.bugs/841 b/.bugs/841
index 3bed1c3..21f2bdf 100644
--- a/.bugs/841
+++ b/.bugs/841
@@ -1,8 +1,11 @@
Title: View Editor: It's not possible to delete a view
Component: multisite
-State: open
+Class: bug
+State: done
Date: 2014-04-16 09:34:07
Targetversion: 1.2.5i1
-Class: bug
Currently it is not possible to delete a view in Multisite. I think this has to do with
the new security features regarding to the CVE's
+
+2014-08-06 19:22:15: changed state open -> done
+Has already been fixed.
diff --git a/.werks/1153 b/.werks/1153
new file mode 100644
index 0000000..0f4f8f9
--- /dev/null
+++ b/.werks/1153
@@ -0,0 +1,11 @@
+Title: Changed custom user attributes can now be used immediately
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.5i6
+Date: 1407348323
+Class: fix
+
+IN previous versions changed custom user attributes needed a restart of the
+apache process to take effect.
+
diff --git a/ChangeLog b/ChangeLog
index bdb0be4..e9c18d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,7 @@
* 1091 FIX: logwatch patterns: allow unicode text in pattern comment
* 1092 FIX: logwatch: now able to enter unicode text into the "Pattern
(Regex)" field
* 0191 FIX: Added swp files to the ignore list for the WATO git feature...
+ * 1153 FIX: Changed custom user attributes can now be used immediately...
1.2.5i5:
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index d0dc871..197e04b 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -34,9 +34,19 @@ loaded_with_language = False
# Custom user attributes
user_attributes = {}
+builtin_user_attribute_names = []
-# Load all login plugins
+# Load all userdb plugins
def load_plugins():
+ # Do not cache the custom user attributes. They can be created by the user
+ # during runtime, means they need to be loaded during each page request.
+ # But delete the old definitions before to also apply removals of attributes
+ if user_attributes:
+ for attr_name in user_attributes.keys():
+ if attr_name not in builtin_user_attribute_names:
+ del user_attributes[attr_name]
+ declare_custom_user_attrs()
+
global loaded_with_language
if loaded_with_language == current_language:
return
@@ -45,10 +55,12 @@ def load_plugins():
global user_attributes ; user_attributes = {}
global multisite_user_connectors ; multisite_user_connectors = []
- declare_custom_user_attrs()
-
load_web_plugins("userdb", globals())
+ global builtin_user_attribute_names
+ builtin_user_attribute_names = user_attributes.keys()
+ declare_custom_user_attrs()
+
# This must be set after plugin loading to make broken plugins raise
# exceptions all the time and not only the first time (when the plugins
# are loaded).
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index e4ec3e7..0b555b0 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -833,6 +833,11 @@ ldap_attribute_plugins['pager'] = {
# Register sync plugins for all custom user attributes (assuming simple data types)
def register_user_attribute_sync_plugins():
+ # Remove old user attribute plugins
+ for attr_name in ldap_attribute_plugins.keys():
+ if attr_name not in ldap_builtin_attribute_plugin_names:
+ del ldap_attribute_plugins[attr_name]
+
for attr, val in get_user_attributes():
ldap_attribute_plugins[attr] = {
'title': val['valuespec'].title(),
@@ -851,8 +856,6 @@ def register_user_attribute_sync_plugins():
],
}
-register_user_attribute_sync_plugins()
-
def ldap_convert_groups_to_contactgroups(plugin, params, user_id, ldap_user, user):
# 1. Fetch all existing group names in WATO
cg_names = load_group_information().get("contact", {}).keys()
@@ -1107,6 +1110,8 @@ def ldap_non_contact_attributes():
attrs.update(ldap_attribute_plugins.get(key,
{}).get('non_contact_attributes', []))
return list(attrs)
+ldap_builtin_attribute_plugin_names = []
+
# Is called on every multisite http request
def ldap_page():
try:
@@ -1114,6 +1119,13 @@ def ldap_page():
except:
last_sync_time = 0
+ # Save the builtin attribute names (to be able to delete removed user attributes)
+ global ldap_builtin_attribute_plugin_names
+ if not ldap_builtin_attribute_plugin_names:
+ ldap_builtin_attribute_plugin_names = ldap_attribute_plugins.keys()
+
+ register_user_attribute_sync_plugins()
+
# in case of sync problems, synchronize all 20 seconds, instead of the configured
# regular cache livetime
if os.path.exists(g_ldap_sync_fail_file):