From 27f8ff6282537ec9d8981311d91b4263724b8ea0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 11 Jan 2019 15:46:20 -0600 Subject: [PATCH] msg/async: move get_auth_allowed into ProtocolV2.cc We're the only user, and no Dispatchers override. Signed-off-by: Sage Weil --- src/msg/Dispatcher.h | 8 -------- src/msg/Messenger.cc | 31 ------------------------------- src/msg/Messenger.h | 6 ------ src/msg/async/ProtocolV2.cc | 32 ++++++++++++++++++++++++++++++-- src/msg/async/ProtocolV2.h | 3 +++ 5 files changed, 33 insertions(+), 47 deletions(-) diff --git a/src/msg/Dispatcher.h b/src/msg/Dispatcher.h index 1050308558931..fef5e3203ffa4 100644 --- a/src/msg/Dispatcher.h +++ b/src/msg/Dispatcher.h @@ -203,14 +203,6 @@ public: * @{ */ - /** - * Return the allowed authentication methods for peer - **/ - virtual int ms_get_auth_allowed_methods( - uint32_t peer_type, std::vector &allowed_methods) { - return 0; - } - /** * handle successful authentication (msgr2) * diff --git a/src/msg/Messenger.cc b/src/msg/Messenger.cc index 68825c5f8efa3..d697402b4d193 100644 --- a/src/msg/Messenger.cc +++ b/src/msg/Messenger.cc @@ -116,37 +116,6 @@ int Messenger::bindv(const entity_addrvec_t& addrs) return bind(addrs.legacy_addr()); } -void Messenger::ms_deliver_get_auth_allowed_methods( - int peer_type, std::vector &allowed_methods) -{ - for (const auto &dispatcher : dispatchers) { - if (dispatcher->ms_get_auth_allowed_methods(peer_type, allowed_methods)) - return; - } - if (allowed_methods.empty()) { - if (get_mytype() == CEPH_ENTITY_TYPE_MON && - peer_type != CEPH_ENTITY_TYPE_MON) { - allowed_methods.push_back(CEPH_AUTH_NONE); - return; - } - std::string method; - if (!cct->_conf->auth_supported.empty()) { - method = cct->_conf->auth_supported; - } else if (peer_type == CEPH_ENTITY_TYPE_OSD || - peer_type == CEPH_ENTITY_TYPE_MDS || - peer_type == CEPH_ENTITY_TYPE_MON || - peer_type == CEPH_ENTITY_TYPE_MGR) { - method = cct->_conf->auth_cluster_required; - } else { - method = cct->_conf->auth_client_required; - } - AuthMethodList auth_list(cct, method); - for (auto pt : auth_list.get_supported_set()) { - allowed_methods.push_back(pt); - } - } -} - bool Messenger::ms_deliver_verify_authorizer( Connection *con, int peer_type, diff --git a/src/msg/Messenger.h b/src/msg/Messenger.h index 500430d21afab..7134db851da9d 100644 --- a/src/msg/Messenger.h +++ b/src/msg/Messenger.h @@ -758,12 +758,6 @@ public: } } - /** - * Get allowed authentication methods for a specific peer type - **/ - void ms_deliver_get_auth_allowed_methods( - int peer_type, std::vector &allowed_methods); - /** * Get the AuthAuthorizer for a new outgoing Connection. * diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 8a96a27486992..6bdbff596422d 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -41,6 +41,34 @@ struct SHA256SignatureError : public std::exception { struct DecryptionError : public std::exception {}; +void ProtocolV2::get_auth_allowed_methods( + int peer_type, std::vector &allowed_methods) +{ + // FIXME: this is for legacy MAuth-based authentication + if (messenger->get_mytype() == CEPH_ENTITY_TYPE_MON && + peer_type != CEPH_ENTITY_TYPE_MON) { + allowed_methods.push_back(CEPH_AUTH_NONE); + return; + } + + std::string method; + if (!cct->_conf->auth_supported.empty()) { + method = cct->_conf->auth_supported; + } else if (peer_type == CEPH_ENTITY_TYPE_OSD || + peer_type == CEPH_ENTITY_TYPE_MDS || + peer_type == CEPH_ENTITY_TYPE_MON || + peer_type == CEPH_ENTITY_TYPE_MGR) { + method = cct->_conf->auth_cluster_required; + } else { + method = cct->_conf->auth_client_required; + } + AuthMethodList auth_list(cct, method); + for (auto pt : auth_list.get_supported_set()) { + allowed_methods.push_back(pt); + } +} + + void ProtocolV2::run_continuation(CtPtr continuation) { try { CONTINUATION_RUN(continuation) @@ -2515,8 +2543,8 @@ CtPtr ProtocolV2::handle_auth_request(char *payload, uint32_t length) { << dendl; std::vector allowed_methods; - messenger->ms_deliver_get_auth_allowed_methods(connection->peer_type, - allowed_methods); + get_auth_allowed_methods(connection->peer_type, + allowed_methods); bool found = std::find(allowed_methods.begin(), allowed_methods.end(), auth_request.method()) != allowed_methods.end(); diff --git a/src/msg/async/ProtocolV2.h b/src/msg/async/ProtocolV2.h index 5ac7f72c7006e..c849bd50654b4 100644 --- a/src/msg/async/ProtocolV2.h +++ b/src/msg/async/ProtocolV2.h @@ -112,6 +112,9 @@ private: bool keepalive; + void get_auth_allowed_methods( + int peer_type, std::vector &allowed_methods); + ostream &_conn_prefix(std::ostream *_dout); void run_continuation(Ct *continuation); void calc_signature(const char *in, uint32_t length, char *out); -- 2.39.5