]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: AuthSupported: deglobalize
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 17 Jun 2011 19:34:51 +0000 (12:34 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 20 Jun 2011 23:41:42 +0000 (16:41 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/auth/AuthAuthorizeHandler.cc
src/auth/AuthAuthorizeHandler.h
src/auth/AuthServiceHandler.cc
src/auth/AuthSupported.cc
src/auth/AuthSupported.h
src/auth/KeyRing.cc
src/mds/MDS.cc
src/mon/Monitor.cc
src/osd/OSD.cc

index 9234d6aef5c94683c32d97564c3667edaea27ced..03f301a861077082f8d718e2088b20990f063998 100644 (file)
@@ -23,22 +23,22 @@ static bool _initialized = false;
 static Mutex _lock("auth_service_handler_init");
 static map<int, AuthAuthorizeHandler *> authorizers;
 
-static void _init_authorizers(void)
+static void _init_authorizers(CephContext *cct)
 {
-  if (is_supported_auth(CEPH_AUTH_NONE)) {
+  if (is_supported_auth(CEPH_AUTH_NONE, cct)) {
     authorizers[CEPH_AUTH_NONE] = new AuthNoneAuthorizeHandler(); 
   }
-  if (is_supported_auth(CEPH_AUTH_CEPHX)) {
+  if (is_supported_auth(CEPH_AUTH_CEPHX, cct)) {
     authorizers[CEPH_AUTH_CEPHX] = new CephxAuthorizeHandler(); 
   }
   _initialized = true;
 }
 
-AuthAuthorizeHandler *get_authorize_handler(int protocol)
+AuthAuthorizeHandler *get_authorize_handler(int protocol, CephContext *cct)
 {
   Mutex::Locker l(_lock);
   if (!_initialized) {
-   _init_authorizers();
+   _init_authorizers(cct);
   }
 
   map<int, AuthAuthorizeHandler *>::iterator iter = authorizers.find(protocol);
index 6a0fe02b7f865e071501c15245a483a62d90203c..7837d0ca2ab5a9f6b9d86792d547a5cbccb4b60b 100644 (file)
@@ -30,6 +30,6 @@ struct AuthAuthorizeHandler {
                                 AuthCapsInfo& caps_info, uint64_t *auid = NULL) = 0;
 };
 
-extern AuthAuthorizeHandler *get_authorize_handler(int protocol);
+extern AuthAuthorizeHandler *get_authorize_handler(int protocol, CephContext *cct);
 
 #endif
index 665a7d65f512d05d8d36b55dcbc221f8737ee0d3..12966857aabccd929d3b932ec6830938b062207e 100644 (file)
@@ -24,9 +24,9 @@
 AuthServiceHandler *get_auth_service_handler(CephContext *cct, KeyServer *ks,
                                             set<__u32>& supported)
 {
-  if (is_supported_auth(CEPH_AUTH_CEPHX) && supported.count(CEPH_AUTH_CEPHX))
+  if (is_supported_auth(CEPH_AUTH_CEPHX, cct) && supported.count(CEPH_AUTH_CEPHX))
     return new CephxServiceHandler(cct, ks);
-  if (is_supported_auth(CEPH_AUTH_NONE) && supported.count(CEPH_AUTH_NONE))
+  if (is_supported_auth(CEPH_AUTH_NONE, cct) && supported.count(CEPH_AUTH_NONE))
     return new AuthNoneServiceHandler(cct);
   return NULL;
 }
index 0a43a4a2ce8a4b9c3305e97a99c95d39dfe1c2e2..bb9580e625d32d3581858cdd0ca4162a55bd4457 100644 (file)
@@ -23,9 +23,9 @@ static bool _supported_initialized = false;
 static Mutex _supported_lock("auth_supported_init");
 static map<int, bool> auth_supported;
 
-static void _init_supported(void)
+static void _init_supported(CephContext *cct)
 {
-  string str = g_conf->auth_supported;
+  string str = cct->_conf->auth_supported;
   list<string> sup_list;
   get_str_list(str, sup_list);
   for (list<string>::iterator iter = sup_list.begin(); iter != sup_list.end(); ++iter) {
@@ -34,19 +34,19 @@ static void _init_supported(void)
     } else if (iter->compare("none") == 0) {
       auth_supported[CEPH_AUTH_NONE] = true;
     } else {
-      derr << "WARNING: unknown auth protocol defined: " << *iter << dendl;
+      lderr(cct) << "WARNING: unknown auth protocol defined: " << *iter << dendl;
     }
   }
   _supported_initialized = true;
 }
 
 
-bool is_supported_auth(int auth_type)
+bool is_supported_auth(int auth_type, CephContext *cct)
 {
   {
     Mutex::Locker lock(_supported_lock);
     if (!_supported_initialized) {
-      _init_supported();
+      _init_supported(cct);
     }
   }
   return auth_supported[auth_type];
index da12a8567bfa11e5734db5175a68f55e236d91ab..bccccd851744992210f7d7f2dab709bae3c74f48 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <map>
 
-extern bool is_supported_auth(int auth_type);
+class CephContext;
+
+extern bool is_supported_auth(int auth_type, CephContext *cct);
 
 #endif
index 71caef42743a4f473349a4401a2280369551001d..747e58d9681cf79427f623096dbc5b94472c4454 100644 (file)
@@ -39,7 +39,7 @@ from_ceph_context(CephContext *cct)
   bool found_key = false;
   auto_ptr < KeyRing > keyring(new KeyRing());
 
-  if (!is_supported_auth(CEPH_AUTH_CEPHX)) {
+  if (!is_supported_auth(CEPH_AUTH_CEPHX, cct)) {
     ldout(cct, 2) << "KeyRing::from_ceph_context: CephX auth is not supported." << dendl;
     return keyring.release();
   }
index 7ceed9a30fc21bdaffec19fd32d6ecc7ab57a383..86bcd6d23f49b627ee2cdb1852ef60133fdeaf1b 100644 (file)
@@ -2013,7 +2013,8 @@ bool MDS::ms_verify_authorizer(Connection *con, int peer_type,
 {
   Mutex::Locker l(mds_lock);
 
-  AuthAuthorizeHandler *authorize_handler = get_authorize_handler(protocol);
+  AuthAuthorizeHandler *authorize_handler =
+      get_authorize_handler(protocol, &g_ceph_context);
   if (!authorize_handler) {
     dout(0) << "No AuthAuthorizeHandler found for protocol " << protocol << dendl;
     is_valid = false;
index fa3644358ee866818cba7cbb946f7f4fa546c28d..55e00699fdda5451d62508fcce11b48ab6d5658f 100644 (file)
@@ -1131,7 +1131,7 @@ bool Monitor::ms_get_authorizer(int service_id, AuthAuthorizer **authorizer, boo
   if (service_id != CEPH_ENTITY_TYPE_MON)
     return false;
 
-  if (!is_supported_auth(CEPH_AUTH_CEPHX))
+  if (!is_supported_auth(CEPH_AUTH_CEPHX, &g_ceph_context))
     return false;
 
   CephXServiceTicketInfo auth_ticket_info;
@@ -1188,7 +1188,7 @@ bool Monitor::ms_verify_authorizer(Connection *con, int peer_type,
           << " protocol " << protocol << dendl;
 
   if (peer_type == CEPH_ENTITY_TYPE_MON &&
-      is_supported_auth(CEPH_AUTH_CEPHX)) {
+      is_supported_auth(CEPH_AUTH_CEPHX, &g_ceph_context)) {
     // monitor, and cephx is enabled
     isvalid = false;
     if (protocol == CEPH_AUTH_CEPHX) {
index d7e4c7a3da36adb88f4b131e80ba8ecf55803007..416ed018fb2280a0be2f05b86b56087fe3eb8433 100644 (file)
@@ -2600,7 +2600,8 @@ bool OSD::ms_verify_authorizer(Connection *con, int peer_type,
                               int protocol, bufferlist& authorizer_data, bufferlist& authorizer_reply,
                               bool& isvalid)
 {
-  AuthAuthorizeHandler *authorize_handler = get_authorize_handler(protocol);
+  AuthAuthorizeHandler *authorize_handler =
+      get_authorize_handler(protocol, &g_ceph_context);
   if (!authorize_handler) {
     dout(0) << "No AuthAuthorizeHandler found for protocol " << protocol << dendl;
     isvalid = false;