Skip to content

Commit

Permalink
rgw ldap: move conditional LDAPEngine init into it's ctor
Browse files Browse the repository at this point in the history
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 <mbenjamin@redhat.com>
(cherry picked from commit 97e6c9d)

Conflicts:
	src/rgw/rgw_rest_s3.h : Added valid
  • Loading branch information
mattbenjamin authored and Prashant D committed Jan 25, 2019
1 parent 84d0554 commit d9fbba0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/rgw/rgw_auth_s3.h
Expand Up @@ -79,8 +79,7 @@ class ExternalAuthStrategy : public rgw::auth::Strategy,

}

if (cct->_conf->rgw_s3_auth_use_ldap &&
! cct->_conf->rgw_ldap_uri.empty()) {
if (ldap_engine.valid()) {
add_engine(Control::SUFFICIENT, ldap_engine);
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/rgw/rgw_rest_s3.cc
Expand Up @@ -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<std::mutex> lck(mtx);
if (! ldh) {
Expand All @@ -4078,6 +4083,11 @@ void rgw::auth::s3::LDAPEngine::init(CephContext* const cct)
}
}

bool rgw::auth::s3::LDAPEngine::valid() {
std::lock_guard<std::mutex> lck(mtx);
return (!!ldh);
}

rgw::auth::RemoteApplier::acl_strategy_t
rgw::auth::s3::LDAPEngine::get_acl_strategy() const
{
Expand Down
2 changes: 2 additions & 0 deletions src/rgw/rgw_rest_s3.h
Expand Up @@ -847,6 +847,8 @@ class LDAPEngine : public AWSEngine {
const char* get_name() const noexcept override {
return "rgw::auth::s3::LDAPEngine";
}

static bool valid();
};


Expand Down

0 comments on commit d9fbba0

Please sign in to comment.