[checkmk-commits] Check_MK Git: check_mk: Checking for existing auth.phgp and auth. serials independent of the used login method

git version control git at mathias-kettner.de
Thu Nov 22 09:17:59 CET 2012


Module: check_mk
Branch: master
Commit: 8da8c92ad2d1b56a3384f781e6577fd45e74f43b
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8da8c92ad2d1b56a3384f781e6577fd45e74f43b

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Thu Nov 22 09:18:08 2012 +0100

Checking for existing auth.phgp and auth.serials independent of the used login method

---

 web/htdocs/login.py  |   10 ----------
 web/htdocs/userdb.py |   23 ++++++++++++++++++++++-
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/web/htdocs/login.py b/web/htdocs/login.py
index 3c7557d..7e5e2ee 100644
--- a/web/htdocs/login.py
+++ b/web/htdocs/login.py
@@ -205,16 +205,6 @@ def page_login(no_html_output = False):
         return normal_login_page()
 
 def normal_login_page(called_directly = True):
-    # Working around the problem that the auth.php file needed for multisite based
-    # authorization of external addons might not exist when setting up a new installation
-    # We assume: Each user must visit this login page before using the multisite based
-    #            authorization. So we can easily create the file here if it is missing.
-    # This is a good place to replace old api based files in the future.
-    auth_php = defaults.var_dir + '/wato/auth/auth.php'
-    if not os.path.exists(auth_php) or os.path.getsize(auth_php) == 0:
-        import wato
-        wato.create_auth_file(wato.load_users())
-
     html.set_render_headfoot(False)
     html.header(_("Check_MK Multisite Login"), javascripts=[], stylesheets=["pages", "login"])
 
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index c49d112..e0da8ce 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -24,7 +24,7 @@
 # to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
 # Boston, MA 02110-1301 USA.
 
-import config
+import config, defaults
 from lib import *
 import time
 from valuespec import *
@@ -217,6 +217,25 @@ def hook_save(users):
             else:
                 raise
 
+# This function registers general stuff, which is independet of the single
+# connectors to each page load. It is exectued AFTER all other page hooks.
+def general_page_hook():
+    # Working around the problem that the auth.php file needed for multisite based
+    # authorization of external addons might not exist when setting up a new installation
+    # We assume: Each user must visit this login page before using the multisite based
+    #            authorization. So we can easily create the file here if it is missing.
+    # This is a good place to replace old api based files in the future.
+    auth_php = defaults.var_dir + '/wato/auth/auth.php'
+    if not os.path.exists(auth_php) or os.path.getsize(auth_php) == 0:
+        import wato
+        wato.create_auth_file(wato.load_users())
+
+    # Create initial auth.serials file, same issue as auth.php above
+    serials_file = '%s/auth.serials' % os.path.dirname(defaults.htpasswd_file)
+    if not os.path.exists(serials_file):
+        import wato
+        wato.save_users(wato.load_users())
+
 # Hook function can be registered here to execute actions on a "regular" base without
 # user triggered action. This hook is called on each page load.
 # Catch all exceptions and log them to apache error log. Let exceptions raise trough
@@ -235,3 +254,5 @@ def hook_page():
                 import traceback
                 html.log('Exception (%s, page handler): %s' % 
                             (connector['id'], traceback.format_exc()))
+
+    general_page_hook()



More information about the checkmk-commits mailing list