Module: check_mk
Branch: master
Commit: ae7080734c23a13bb51b0032f779042b833a0725
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ae7080734c23a1…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Mar 17 10:10:23 2015 +0100
#2145 FIX LDAP-Sync: Handling user ids with special characters more user friendly
At the moment the Check_MK GUI does not allow to use special characters like
german umlauts in the user ID. By default the LDAP sync pluginn tries to
replace these umlauts with some similar characters, or if enabled, it tries
to skip these users during sync.
But if a user ID contains other special characters, which are not handled by
the LDAP code, this could result in exceptions after synchronising such users.
We improved the handling of those users to skip them silently during
synchronisation. If you miss some users, just enable the diagnostic log and
have a look at the LDAP debug log (located in <tt>var/check_mk/web/ldap-debug.log</tt>
in OMD sites) and search for <tt>Skipped user: ...</tt> entries. If you need
these users within Check_MK please let us know, we will add the needed umlauts
to the translation map.
For future innovation releases we plan to make such special characters usable
in user IDs, then this translation map will not be needed anymore.
---
.werks/2145 | 27 +++++++++++++++++++++++++
ChangeLog | 1 +
web/plugins/userdb/ldap.py | 48 ++++++++++++++++++++++++++------------------
3 files changed, 56 insertions(+), 20 deletions(-)
diff --git a/.werks/2145 b/.werks/2145
new file mode 100644
index 0000000..67a69cd
--- /dev/null
+++ b/.werks/2145
@@ -0,0 +1,27 @@
+Title: LDAP-Sync: Handling user ids with special characters more user friendly
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1426583054
+
+At the moment the Check_MK GUI does not allow to use special characters like
+german umlauts in the user ID. By default the LDAP sync pluginn tries to
+replace these umlauts with some similar characters, or if enabled, it tries
+to skip these users during sync.
+
+But if a user ID contains other special characters, which are not handled by
+the LDAP code, this could result in exceptions after synchronising such users.
+
+We improved the handling of those users to skip them silently during
+synchronisation. If you miss some users, just enable the diagnostic log and
+have a look at the LDAP debug log (located in <tt>var/check_mk/web/ldap-debug.log</tt>
+in OMD sites) and search for <tt>Skipped user: ...</tt> entries. If you need
+these users within Check_MK please let us know, we will add the needed umlauts
+to the translation map.
+
+For future innovation releases we plan to make such special characters usable
+in user IDs, then this translation map will not be needed anymore.
+
diff --git a/ChangeLog b/ChangeLog
index bef1923..3d78848 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -311,6 +311,7 @@
* 2054 FIX: Sidebar snapin "Tree of folders": fixed exception when using localized default value...
* 2090 FIX: Fixed errors when editing / rendering custom url dashlets in some cases...
* 2092 FIX: Dashboards: Possible to configure an empty custom title
+ * 2145 FIX: LDAP-Sync: Handling user ids with special characters more user friendly...
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 3ba6bed..0704fa4 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -92,6 +92,20 @@ ldap_filter_map = {
},
}
+# All these characters are replaced from user ids by default. Check_MK
+# currently does not support special characters in user ids, so users
+# not matching this specification are cleaned up with this map. When the
+# user accounts still do not match the specification, they are skipped.
+ldap_umlaut_translation = {
+ ord(u'ü'): u'ue',
+ ord(u'ö'): u'oe',
+ ord(u'ä'): u'ae',
+ ord(u'ß'): u'ss',
+ ord(u'Ü'): u'UE',
+ ord(u'Ö'): u'OE',
+ ord(u'Ä'): u'AE',
+}
+
#.
# .-General LDAP code----------------------------------------------------.
# | _ ____ _ ____ |
@@ -106,6 +120,8 @@ ldap_filter_map = {
def ldap_log(s):
if config.ldap_debug_log is not None:
+ if type(s) == unicode:
+ s = s.encode('utf-8')
file(ldap_replace_macros(config.ldap_debug_log), "a").write('%s %s\n' %
(time.strftime('%Y-%m-%d %H:%M:%S'), s))
@@ -414,29 +430,21 @@ def ldap_rewrite_user_id(user_id):
user_id = user_id.lower()
umlauts = config.ldap_userspec.get('user_id_umlauts', 'replace')
- new = ""
- for c in user_id:
- if c == u'ü':
- new += 'ue'
- elif c == u'ö':
- new += 'oe'
- elif c == u'ä':
- new += 'ae'
- elif c == u'ß':
- new += 'ss'
- elif c == u'Ü':
- new += 'UE'
- elif c == u'Ö':
- new += 'OE'
- elif c == u'Ä':
- new += 'AE'
- else:
- new += c
+ new_user_id = user_id.translate(ldap_umlaut_translation)
+
if umlauts == 'replace':
- user_id = new
- elif umlauts == 'skip' and user_id != new:
+ user_id = new_user_id
+ elif umlauts == 'skip' and user_id != new_user_id:
return None # This makes the user being skipped
+ # Now check whether or not the user id matches our specification
+ try:
+ str(user_id)
+ except UnicodeEncodeError:
+ # Skipping this user: not all "bad" characters were replaced before
+ ldap_log('Skipped user: %s (contains not allowed special characters)' % user_id)
+ return None
+
return user_id
def ldap_user_id_attr():
Module: check_mk
Branch: master
Commit: 050d2bd2656fec7354e971817486389d6c1ffdb6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=050d2bd2656fec…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 16 16:18:17 2015 +0100
#2144 FIX Fixed exception in inventory GUI when trying to render dates of inventorized exe files
Till this change the agent provided the installation dates of the exe files in a localized
format (depending on the system locale config). The new agent is now providing a non
localized format which can easily be parsed by the check.
Not parsed installation dates lead to exceptions in the GUI when showing the inventorized
information of a host.
---
.werks/2144 | 15 +++++++++++++++
ChangeLog | 1 +
agents/windows/plugins/mk_inventory.ps1 | 3 ++-
inventory/win_exefiles | 11 +++++++++--
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.werks/2144 b/.werks/2144
new file mode 100644
index 0000000..91d05d3
--- /dev/null
+++ b/.werks/2144
@@ -0,0 +1,15 @@
+Title: Fixed exception in inventory GUI when trying to render dates of inventorized exe files
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1426518769
+
+Till this change the agent provided the installation dates of the exe files in a localized
+format (depending on the system locale config). The new agent is now providing a non
+localized format which can easily be parsed by the check.
+
+Not parsed installation dates lead to exceptions in the GUI when showing the inventorized
+information of a host.
diff --git a/ChangeLog b/ChangeLog
index 0b22b7d..bef1923 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -259,6 +259,7 @@
* 1895 FIX: temperature.include: Fixed Fahrenheit handling...
* 2097 FIX: apc_symmetra: Fixed false alert during self test...
* 2143 FIX: Solaris-Agent: Fixed broken zfsget checks on solaris 10
+ * 2144 FIX: Fixed exception in inventory GUI when trying to render dates of inventorized exe files...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request, added mailto link for error report...
diff --git a/agents/windows/plugins/mk_inventory.ps1 b/agents/windows/plugins/mk_inventory.ps1
index 0a11313..6c71525 100644
--- a/agents/windows/plugins/mk_inventory.ps1
+++ b/agents/windows/plugins/mk_inventory.ps1
@@ -2,6 +2,8 @@
$delay = 14400 # execute agent only every $delay seconds
$exe_paths = @("c:\Program Files (x86)")
+[System.Threading.Thread]::CurrentThread.CurrentCulture = [Globalization.CultureInfo]::InvariantCulture
+[System.Threading.Thread]::CurrentThread.CurrentUICulture = [Globalization.CultureInfo]::InvariantCulture
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
write-output "" # workaround to prevent the byte order mark to be at the beginning of the first section
$name = (Get-Item env:\Computername).Value
@@ -17,7 +19,6 @@ if (!$agent_dir) {
$timestamp = $agent_dir + "\timestamp."+ $remote_host
-
# does $timestamp exist?
If (Test-Path $timestamp){
$filedate = (ls $timestamp).LastWriteTime
diff --git a/inventory/win_exefiles b/inventory/win_exefiles
index 4641532..b5d1862 100644
--- a/inventory/win_exefiles
+++ b/inventory/win_exefiles
@@ -35,13 +35,20 @@ def inv_win_exefiles(info):
paclist = inv_tree("software.packages:")
for full_name, write_time, size, description, product_version, product_name in info:
parts = full_name.split('\\')
- # 14.02.2014 23:12:04
+ # Since 1.2.6p1 the agent always provides a date format of "04/18/2003 18:06:32".
+ # Old agent versions provided localized date formats which lead to problems here
+ # when none of the implemented parsers matches. We keep the existing parsers for
+ # compatibility, all users with yet unhandled formats should update the agent to
+ # solve the problems.
if re.match("^\d{2}\.\d{2}\.20\d{2} \d{2}:\d{2}:\d{2}", write_time):
install_date = int(time.mktime(time.strptime(write_time, "%d.%m.%Y %H:%M:%S")))
elif re.match("^\d{1,2}/\d{1,2}/20\d{2} \d{1,2}:\d{2}:\d{2} (AM|PM)", write_time):
install_date = int(time.mktime(time.strptime(write_time, "%m/%d/%Y %H:%M:%S %p")))
+ elif re.match("^\d{1,2}/\d{1,2}/20\d{2} \d{1,2}:\d{2}:\d{2}", write_time):
+ # This is the 1.2.6p1 new default date
+ install_date = int(time.mktime(time.strptime(write_time, "%m/%d/%Y %H:%M:%S")))
else:
- install_date = write_time
+ install_date = None # need to return 0 to not break the painter which assumes an int
entry = {
"name" : parts[-1],