From 49c774e314ecfe289f56267f33a86a6b856c08b2 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Fri, 4 Jan 2019 16:25:16 -0500 Subject: [PATCH] rgw ldap: move conditional LDAPEngine init into it's ctor rgw::auth::ExternalAuthStrategy defines an LDAPEngine in a ctor-initializer list, making it too late to conditionally initialize -it- in ExternalAuthStrategy's ctor. Fixes: https://tracker.ceph.com/issues/24228 Signed-off-by: Matt Benjamin (cherry picked from commit 97e6c9dac7ca9050d7b16ac160120acbe6ddc33c) --- src/rgw/rgw_auth_s3.h | 3 +-- src/rgw/rgw_rest_s3.cc | 10 ++++++++++ src/rgw/rgw_rest_s3.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_auth_s3.h b/src/rgw/rgw_auth_s3.h index d3b6e44b74cbd..0917c52c18214 100644 --- a/src/rgw/rgw_auth_s3.h +++ b/src/rgw/rgw_auth_s3.h @@ -75,8 +75,7 @@ public: } - if (cct->_conf->rgw_s3_auth_use_ldap && - ! cct->_conf->rgw_ldap_uri.empty()) { + if (ldap_engine.valid()) { add_engine(Control::SUFFICIENT, ldap_engine); } } diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 67d0712f1f1b3..9ed0563fb66cf 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -4115,6 +4115,11 @@ std::mutex rgw::auth::s3::LDAPEngine::mtx; void rgw::auth::s3::LDAPEngine::init(CephContext* const cct) { + if (! cct->_conf->rgw_s3_auth_use_ldap || + ! cct->_conf->rgw_ldap_uri.empty()) { + return; + } + if (! ldh) { std::lock_guard lck(mtx); if (! ldh) { @@ -4134,6 +4139,11 @@ void rgw::auth::s3::LDAPEngine::init(CephContext* const cct) } } +bool rgw::auth::s3::LDAPEngine::valid() { + std::lock_guard lck(mtx); + return (!!ldh); +} + rgw::auth::RemoteApplier::acl_strategy_t rgw::auth::s3::LDAPEngine::get_acl_strategy() const { diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index 9e5ef4316aeb0..919e7c5a0ced1 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -846,6 +846,7 @@ public: return "rgw::auth::s3::LDAPEngine"; } + static bool valid(); static void shutdown(); }; -- 2.47.3