From 56bce3ba261195984effceb5c46fa56b9c8ac65a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 29 Oct 2012 15:47:45 -0700 Subject: [PATCH] auth: include features in cephx SessionHandler Signed-off-by: Sage Weil --- src/auth/AuthSessionHandler.cc | 4 ++-- src/auth/AuthSessionHandler.h | 3 ++- src/auth/cephx/CephxSessionHandler.cc | 1 + src/auth/cephx/CephxSessionHandler.h | 7 +++++-- src/msg/Pipe.cc | 14 +++++++++----- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/auth/AuthSessionHandler.cc b/src/auth/AuthSessionHandler.cc index cc60b18260731..e928cf74fe28b 100644 --- a/src/auth/AuthSessionHandler.cc +++ b/src/auth/AuthSessionHandler.cc @@ -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: diff --git a/src/auth/AuthSessionHandler.h b/src/auth/AuthSessionHandler.h index 108d6e4dfedbe..684b83a286817 100644 --- a/src/auth/AuthSessionHandler.h +++ b/src/auth/AuthSessionHandler.h @@ -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 diff --git a/src/auth/cephx/CephxSessionHandler.cc b/src/auth/cephx/CephxSessionHandler.cc index 45ea433abb901..31b219e153f17 100644 --- a/src/auth/cephx/CephxSessionHandler.cc +++ b/src/auth/cephx/CephxSessionHandler.cc @@ -20,6 +20,7 @@ #include "common/config.h" #include "include/assert.h" +#include "include/ceph_features.h" #define dout_subsys ceph_subsys_auth diff --git a/src/auth/cephx/CephxSessionHandler.h b/src/auth/cephx/CephxSessionHandler.h index 8bca05d8f031d..52a112e29a29e 100644 --- a/src/auth/cephx/CephxSessionHandler.h +++ b/src/auth/cephx/CephxSessionHandler.h @@ -19,9 +19,12 @@ 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() { diff --git a/src/msg/Pipe.cc b/src/msg/Pipe.cc index 608042f7991df..8192e04d2a627 100644 --- a/src/msg/Pipe.cc +++ b/src/msg/Pipe.cc @@ -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; -- 2.39.5