]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw ldap: move conditional LDAPEngine init into it's ctor 26131/head
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 4 Jan 2019 21:25:16 +0000 (16:25 -0500)
committerPrashant D <pdhange@redhat.com>
Fri, 25 Jan 2019 01:01:09 +0000 (20:01 -0500)
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 97e6c9dac7ca9050d7b16ac160120acbe6ddc33c)

Conflicts:
src/rgw/rgw_rest_s3.h : Added valid

src/rgw/rgw_auth_s3.h
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_s3.h

index 6f860a72a2e1fc0d98e522fd6b5896d108432671..c8f56148e75eb2b3cca5c4ca288a07981cd1de0e 100644 (file)
@@ -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);
     }
   }
index 6534e254ec2360802055200eaf8535ddbf2b9ecc..4cd59c05f2196bdc46c894a2eeb239b293f328a3 100644 (file)
@@ -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) {
@@ -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
 {
index 506f5f4c57b4eee90d75bb9f8692890717484aea..5cb86e21d29db6915a79a2e4290237a50147f85c 100644 (file)
@@ -847,6 +847,8 @@ public:
   const char* get_name() const noexcept override {
     return "rgw::auth::s3::LDAPEngine";
   }
+
+  static bool valid();
 };