]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: include features in cephx SessionHandler
authorSage Weil <sage@inktank.com>
Mon, 29 Oct 2012 22:47:45 +0000 (15:47 -0700)
committerSage Weil <sage@inktank.com>
Mon, 29 Oct 2012 22:47:45 +0000 (15:47 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/auth/AuthSessionHandler.cc
src/auth/AuthSessionHandler.h
src/auth/cephx/CephxSessionHandler.cc
src/auth/cephx/CephxSessionHandler.h
src/msg/Pipe.cc

index cc60b1826073183e9604692b62591b47d8441ad5..e928cf74fe28b2884f9f45285e08608cf76b27da 100644 (file)
@@ -22,7 +22,7 @@
 #define dout_subsys ceph_subsys_auth
 
 
-AuthSessionHandler *get_auth_session_handler(CephContext *cct, int protocol, CryptoKey key)
+AuthSessionHandler *get_auth_session_handler(CephContext *cct, int protocol, CryptoKey key, uint64_t features)
 {
 
   // Should add code to only print the SHA1 hash of the key, unless in secure debugging mode
@@ -31,7 +31,7 @@ AuthSessionHandler *get_auth_session_handler(CephContext *cct, int protocol, Cry
  
   switch (protocol) {
   case CEPH_AUTH_CEPHX:
-    return new CephxSessionHandler(cct, key);
+    return new CephxSessionHandler(cct, key, features);
   case CEPH_AUTH_NONE:
     return new AuthNoneSessionHandler(cct, key);
   case CEPH_AUTH_UNKNOWN:
index 108d6e4dfedbee83533a9c006b15ed853ee32bd9..684b83a2868173554f6909075fc9f6136c7b6a53 100644 (file)
@@ -65,6 +65,7 @@ public:
 
 };
 
-extern AuthSessionHandler *get_auth_session_handler(CephContext *cct, int protocol, CryptoKey key);
+extern AuthSessionHandler *get_auth_session_handler(CephContext *cct, int protocol, CryptoKey key,
+                                                   uint64_t features);
 
 #endif
index 45ea433abb901e384b6d088a2400d1a88bbed8c2..31b219e153f172381e09daf8b1c80d4674b60dee 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "common/config.h"
 #include "include/assert.h"
+#include "include/ceph_features.h"
 
 #define dout_subsys ceph_subsys_auth
 
index 8bca05d8f031d1baa4edafcf70843a97e49ca69c..52a112e29a29e0c51af76df8c4f045249c413c92 100644 (file)
 class CephContext;
 
 class CephxSessionHandler  : public AuthSessionHandler {
+  uint64_t features;
+
 public:
-  CephxSessionHandler(CephContext *cct_, CryptoKey session_key)
-    : AuthSessionHandler(cct_, CEPH_AUTH_CEPHX, session_key) {}
+  CephxSessionHandler(CephContext *cct_, CryptoKey session_key, uint64_t features)
+    : AuthSessionHandler(cct_, CEPH_AUTH_CEPHX, session_key),
+      features(features) {}
   ~CephxSessionHandler() {}
   
   bool no_security() {
index 608042f7991df9c7ee871decf0190f7f262f8109..8192e04d2a627d132886af16595d118d389d9d72 100644 (file)
@@ -315,7 +315,8 @@ int Pipe::accept()
     // Check the authorizer.  If not good, bail out.
 
     if (!msgr->verify_authorizer(connection_state, peer_type, connect.authorizer_protocol, authorizer, 
-        authorizer_reply, authorizer_valid, session_key) || !authorizer_valid ) {
+                                authorizer_reply, authorizer_valid, session_key) ||
+       !authorizer_valid) {
       ldout(msgr->cct,0) << "accept: got bad authorizer" << dendl;
       reply.tag = CEPH_MSGR_TAG_BADAUTHORIZER;
       session_security = NULL;
@@ -325,7 +326,6 @@ int Pipe::accept()
     // We've verified the authorizer for this pipe, so set up the session security structure.  PLR
 
     ldout(msgr->cct,10) << "accept:  setting up session_security." << dendl;
-    session_security = get_auth_session_handler(msgr->cct, connect.authorizer_protocol, session_key);
 
     msgr->lock.Lock();
     if (msgr->dispatch_queue.stop)
@@ -540,6 +540,9 @@ int Pipe::accept()
   connection_state->set_features((int)reply.features & (int)connect.features);
   ldout(msgr->cct,10) << "accept features " << connection_state->get_features() << dendl;
 
+  session_security = get_auth_session_handler(msgr->cct, connect.authorizer_protocol, session_key,
+                                             connection_state->get_features());
+
   // notify
   msgr->dispatch_queue.queue_accept(connection_state);
 
@@ -915,7 +918,8 @@ int Pipe::connect()
       // connection.  PLR
 
       if (authorizer != NULL) {
-        session_security = get_auth_session_handler(msgr->cct, authorizer->protocol, authorizer->session_key);
+        session_security = get_auth_session_handler(msgr->cct, authorizer->protocol, authorizer->session_key,
+                                                   connection_state->get_features());
       }  else {
         // We have no authorizer, so we shouldn't be applying security to messages in this pipe.  PLR
        session_security = NULL;
@@ -1603,10 +1607,10 @@ int Pipe::read_message(Message **pm)
   //  Check the signature if one should be present.  A zero return indicates success. PLR
   //
 
-  if (session_security == NULL ) {
+  if (session_security == NULL) {
     ldout(msgr->cct, 10) << "No session security set" << dendl;
   } else {
-    if (session_security->check_message_signature(message)){
+    if (session_security->check_message_signature(message)) {
       ldout(msgr->cct, 0) << "Signature check failed" << dendl;
       ret = -EINVAL;
       goto out_dethrottle;