]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add runner to initialize NTLM auth (#1051)
authorAmos Jeffries <yadij@users.noreply.github.com>
Wed, 25 May 2022 10:53:59 +0000 (10:53 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 25 May 2022 11:46:42 +0000 (11:46 +0000)
src/AuthReg.cc
src/auth/ntlm/Scheme.cc
src/auth/ntlm/Scheme.h

index 1048c3a7bca1f8854ea112524ad94bfd80e2c789..2840dffa13357bebbb484eca51b49d159f0acbe5 100644 (file)
@@ -20,9 +20,6 @@
 #if HAVE_AUTH_MODULE_NEGOTIATE
 #include "auth/negotiate/Scheme.h"
 #endif
-#if HAVE_AUTH_MODULE_NTLM
-#include "auth/ntlm/Scheme.h"
-#endif
 
 #include "debug/Stream.h"
 
@@ -46,11 +43,6 @@ Auth::Init()
     static const char *negotiate_type = Auth::Negotiate::Scheme::GetInstance()->type();
     debugs(29,DBG_IMPORTANT,"Startup: Initialized Authentication Scheme '" << negotiate_type << "'");
 #endif
-#if HAVE_AUTH_MODULE_NTLM
-    static const char *ntlm_type = Auth::Ntlm::Scheme::GetInstance()->type();
-    debugs(29,DBG_IMPORTANT,"Startup: Initialized Authentication Scheme '" << ntlm_type << "'");
-#endif
-    debugs(29,DBG_IMPORTANT,"Startup: Initialized Authentication.");
 }
 
 #endif /* USE_AUTH */
index 5fac5e1d772b32ab6cace8c7cd6bf0b965942d7e..3edc1a9a82f8b11a2353c73848bf47b30e8b4bdf 100644 (file)
@@ -9,16 +9,28 @@
 #include "squid.h"
 #include "auth/ntlm/Config.h"
 #include "auth/ntlm/Scheme.h"
+#include "base/RunnersRegistry.h"
 #include "debug/Messages.h"
 #include "debug/Stream.h"
 #include "helper.h"
 
-Auth::Scheme::Pointer Auth::Ntlm::Scheme::_instance = NULL;
+class NtlmAuthRr : public RegisteredRunner
+{
+public:
+    /* RegisteredRunner API */
+    virtual void bootstrapConfig() override {
+        const char *type = Auth::Ntlm::Scheme::GetInstance()->type();
+        debugs(29, 2, "Initialized Authentication Scheme '" << type << "'");
+    }
+};
+RunnerRegistrationEntry(NtlmAuthRr);
 
 Auth::Scheme::Pointer
 Auth::Ntlm::Scheme::GetInstance()
 {
-    if (_instance == NULL) {
+    static Auth::Scheme::Pointer _instance;
+
+    if (!_instance) {
         _instance = new Auth::Ntlm::Scheme();
         AddScheme(_instance);
     }
@@ -34,11 +46,8 @@ Auth::Ntlm::Scheme::type() const
 void
 Auth::Ntlm::Scheme::shutdownCleanup()
 {
-    if (_instance == NULL)
-        return;
-
-    _instance = NULL;
-    debugs(29, Critical(61), "Shutdown: NTLM authentication.");
+    // TODO: destruct any active Ntlm::Config objects via runner
+    debugs(29, 2, "Shutdown: NTLM authentication.");
 }
 
 Auth::SchemeConfig *
index 68638a3073656caac7141169063e16b84362604a..6440b8b727b46c9fa744bdedc3fb1aea98bb53c3 100644 (file)
@@ -35,13 +35,6 @@ public:
     /* Not implemented */
     Scheme (Scheme const &);
     Scheme &operator=(Scheme const &);
-
-private:
-    /**
-     * Main instance of this authentication Scheme.
-     * NULL when the scheme is not being used.
-     */
-    static Auth::Scheme::Pointer _instance;
 };
 
 } // namespace Ntlm