Module: check_mk
Branch: master
Commit: f8cb2415cd0c119a8e98bd4434d01af22da176a6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f8cb2415cd0c11…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Jan 27 09:56:37 2014 +0100
FIX Fixed auth.serials permission problem in check_mk standalone installation
---
.werks/267 | 13 +++++++++++++
ChangeLog | 1 +
web/htdocs/userdb.py | 11 +++++++++--
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/.werks/267 b/.werks/267
new file mode 100644
index 0000000..d6953cc
--- /dev/null
+++ b/.werks/267
@@ -0,0 +1,13 @@
+Title: Fixed auth.serials permission problem in check_mk standalone installation
+Level: 1
+Component: core
+Class: fix
+State: unknown
+Version: 1.2.5i1
+Date: 1390812956
+
+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/auth_serials.new</tt> and rename it to
+<tt>/usr/local/nagios/etc/auth_serials</tt> afterwards ->
failed<br>
+The workaround is that no <tt>auth_serials.new</tt> file will be created on
standalone installations.
+The user management module now directly writes in <tt>auth_serials</tt>.
diff --git a/ChangeLog b/ChangeLog
index 6ef8201..c374413 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@
* 0453 FIX: Fix ugly Python exception in host diagnosis page in case of SNMP
error...
* 0696 FIX: Remove garbled output of cmk -v in state of CMC
* 0682 FIX: Allow overriding of active and custom checks by more specific rule...
+ * 0267 FIX: Fixed auth.serials permission problem in check_mk standalone
installation...
Checks & Agents:
* 0306 esx_vsphere_counters: added missing ramdisk levels sfcbtickets
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index ce7a5b9..7aba253 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -423,7 +423,13 @@ def save_users(profiles):
# Write out the users serials
serials_file = '%s/auth.serials.new' %
os.path.dirname(defaults.htpasswd_file)
- out = create_user_file(serials_file, "w")
+ rename_file = True
+ try:
+ out = create_user_file(serials_file, "w")
+ except:
+ rename_file = False
+ out = create_user_file(serials_file[:-4], "w")
+
def encode_utf8(value):
if type(value) == unicode:
value = value.encode("utf-8")
@@ -432,7 +438,8 @@ def save_users(profiles):
for user_id, user in profiles.items():
out.write('%s:%d\n' % (encode_utf8(user_id), user.get('serial',
0)))
out.close()
- os.rename(serials_file, serials_file[:-4])
+ if rename_file:
+ os.rename(serials_file, serials_file[:-4])
# Write user specific files
for id, user in profiles.items():