From: Matt Benjamin Date: Fri, 4 Jan 2019 21:25:16 +0000 (-0500) Subject: rgw ldap: move conditional LDAPEngine init into it's ctor X-Git-Tag: v12.2.12~87^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F26131%2Fhead;p=ceph.git 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) Conflicts: src/rgw/rgw_rest_s3.h : Added valid --- diff --git a/src/rgw/rgw_auth_s3.h b/src/rgw/rgw_auth_s3.h index 6f860a72a2e..c8f56148e75 100644 --- a/src/rgw/rgw_auth_s3.h +++ b/src/rgw/rgw_auth_s3.h @@ -79,8 +79,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 6534e254ec2..4cd59c05f21 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -4059,6 +4059,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) { @@ -4078,6 +4083,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 506f5f4c57b..5cb86e21d29 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -847,6 +847,8 @@ public: const char* get_name() const noexcept override { return "rgw::auth::s3::LDAPEngine"; } + + static bool valid(); };