From: Amos Jeffries Date: Wed, 25 May 2022 10:53:59 +0000 (+0000) Subject: Add runner to initialize NTLM auth (#1051) X-Git-Tag: SQUID_6_0_1~179 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09490bb867d0b3f00a29911a65c715108e95b782;p=thirdparty%2Fsquid.git Add runner to initialize NTLM auth (#1051) --- diff --git a/src/AuthReg.cc b/src/AuthReg.cc index 1048c3a7bc..2840dffa13 100644 --- a/src/AuthReg.cc +++ b/src/AuthReg.cc @@ -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 */ diff --git a/src/auth/ntlm/Scheme.cc b/src/auth/ntlm/Scheme.cc index 5fac5e1d77..3edc1a9a82 100644 --- a/src/auth/ntlm/Scheme.cc +++ b/src/auth/ntlm/Scheme.cc @@ -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 * diff --git a/src/auth/ntlm/Scheme.h b/src/auth/ntlm/Scheme.h index 68638a3073..6440b8b727 100644 --- a/src/auth/ntlm/Scheme.h +++ b/src/auth/ntlm/Scheme.h @@ -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