]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: distribute global instance id to client
authorYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 9 Nov 2009 18:16:04 +0000 (10:16 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 9 Nov 2009 18:16:04 +0000 (10:16 -0800)
src/mon/AuthMonitor.cc
src/mon/MonClient.cc
src/mon/MonClient.h
src/mon/Session.h

index 7e4b51dadeca7813afaaf30dd55cc572a3e9369c..2ff7d4ccfecf0f482f3064da1f1242cc4546e00d 100644 (file)
@@ -370,8 +370,8 @@ bool AuthMonitor::preprocess_auth(MAuth *m)
     EntityName entity_name;
 
     if (!s->auth_handler) {
-      uint64_t global_id = assign_global_id(m);
-      if (!global_id)
+      s->global_id = assign_global_id(m);
+      if (!s->global_id)
         goto done;
 
       set<__u32> supported;
@@ -389,6 +389,7 @@ bool AuthMonitor::preprocess_auth(MAuth *m)
        if (!s->auth_handler)
          ret = -EPERM;
        else {
+          ::encode(s->global_id, response_bl);
          proto = s->auth_handler->start_session(entity_name, indata, response_bl);
           if (proto == CEPH_AUTH_NONE) {
             s->caps.set_allow_all(true);
index bf18760e93b557c6f4d1e93f240007c4ec52f9d8..387ff280173715adc295aadf7e451492e2bf2a92 100644 (file)
@@ -319,6 +319,7 @@ void MonClient::handle_mount_ack(MClientMountAck* m)
 
 void MonClient::handle_auth(MAuthReply *m)
 {
+  bufferlist::iterator p = m->result_bl.begin();
   if (state == MC_STATE_NEGOTIATING) {
     if (!auth || (int)m->protocol != auth->get_protocol()) {
       delete auth;
@@ -332,11 +333,17 @@ void MonClient::handle_auth(MAuthReply *m)
     } else {
       auth->reset();
     }
+    try {
+      ::decode(global_id, p);
+      dout(0) << "decoded global_id=" << global_id << dendl;
+    } catch (buffer::error *err) {
+      delete m;
+      return;
+    }
     state = MC_STATE_AUTHENTICATING;
   }
   assert(auth);
 
-  bufferlist::iterator p = m->result_bl.begin();
   int ret = auth->handle_response(m->result, p);
   delete m;
 
index 1ba4019c02730ae2be542ffa7bf3f56f2009e9ad..e2e8df6a7f617b7c6f080e867f36d20decb837bd 100644 (file)
@@ -89,6 +89,8 @@ private:
 
   uint32_t want_keys;
 
+  uint64_t global_id;
+
   // mount
 private:
   client_t clientid;
@@ -175,7 +177,7 @@ public:
                timer(monc_lock),
                hunting(false),
                want_monmap(false),
-               want_keys(0),
+               want_keys(0), global_id(0),
                mounting(0), mount_err(0),
                auth(NULL) { }
   ~MonClient() {
index bddb4eef2e07326a1559781fc4ecb800ce09aad7..e7356114f5c1ccf328cacdeb33b90a376ab2cfdb 100644 (file)
@@ -41,13 +41,14 @@ struct Session : public RefCountedObject {
   xlist<Session*>::item item;
   set<__u64> routed_request_tids;
   MonCaps caps;
+  uint64_t global_id;
 
   map<nstring, Subscription*> sub_map;
 
   AuthServiceHandler *auth_handler;
 
   Session(entity_inst_t i) : inst(i), closed(false), item(this),
-                            auth_handler(NULL) {}
+                            global_id(0), auth_handler(NULL) {}
   ~Session() {
     generic_dout(0) << "~Session " << this << dendl;
     // we should have been removed before we get destructed; see SessionMap::remove_session()