]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: CEPH_PRINCIPLE_ -> CEPH_ENTITY_TYPE_*
authorSage Weil <sage@newdream.net>
Thu, 22 Oct 2009 21:17:10 +0000 (14:17 -0700)
committerSage Weil <sage@newdream.net>
Thu, 22 Oct 2009 21:17:10 +0000 (14:17 -0700)
13 files changed:
src/auth/Auth.h
src/auth/AuthClientHandler.cc
src/auth/AuthProtocol.h
src/auth/AuthServiceHandler.cc
src/auth/KeyServer.cc
src/include/ceph_strings.cc
src/include/msgr.h
src/librados.cc
src/mds/MDS.cc
src/mon/MonClient.cc
src/mon/MonClient.h
src/mon/Monitor.cc
src/osd/OSD.cc

index 68a1f89d8995891a0a56eef450850e9249cd2537..0314d52297fd0afd0d656c1bee25589815bb2270 100644 (file)
@@ -317,8 +317,8 @@ public:
 
 static inline bool auth_principal_needs_rotating_keys(EntityName& name)
 {
-  return ((name.entity_type == CEPHX_PRINCIPAL_OSD) ||
-          (name.entity_type == CEPHX_PRINCIPAL_MDS));
+  return ((name.entity_type == CEPH_ENTITY_TYPE_OSD) ||
+          (name.entity_type == CEPH_ENTITY_TYPE_MDS));
 }
 
 
