Module: check_mk
Branch: master
Commit: ad157aaa1c38ccc5ac9a1419632eee14fad23cbb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ad157aaa1c38cc…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Jan 17 12:11:53 2014 +0100
FIX Fixed htpasswd permission problem in check_mk standalone installation
In a standalone installation the path <tt>/usr/local/nagios/etc</tt> is not
writable by the apache user.<br>
The user management module tried to create a file
<tt>/usr/local/nagios/etc/htpasswd.new</tt> and rename it to
<tt>/usr/local/nagios/etc/htpasswd</tt> afterwards -> failed<br>
The workaround is that no <tt>htpasswd.new</tt> file will be created on
standalone installations.
The user management module now directly writes in <tt>htpasswd</tt>.
---
.werks/259 | 12 ++++++++++++
ChangeLog | 1 +
web/plugins/userdb/htpasswd.py | 11 +++++++++--
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/.werks/259 b/.werks/259
new file mode 100644
index 0000000..1bedbd1
--- /dev/null
+++ b/.werks/259
@@ -0,0 +1,12 @@
+Title: Fixed htpasswd permission problem in check_mk standalone installation
+Level: 1
+Component: core
+Version: 1.2.5i1
+Date: 1389956512
+Class: fix
+
+In a standalone installation the path <tt>/usr/local/nagios/etc</tt> is not
writable by the apache user.<br>
+The user management module tried to create a file
<tt>/usr/local/nagios/etc/htpasswd.new</tt> and rename it to
+<tt>/usr/local/nagios/etc/htpasswd</tt> afterwards -> failed<br>
+The workaround is that no <tt>htpasswd.new</tt> file will be created on
standalone installations.
+The user management module now directly writes in <tt>htpasswd</tt>.
diff --git a/ChangeLog b/ChangeLog
index d127589..ed3339b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
* 0402 FIX: Fix exception in case of missing agent sections of cluster-aware
checks...
* 0426 FIX: Fixed processing of cached agent plugins / local scripts...
* 0451 FIX: Ignore missing check types when creating configuration for Nagios
+ * 0259 FIX: Fixed htpasswd permission problem in check_mk standalone installation...
Checks & Agents:
* 0306 esx_vsphere_counters: added missing ramdisk levels sfcbtickets
diff --git a/web/plugins/userdb/htpasswd.py b/web/plugins/userdb/htpasswd.py
index 883e3f1..0839394 100644
--- a/web/plugins/userdb/htpasswd.py
+++ b/web/plugins/userdb/htpasswd.py
@@ -108,7 +108,13 @@ def htpasswd_save(users):
# WATO, you should continue to do so or stop doing to for ever...
# Locked accounts get a '!' before their password. This disable it.
filename = defaults.htpasswd_file + '.new'
- out = create_user_file(filename, "w")
+ rename_file = True
+ try:
+ out = create_user_file(filename, "w")
+ except:
+ rename_file = False
+ out = create_user_file(defaults.htpasswd_file, "w")
+
for id, user in users.items():
# only process users which are handled by htpasswd connector
if user.get('connector', 'htpasswd') != 'htpasswd':
@@ -121,7 +127,8 @@ def htpasswd_save(users):
locksym = ""
out.write("%s:%s%s\n" % (id, locksym, user["password"]))
out.close()
- os.rename(filename, filename[:-4])
+ if rename_file:
+ os.rename(filename, filename[:-4])
multisite_user_connectors.append({
'id': 'htpasswd',