Module: check_mk
Branch: master
Commit: 976868a6753564279e59b9899faaf1b7a319fa9c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=976868a6753564…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 25 12:48:39 2012 +0200
FIX: Handling empty lines in htpasswd correctly
---
ChangeLog | 2 ++
web/htdocs/login.py | 5 +++--
web/htdocs/wato.py | 36 +++++++++++++++++++-----------------
3 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 35107d2..d4bc0f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@
* FIX: Allowing german umlauts in users mail addresses
* Allow list of aux tags to be missing in host tag definitions. This
makes migration from older version easier.
+ * FIX: user management modules can now deal with empty lines in htpasswd
Multisite:
* New display type 'boxes-omit-root' for BI views
@@ -51,6 +52,7 @@
* FIX: fix problem where filter settings (of checkboxes) are not effective
when it comes to executing commands
* FIX: Fixed styling issues of view filters with dropdown fields
+ * FIX: multisite login can now deal with empty lines in htpasswd
Mobile:
* FIX: Fixed logtime filter settings in all mobile views
diff --git a/web/htdocs/login.py b/web/htdocs/login.py
index fb9eacb..88ebbc1 100644
--- a/web/htdocs/login.py
+++ b/web/htdocs/login.py
@@ -59,8 +59,9 @@ def load_htpasswd():
creds = {}
for line in open(defaults.htpasswd_file, 'r'):
- username, pwhash = line.split(':', 1)
- creds[username] = pwhash.rstrip('\n')
+ if ':' in line:
+ username, pwhash = line.split(':', 1)
+ creds[username] = pwhash.rstrip('\n')
return creds
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index cdb87e3..ebbd2cb 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7835,23 +7835,25 @@ def load_users():
filename = defaults.htpasswd_file
if os.path.exists(filename):
for line in file(filename):
- id, password = line.strip().split(":")[:2]
- if password.startswith("!"):
- locked = True
- password = password[1:]
- else:
- locked = False
- if id in result:
- result[id]["password"] = password
- result[id]["locked"] = locked
- else:
- # Create entry if this is an admin user
- new_user = {
- "roles" : config.roles_of_user(id),
- "password" : password,
- "locked" : False
- }
- result[id] = new_user
+ line = line.strip()
+ if ':' in line:
+ id, password = line.strip().split(":")[:2]
+ if password.startswith("!"):
+ locked = True
+ password = password[1:]
+ else:
+ locked = False
+ if id in result:
+ result[id]["password"] = password
+ result[id]["locked"] = locked
+ else:
+ # Create entry if this is an admin user
+ new_user = {
+ "roles" : config.roles_of_user(id),
+ "password" : password,
+ "locked" : False
+ }
+ result[id] = new_user
# Other unknown entries will silently be dropped. Sorry...
# Now read the automation secrets and add them to existing