index aca588c882c428db356e19ee4801a5d0a9560fc9..bbafe0109dac2f5483015066d7403485fc2f201f 100644 (file)
@@ -215,7 +215,7 @@ int AuthClientAuthenticateHandler::_handle_response(int ret, bufferlist::iterato
 int AuthClientAuthenticateHandler::generate_cephx_authenticate_request(bufferlist& bl)
 {
   CephXRequestHeader header;
-  AuthTicketHandler& ticket_handler = client->tickets.get_handler(CEPHX_PRINCIPAL_AUTH);
+  AuthTicketHandler& ticket_handler = client->tickets.get_handler(CEPH_ENTITY_TYPE_AUTH);
 
   if (!ticket_handler.has_key()) {
     dout(0) << "auth ticket: doesn't have key" << dendl;
@@ -285,7 +285,7 @@ int AuthClientAuthenticateHandler::handle_cephx_response(bufferlist::iterator& i
     cephx_response_state = 2;
     dout(0) << "CEPHX_GET_PRINCIPAL_SESSION_KEY" << dendl;
     {
-      AuthTicketHandler& ticket_handler = client->tickets.get_handler(CEPHX_PRINCIPAL_AUTH);
+      AuthTicketHandler& ticket_handler = client->tickets.get_handler(CEPH_ENTITY_TYPE_AUTH);
   
       if (!client->tickets.verify_service_ticket_reply(ticket_handler.session_key, indata)) {
         dout(0) << "could not verify service_ticket reply" << dendl;
index b6b1c8866947fde3da493f9b696864c4308e135e..1b2eb851a068b6c9897b827120f3318fee614f72 100644 (file)
@@ -83,14 +83,6 @@ using namespace std;
   the service, using that ticket.
 */
 
-#define CEPHX_PRINCIPAL_AUTH            0x0001
-#define CEPHX_PRINCIPAL_MON             0x0002
-#define CEPHX_PRINCIPAL_OSD             0x0004
-#define CEPHX_PRINCIPAL_MDS             0x0008
-#define CEPHX_PRINCIPAL_CLIENT          0x0010
-
-#define CEPHX_PRINCIPAL_TYPE_MASK       0x00FF
-
 /* authenticate requests */
 #define CEPHX_GET_AUTH_SESSION_KEY      0x0100
 #define CEPHX_GET_PRINCIPAL_SESSION_KEY 0x0200
@@ -102,46 +94,6 @@ using namespace std;
 
 class Monitor;
 
-static inline void get_entity_type_str(uint32_t entity_type,string& s) {
-   switch (entity_type) {
-     case CEPHX_PRINCIPAL_AUTH:
-       s = "auth";
-       break;
-     case CEPHX_PRINCIPAL_MON:
-       s = "mon";
-       break;
-     case CEPHX_PRINCIPAL_OSD:
-       s = "osd";
-       break;
-     case CEPHX_PRINCIPAL_MDS:
-       s = "mds";
-       break;
-     case CEPHX_PRINCIPAL_CLIENT:
-       s = "client";
-       break;
-     default:
-       s = "???";
-       break;
-   }
-}
-
-static inline uint32_t peer_id_to_entity_type(int peer_id)
-{
-  switch (peer_id) {
-  case CEPH_ENTITY_TYPE_MON:
-    return CEPHX_PRINCIPAL_MON;
-  case CEPH_ENTITY_TYPE_MDS:
-    return CEPHX_PRINCIPAL_MDS;
-  case CEPH_ENTITY_TYPE_OSD:
-    return CEPHX_PRINCIPAL_OSD;
-  case CEPH_ENTITY_TYPE_CLIENT:
-    return CEPHX_PRINCIPAL_CLIENT;
-  default:
-    return 0;
-  /* case CEPH_ENTITY_TYPE_ADMIN: */
-  }
-}
-
 struct EntityName {
   uint32_t entity_type;
   string name;
@@ -156,7 +108,7 @@ struct EntityName {
   }
 
   void to_str(string& str) const {
-    get_entity_type_str(entity_type, str);
+    str.append(ceph_entity_type_name(entity_type));
     str.append(".");
     str.append(name);
   }
@@ -184,15 +136,15 @@ struct EntityName {
 
   void set_type(const char *type) {
     if (strcmp(type, "auth") == 0) {
-      entity_type = CEPHX_PRINCIPAL_AUTH;
+      entity_type = CEPH_ENTITY_TYPE_AUTH;
     } else if (strcmp(type, "mon") == 0) {
-      entity_type = CEPHX_PRINCIPAL_MON;
+      entity_type = CEPH_ENTITY_TYPE_MON;
     } else if (strcmp(type, "osd") == 0) {
-      entity_type = CEPHX_PRINCIPAL_OSD;
+      entity_type = CEPH_ENTITY_TYPE_OSD;
     } else if (strcmp(type, "mds") == 0) {
-      entity_type = CEPHX_PRINCIPAL_MDS;
+      entity_type = CEPH_ENTITY_TYPE_MDS;
     } else {
-      entity_type = CEPHX_PRINCIPAL_CLIENT;
+      entity_type = CEPH_ENTITY_TYPE_CLIENT;
     }
   }
   void from_type_id(const char *type, const char *id) {
@@ -201,7 +153,7 @@ struct EntityName {
   }
 
   void get_type_str(string& s) {
-    get_entity_type_str(entity_type, s);
+    s = ceph_entity_type_name(entity_type);
   }
 };
 WRITE_CLASS_ENCODER(EntityName);
index 9f2e88531e21b3038bdce73eea2cd8136dc79539..cf4194ee0c8f95587fd23706b2b2ed1a3baf115a 100644 (file)
@@ -151,8 +151,8 @@ int CephAuthService_X::handle_cephx_protocol(bufferlist::iterator& indata, buffe
       mon->key_server.generate_secret(session_key);
 
       info.session_key = session_key;
-      info.service_id = CEPHX_PRINCIPAL_AUTH;
-      if (!mon->key_server.get_service_secret(CEPHX_PRINCIPAL_AUTH, info.service_secret, info.secret_id)) {
+      info.service_id = CEPH_ENTITY_TYPE_AUTH;
+      if (!mon->key_server.get_service_secret(CEPH_ENTITY_TYPE_AUTH, info.service_secret, info.secret_id)) {
         dout(0) << "could not get service secret for auth subsystem" << dendl;
         ret = -EIO;
         break;
@@ -186,7 +186,7 @@ int CephAuthService_X::handle_cephx_protocol(bufferlist::iterator& indata, buffe
 
       ret = 0;
       vector<SessionAuthInfo> info_vec;
-      for (uint32_t service_id = 1; service_id != (CEPHX_PRINCIPAL_TYPE_MASK + 1); service_id <<= 1) {
+      for (uint32_t service_id = 1; service_id <= ticket_req.keys; service_id <<= 1) {
         if (ticket_req.keys & service_id) {
           SessionAuthInfo info;
           int r = mon->key_server.build_session_auth_info(service_id, auth_ticket_info, info);
index f6f9d446579cc010e39e70fb9f01b9f7a604ce24..00dd4a4ab603bd30fa626892777f06aa3694fa9d 100644 (file)
@@ -135,10 +135,10 @@ void KeyServer::_generate_all_rotating_secrets(bool init)
     i = 1;
 
   for (; i <= KEY_ROTATE_NUM; i++) {
-    _rotate_secret(CEPHX_PRINCIPAL_AUTH, i);
-    _rotate_secret(CEPHX_PRINCIPAL_MON, i);
-    _rotate_secret(CEPHX_PRINCIPAL_OSD, i);
-    _rotate_secret(CEPHX_PRINCIPAL_MDS, i);
+    _rotate_secret(CEPH_ENTITY_TYPE_AUTH, i);
+    _rotate_secret(CEPH_ENTITY_TYPE_MON, i);
+    _rotate_secret(CEPH_ENTITY_TYPE_OSD, i);
+    _rotate_secret(CEPH_ENTITY_TYPE_MDS, i);
   }
 
   dout(0) << "generated: " << dendl;
@@ -328,8 +328,7 @@ int KeyServer::_build_session_auth_info(uint32_t service_id, AuthServiceTicketIn
 
   info.service_id = service_id;
 
-  string s;
-  get_entity_type_str(service_id, s);
+  string s = ceph_entity_type_name(service_id);
 
   if (!data.get_caps(info.ticket.name, s, info.ticket.caps)) {
     return -EINVAL;
index 90d19d9d8d8f272a3cbf43c9bb77b3ab8558f285..8e4be6a80c62a0466c3758a25e5367493f54bd77 100644 (file)
@@ -3,6 +3,19 @@
  */
 #include "types.h"
 
+const char *ceph_entity_type_name(int type)
+{
+       switch (type) {
+       case CEPH_ENTITY_TYPE_MDS: return "mds";
+       case CEPH_ENTITY_TYPE_OSD: return "osd";
+       case CEPH_ENTITY_TYPE_MON: return "mon";
+       case CEPH_ENTITY_TYPE_CLIENT: return "client";
+       case CEPH_ENTITY_TYPE_ADMIN: return "admin";
+       case CEPH_ENTITY_TYPE_AUTH: return "auth";
+       default: return "unknown";
+       }
+}
+
 const char *ceph_osd_op_name(int op)
 {
        switch (op) {
index 706d64282aeb8b8338870a794ef4335efcd01f27..66a7d2f226bef5ec07d3f7bcb2c953e81cf61ce0 100644 (file)
@@ -51,8 +51,9 @@ struct ceph_entity_name {
 #define CEPH_ENTITY_TYPE_OSD     4
 #define CEPH_ENTITY_TYPE_CLIENT  8
 #define CEPH_ENTITY_TYPE_ADMIN  16
+#define CEPH_ENTITY_TYPE_AUTH   32
 
-const char *ceph_entity_type_name(int type);
+extern const char *ceph_entity_type_name(int type);
 
 /*
  * entity_addr -- network address
index f0871f55294a0f3bd614709b7b3ea4f393c950a5..cafe5af67cd0b3f0979454a6dabc4705c788b536 100644 (file)
@@ -62,8 +62,7 @@ class RadosClient : public Dispatcher
 
   bool ms_get_authorizer(int dest_type, AuthAuthorizer& authorizer, bool force_new) {
     dout(0) << "RadosClient::ms_get_authorizer type=" << dest_type << dendl;
-    uint32_t want = peer_id_to_entity_type(dest_type);
-    if (monclient.auth.build_authorizer(want, authorizer) < 0)
+    if (monclient.auth.build_authorizer(dest_type, authorizer) < 0)
       return false;
     return true;
   }
@@ -309,7 +308,7 @@ bool RadosClient::init()
   rank.start(1);
   messenger->add_dispatcher_head(this);
 
-  monclient.set_want_keys(CEPHX_PRINCIPAL_MON | CEPHX_PRINCIPAL_OSD);
+  monclient.set_want_keys(CEPH_ENTITY_TYPE_MON | CEPH_ENTITY_TYPE_OSD);
   monclient.init();
 
   if (monclient.get_monmap() < 0)
index 94471fe644731d4a4ec0c6f26ba099edac4a494f..80f3dcd1082b0801c2188de9d74bfaaa568ce9fa 100644 (file)
@@ -378,7 +378,7 @@ int MDS::init()
   // get monmap
   monc->set_messenger(messenger);
 
-  monc->set_want_keys(CEPHX_PRINCIPAL_MON | CEPHX_PRINCIPAL_OSD | CEPHX_PRINCIPAL_MDS);
+  monc->set_want_keys(CEPH_ENTITY_TYPE_MON | CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS);
   monc->init();
 
   monc->get_monmap();
@@ -1158,18 +1158,17 @@ bool MDS::ms_dispatch(Message *m)
 bool MDS::ms_get_authorizer(int dest_type, AuthAuthorizer& authorizer, bool force_new)
 {
   dout(0) << "OSD::ms_get_authorizer type=" << dest_type << dendl;
+
   /* monitor authorization is being handled on different layer */
   if (dest_type == CEPH_ENTITY_TYPE_MON)
     return true;
 
-  uint32_t want = peer_id_to_entity_type(dest_type);
-
   if (force_new) {
     if (monc->wait_auth_rotating(10) < 0)
       return false;
   }
 
-  if (monc->auth.build_authorizer(want, authorizer) < 0)
+  if (monc->auth.build_authorizer(dest_type, authorizer) < 0)
     return false;
 
   return true;
index 69a5af8bcf4500fdeeeebbf1bbd9eb1c79485ffc..9132ffd53002c18975d8e03372a2ae59a336613d 100644 (file)
@@ -517,7 +517,7 @@ int MonClient::wait_authenticate(double timeout)
 
 int MonClient::authorize(double timeout)
 {
-  return auth.authorize(CEPHX_PRINCIPAL_MON, timeout);
+  return auth.authorize(CEPH_ENTITY_TYPE_MON, timeout);
 }
 
 int MonClient::_start_auth_rotating()
index a937b019a4eb6bdcd15bd715f83c7f6095d7f140..646730489962c1a00665f138ffc12cab7d55a9e6 100644 (file)
@@ -180,8 +180,8 @@ public:
                timer(monc_lock),
                hunting(false),
                mounting(0), mount_err(0),
-                auth_handler(&auth, CEPHX_PRINCIPAL_MON, 0),
-                authorize_handler(&auth, CEPHX_PRINCIPAL_MON) { }
+                auth_handler(&auth, CEPH_ENTITY_TYPE_MON, 0),
+                authorize_handler(&auth, CEPH_ENTITY_TYPE_MON) { }
   ~MonClient() {
     timer.cancel_all_events();
   }
@@ -232,7 +232,7 @@ public:
   }
 
   void set_want_keys(uint32_t want) {
-    auth_handler.set_want_keys(want | CEPHX_PRINCIPAL_MON);
+    auth_handler.set_want_keys(want | CEPH_ENTITY_TYPE_MON);
   }
 
   void add_want_keys(uint32_t want) {
index 794a62d4f9cf2d789aac1a546f62e3dc9c6108c8..e616b903f1f9578e15e23304a64ec29efcfb98fa 100644 (file)
@@ -926,18 +926,18 @@ bool Monitor::ms_get_authorizer(int dest_type, AuthAuthorizer& authorizer, bool
 
   SessionAuthInfo info;
   int ret;
-  uint32_t service_id = peer_id_to_entity_type(dest_type);
+  uint32_t service_id = dest_type;
 
   dout(0) << "ms_get_authorizer service_id=" << service_id << dendl;
 
-  if (service_id != CEPHX_PRINCIPAL_MON) {
+  if (service_id != CEPH_ENTITY_TYPE_MON) {
     ret = key_server.build_session_auth_info(service_id, auth_ticket_info, info);
     if (ret < 0) {
       return false;
     }
   } else {
     EntityName name;
-    name.entity_type = CEPHX_PRINCIPAL_MON;
+    name.entity_type = CEPH_ENTITY_TYPE_MON;
 
     CryptoKey secret;
     if (!key_server.get_secret(name, secret)) {
index 4b5268e20a6a68ae24018cbfb45cbe5545d4dca2..6aecc5454a57d5e543ad5b216867bc773f1292e6 100644 (file)
@@ -1505,14 +1505,13 @@ bool OSD::ms_dispatch(Message *m)
 bool OSD::ms_get_authorizer(int dest_type, AuthAuthorizer& authorizer, bool force_new)
 {
   dout(0) << "OSD::ms_get_authorizer type=" << dest_type << dendl;
-  uint32_t want = peer_id_to_entity_type(dest_type);
 
   if (force_new) {
     if (monc->wait_auth_rotating(10) < 0)
       return false;
   }
 
-  if (monc->auth.build_authorizer(want, authorizer) < 0)
+  if (monc->auth.build_authorizer(dest_type, authorizer) < 0)
     return false;
 
   return true;