From 01038faf697693862e766c301e0822d024a06bb9 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Wed, 15 Jun 2011 13:34:08 -0700 Subject: [PATCH] auth: remove remaining globals Signed-off-by: Colin McCabe --- src/auth/AuthAuthorizeHandler.h | 6 +++--- src/auth/Crypto.cc | 4 ++-- src/auth/Crypto.h | 2 +- src/auth/cephx/CephxAuthorizeHandler.cc | 8 ++++---- src/auth/cephx/CephxAuthorizeHandler.h | 4 +++- src/auth/cephx/CephxClientHandler.h | 2 +- src/auth/cephx/CephxKeyServer.cc | 2 +- src/auth/none/AuthNoneAuthorizeHandler.cc | 4 ++-- src/auth/none/AuthNoneAuthorizeHandler.h | 4 +++- src/mds/MDS.cc | 2 +- src/osd/OSD.cc | 2 +- 11 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/auth/AuthAuthorizeHandler.h b/src/auth/AuthAuthorizeHandler.h index 40a8765847114..6a0fe02b7f865 100644 --- a/src/auth/AuthAuthorizeHandler.h +++ b/src/auth/AuthAuthorizeHandler.h @@ -15,16 +15,16 @@ #ifndef CEPH_AUTHAUTHORIZEHANDLER_H #define CEPH_AUTHAUTHORIZEHANDLER_H -#include "include/types.h" -#include "common/config.h" #include "Auth.h" +#include "include/types.h" +class CephContext; class KeyRing; class RotatingKeyRing; struct AuthAuthorizeHandler { virtual ~AuthAuthorizeHandler() {} - virtual bool verify_authorizer(KeyStore *keys, + virtual bool verify_authorizer(CephContext *cct, KeyStore *keys, bufferlist& authorizer_data, bufferlist& authorizer_reply, EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info, uint64_t *auid = NULL) = 0; diff --git a/src/auth/Crypto.cc b/src/auth/Crypto.cc index 9f2a46ec5b2cb..7251d09eb36f2 100644 --- a/src/auth/Crypto.cc +++ b/src/auth/Crypto.cc @@ -350,10 +350,10 @@ CryptoHandler *get_crypto_handler(int type) // --------------------------------------------------- -int CryptoKey::set_secret(int type, bufferptr& s) +int CryptoKey::set_secret(CephContext *cct, int type, bufferptr& s) { this->type = type; - created = ceph_clock_now(&g_ceph_context); + created = ceph_clock_now(cct); CryptoHandler *h = get_crypto_handler(type); if (!h) diff --git a/src/auth/Crypto.h b/src/auth/Crypto.h index 18fce89d320cb..9ebf24cbfe883 100644 --- a/src/auth/Crypto.h +++ b/src/auth/Crypto.h @@ -53,7 +53,7 @@ public: utime_t get_created() const { return created; } void print(std::ostream& out) const; - int set_secret(int type, bufferptr& s); + int set_secret(CephContext *cct, int type, bufferptr& s); bufferptr& get_secret() { return secret; } const bufferptr& get_secret() const { return secret; } diff --git a/src/auth/cephx/CephxAuthorizeHandler.cc b/src/auth/cephx/CephxAuthorizeHandler.cc index a86af9ac19f08..f33399484be72 100644 --- a/src/auth/cephx/CephxAuthorizeHandler.cc +++ b/src/auth/cephx/CephxAuthorizeHandler.cc @@ -5,21 +5,21 @@ #include "CephxAuthorizeHandler.h" -bool CephxAuthorizeHandler::verify_authorizer(KeyStore *keys, +bool CephxAuthorizeHandler::verify_authorizer(CephContext *cct, KeyStore *keys, bufferlist& authorizer_data, bufferlist& authorizer_reply, EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info, uint64_t *auid) { bufferlist::iterator iter = authorizer_data.begin(); if (!authorizer_data.length()) { - dout(1) << "verify authorizer, authorizer_data.length()=0" << dendl; + ldout(cct, 1) << "verify authorizer, authorizer_data.length()=0" << dendl; return false; } CephXServiceTicketInfo auth_ticket_info; - bool isvalid = cephx_verify_authorizer(&g_ceph_context, keys, iter, auth_ticket_info, authorizer_reply); - dout(1) << "CephxAuthorizeHandler::verify_authorizer isvalid=" << isvalid << dendl; + bool isvalid = cephx_verify_authorizer(cct, keys, iter, auth_ticket_info, authorizer_reply); + ldout(cct, 1) << "CephxAuthorizeHandler::verify_authorizer isvalid=" << isvalid << dendl; if (isvalid) { caps_info = auth_ticket_info.ticket.caps; diff --git a/src/auth/cephx/CephxAuthorizeHandler.h b/src/auth/cephx/CephxAuthorizeHandler.h index 44df8ba1931c5..8344b08678225 100644 --- a/src/auth/cephx/CephxAuthorizeHandler.h +++ b/src/auth/cephx/CephxAuthorizeHandler.h @@ -17,8 +17,10 @@ #include "../AuthAuthorizeHandler.h" +class CephContext; + struct CephxAuthorizeHandler : public AuthAuthorizeHandler { - bool verify_authorizer(KeyStore *keys, + bool verify_authorizer(CephContext *cct, KeyStore *keys, bufferlist& authorizer_data, bufferlist& authorizer_reply, EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info, uint64_t *auid = NULL); diff --git a/src/auth/cephx/CephxClientHandler.h b/src/auth/cephx/CephxClientHandler.h index ba46a18338211..cb878150e7f64 100644 --- a/src/auth/cephx/CephxClientHandler.h +++ b/src/auth/cephx/CephxClientHandler.h @@ -38,7 +38,7 @@ public: starting(false), server_challenge(0), authorizer(0), - tickets(&g_ceph_context), + tickets(cct_), rotating_secrets(rsecrets), keyring(rsecrets->get_keyring()) { diff --git a/src/auth/cephx/CephxKeyServer.cc b/src/auth/cephx/CephxKeyServer.cc index 87fc87bd6f9b0..e2e02a66ffc7e 100644 --- a/src/auth/cephx/CephxKeyServer.cc +++ b/src/auth/cephx/CephxKeyServer.cc @@ -261,7 +261,7 @@ bool KeyServer::generate_secret(CryptoKey& secret) if (crypto->create(bp) < 0) return false; - secret.set_secret(CEPH_CRYPTO_AES, bp); + secret.set_secret(cct, CEPH_CRYPTO_AES, bp); return true; } diff --git a/src/auth/none/AuthNoneAuthorizeHandler.cc b/src/auth/none/AuthNoneAuthorizeHandler.cc index b965049a1115c..37bacffa7effb 100644 --- a/src/auth/none/AuthNoneAuthorizeHandler.cc +++ b/src/auth/none/AuthNoneAuthorizeHandler.cc @@ -15,7 +15,7 @@ #include "AuthNoneAuthorizeHandler.h" #include "common/debug.h" -bool AuthNoneAuthorizeHandler::verify_authorizer(KeyStore *keys, +bool AuthNoneAuthorizeHandler::verify_authorizer(CephContext *cct, KeyStore *keys, bufferlist& authorizer_data, bufferlist& authorizer_reply, EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info, uint64_t *auid) @@ -28,7 +28,7 @@ uint64_t *auid) ::decode(entity_name, iter); ::decode(global_id, iter); } catch (const buffer::error &err) { - dout(0) << "AuthNoneAuthorizeHandle::verify_authorizer() failed to decode" << dendl; + ldout(cct, 0) << "AuthNoneAuthorizeHandle::verify_authorizer() failed to decode" << dendl; return false; } diff --git a/src/auth/none/AuthNoneAuthorizeHandler.h b/src/auth/none/AuthNoneAuthorizeHandler.h index a5eaf3b762d59..da758709921d5 100644 --- a/src/auth/none/AuthNoneAuthorizeHandler.h +++ b/src/auth/none/AuthNoneAuthorizeHandler.h @@ -17,8 +17,10 @@ #include "../AuthAuthorizeHandler.h" +class CephContext; + struct AuthNoneAuthorizeHandler : public AuthAuthorizeHandler { - bool verify_authorizer(KeyStore *keys, + bool verify_authorizer(CephContext *cct, KeyStore *keys, bufferlist& authorizer_data, bufferlist& authorizer_reply, EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info, uint64_t *auid=NULL); diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index ce0f589230452..8d0e9bb7c55a5 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -2024,7 +2024,7 @@ bool MDS::ms_verify_authorizer(Connection *con, int peer_type, EntityName name; uint64_t global_id; - is_valid = authorize_handler->verify_authorizer(monc->rotating_secrets, + is_valid = authorize_handler->verify_authorizer(cct, monc->rotating_secrets, authorizer_data, authorizer_reply, name, global_id, caps_info); if (is_valid) { diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 2c3dbfde4a471..05d40f474985d 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2612,7 +2612,7 @@ bool OSD::ms_verify_authorizer(Connection *con, int peer_type, uint64_t global_id; uint64_t auid = CEPH_AUTH_UID_DEFAULT; - isvalid = authorize_handler->verify_authorizer(monc->rotating_secrets, + isvalid = authorize_handler->verify_authorizer(&g_ceph_context, monc->rotating_secrets, authorizer_data, authorizer_reply, name, global_id, caps_info, &auid); dout(10) << "OSD::ms_verify_authorizer name=" << name << " auid=" << auid << dendl; -- 2.39.5