Module: check_mk
Branch: master
Commit: a706dadaf54b575b816665998c11c73fa69ebc92
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a706dadaf54b57…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 16 13:51:54 2012 +0100
WATO: preserve/honors users only in htpasswd
---
ChangeLog | 2 ++
web/htdocs/wato.py | 12 ++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1b3a6c2..d01304e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,8 @@
* FIX: allow UTF-8 encoded permission translations
* FIX: Fixed several problems in OMD apache shared mode
* FIX: Do not use None$ as item when creating new rules
+ * FIX: Do load *all* users from htpasswd, so passwords from
+ users not created via WATO will not be lost.
Checks & Agents:
* hpux_if: fix missing default parameter errors
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index d574fc3..9f30be0 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7005,7 +7005,11 @@ def load_users():
# Passwords are read directly from the apache htpasswd-file.
# That way heroes of the command line will still be able to
- # change passwords with htpasswd.
+ # change passwords with htpasswd. Users *only* appearing
+ # in htpasswd will also be loaded and assigned to the role
+ # they are getting according to the multisite old-style
+ # configuration variables.
+
filename = defaults.htpasswd_file
if os.path.exists(filename):
for line in file(filename):
@@ -7018,12 +7022,12 @@ def load_users():
if id in result:
result[id]["password"] = password
result[id]["locked"] = locked
- elif id in config.admin_users:
+ else:
# Create entry if this is an admin user
new_user = {
- "roles" : [ "admin" ],
+ "roles" : config.roles_of_user(id),
"password" : password,
- "locked" : False
+ "locked" : False
}
result[id] = new_user
# Other unknown entries will silently be dropped. Sorry...
Module: check_mk
Branch: master
Commit: d860b2df886d56bc62eca641f3e415fc02bc0e61
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d860b2df886d56…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 16 13:21:12 2012 +0100
Fixed problem with snmp_scan_functions of subchecks
---
modules/check_mk.py | 12 ++++++++----
modules/check_mk_base.py | 27 +++++++++++++++++++++++++--
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index b34e3af..e283474 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -630,9 +630,7 @@ def get_snmp_character_encoding(hostname):
return entries[0]
def check_uses_snmp(check_type):
- base_check_name = check_type.split(".")[0]
- return base_check_name in check_info and \
- check_info[base_check_name].get("snmp_info") != None
+ return snmp_info.get(check_type.split(".")[0]) != None
def is_snmp_host(hostname):
return in_binary_hostlist(hostname, snmp_hosts)
@@ -741,7 +739,13 @@ def snmp_scan(hostname, ipaddress):
continue
elif not check_uses_snmp(check_type):
continue
- scan_function = check["snmp_scan_function"]
+ basename = check_type.split(".")[0]
+ # The scan function should be assigned to the basename, because
+ # subchecks sharing the same SNMP info of course should have
+ # an identical scan function. But some checks do not do this
+ # correctly
+ scan_function = snmp_scan_functions.get(check_type,
+ snmp_scan_functions.get(basename))
if scan_function:
try:
if scan_function(lambda oid: get_single_oid(hostname, ipaddress, oid)):
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 54e9374..e617656 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -305,7 +305,7 @@ def get_realhost_info(hostname, ipaddress, check_type, max_cache_age):
# Is this an SNMP table check? Then snmp_info specifies the OID to fetch
# Please note, that if the check_type is foo.bar then we lookup the
# snmp info for "foo", not for "foo.bar".
- oid_info = check_info.get(check_type, {}).get("snmp_info")
+ oid_info = snmp_info.get(check_type.split(".")[0])
if oid_info:
content = read_cache_file(cache_relpath, max_cache_age)
if content:
@@ -735,6 +735,7 @@ def convert_check_info():
check_function, service_description, has_perfdata, inventory_function = info
if inventory_function == no_inventory_possible:
inventory_function = None
+ basename = check_type.split(".")[0]
check_info[check_type] = {
"check_function" : check_function,
@@ -743,10 +744,32 @@ def convert_check_info():
"inventory_function" : inventory_function,
"group" : checkgroup_of.get(check_type),
"snmp_info" : snmp_info.get(check_type),
- "snmp_scan_function" : snmp_scan_functions.get(check_type),
+ # Sometimes the scan function is assigned to the check_type
+ # rather than to the base name.
+ "snmp_scan_function" :
+ snmp_scan_functions.get(check_type,
+ snmp_scan_functions.get(basename)),
"includes" : check_includes.get(check_type, []),
"default_levels_variable" : check_default_levels.get(check_type),
}
+ else:
+ # Make sure that all keys are present
+ info.setdefault("inventory_function", None)
+ info.setdefault("group", None)
+ info.setdefault("snmp_info", None)
+ info.setdefault("snmp_scan_function", None)
+ info.setdefault("includes", [])
+ info.setdefault("default_levels_variable", None)
+
+ # Now gather snmp_info and snmp_scan_function back to the
+ # original arrays. Note: these information is tied to a "agent section",
+ # not to a check. Several checks may use the same SNMP info and scan function.
+ for info in check_info.values():
+ basename = check_type.split(".")[0]
+ if info["snmp_info"] and basename not in snmp_info:
+ snmp_info[basename] = info["snmp_info"]
+ if info["snmp_scan_function"] and basename not in snmp_scan_functions:
+ snmp_scan_functions[basename] = info["snmp_scan_function"]
# Loops over all checks for a host, gets the data, calls the check
# function that examines that data and sends the result to Nagios