From: Sage Weil Date: Mon, 14 Jan 2019 22:13:53 +0000 (-0600) Subject: auth: clean up AuthServiceHandler::start_session() X-Git-Tag: v14.1.0~183^2~63 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=57c72346c71dbcb82be80f34884029c8034d5a01;p=ceph.git auth: clean up AuthServiceHandler::start_session() - return error code, not type (which never changes) - take const ref for input args - pointers for output args Signed-off-by: Sage Weil --- diff --git a/src/auth/AuthServiceHandler.h b/src/auth/AuthServiceHandler.h index 2230c75c71ff..1aa1bcc7ea3d 100644 --- a/src/auth/AuthServiceHandler.h +++ b/src/auth/AuthServiceHandler.h @@ -35,7 +35,9 @@ public: virtual ~AuthServiceHandler() { } - virtual int start_session(EntityName& name, bufferlist::const_iterator& indata, bufferlist& result, AuthCapsInfo& caps) = 0; + virtual int start_session(const EntityName& name, + bufferlist *result, + AuthCapsInfo *caps) = 0; virtual int handle_request(bufferlist::const_iterator& indata, bufferlist& result, uint64_t& global_id, AuthCapsInfo& caps) = 0; EntityName& get_entity_name() { return entity_name; } diff --git a/src/auth/cephx/CephxServiceHandler.cc b/src/auth/cephx/CephxServiceHandler.cc index 4bd197ae5a74..ae0b2bb5e114 100644 --- a/src/auth/cephx/CephxServiceHandler.cc +++ b/src/auth/cephx/CephxServiceHandler.cc @@ -27,19 +27,22 @@ #undef dout_prefix #define dout_prefix *_dout << "cephx server " << entity_name << ": " -int CephxServiceHandler::start_session(EntityName& name, bufferlist::const_iterator& indata, bufferlist& result_bl, AuthCapsInfo& caps) +int CephxServiceHandler::start_session(const EntityName& name, + bufferlist *result_bl, + AuthCapsInfo *caps) { entity_name = name; uint64_t min = 1; // always non-zero uint64_t max = std::numeric_limits::max(); server_challenge = ceph::util::generate_random_number(min, max); - ldout(cct, 10) << "start_session server_challenge " << hex << server_challenge << dec << dendl; + ldout(cct, 10) << "start_session server_challenge " + << hex << server_challenge << dec << dendl; CephXServerChallenge ch; ch.server_challenge = server_challenge; - encode(ch, result_bl); - return CEPH_AUTH_CEPHX; + encode(ch, *result_bl); + return 0; } int CephxServiceHandler::handle_request(bufferlist::const_iterator& indata, bufferlist& result_bl, uint64_t& global_id, AuthCapsInfo& caps) diff --git a/src/auth/cephx/CephxServiceHandler.h b/src/auth/cephx/CephxServiceHandler.h index e961e38814ea..4d8804d559d3 100644 --- a/src/auth/cephx/CephxServiceHandler.h +++ b/src/auth/cephx/CephxServiceHandler.h @@ -29,7 +29,9 @@ public: : AuthServiceHandler(cct_), key_server(ks), server_challenge(0) {} ~CephxServiceHandler() override {} - int start_session(EntityName& name, bufferlist::const_iterator& indata, bufferlist& result_bl, AuthCapsInfo& caps) override; + int start_session(const EntityName& name, + bufferlist *result_bl, + AuthCapsInfo *caps) override; int handle_request(bufferlist::const_iterator& indata, bufferlist& result_bl, uint64_t& global_id, AuthCapsInfo& caps) override; void build_cephx_response_header(int request_type, int status, bufferlist& bl); }; diff --git a/src/auth/krb/KrbServiceHandler.cpp b/src/auth/krb/KrbServiceHandler.cpp index 52ebd0a56815..f896c3fd7778 100644 --- a/src/auth/krb/KrbServiceHandler.cpp +++ b/src/auth/krb/KrbServiceHandler.cpp @@ -148,10 +148,9 @@ int KrbServiceHandler::handle_request(bufferlist::const_iterator& indata, return result; } -int KrbServiceHandler::start_session(EntityName& name, - bufferlist::const_iterator& indata, - bufferlist& buff_list, - AuthCapsInfo& caps) +int KrbServiceHandler::start_session(const EntityName& name, + bufferlist *buff_list, + AuthCapsInfo *caps) { gss_buffer_desc gss_buffer_in = {0, nullptr}; gss_OID gss_object_id = GSS_C_NT_HOSTBASED_SERVICE; @@ -206,7 +205,7 @@ int KrbServiceHandler::start_session(EntityName& name, static_cast(GSSAuthenticationRequest::GSS_MUTUAL); using ceph::encode; - encode(krb_response, buff_list); + encode(krb_response, *buff_list); return (CEPH_AUTH_GSS); } } diff --git a/src/auth/krb/KrbServiceHandler.hpp b/src/auth/krb/KrbServiceHandler.hpp index 692a7ebd06ac..649c5f38887a 100644 --- a/src/auth/krb/KrbServiceHandler.hpp +++ b/src/auth/krb/KrbServiceHandler.hpp @@ -42,10 +42,9 @@ class KrbServiceHandler : public AuthServiceHandler { uint64_t& global_id, AuthCapsInfo& caps) override; - int start_session(EntityName& name, - bufferlist::const_iterator& indata, - bufferlist& buff_list, - AuthCapsInfo& caps) override; + int start_session(const EntityName& name, + bufferlist *buff_list, + AuthCapsInfo *caps) override; private: gss_buffer_desc m_gss_buffer_out; diff --git a/src/auth/none/AuthNoneServiceHandler.h b/src/auth/none/AuthNoneServiceHandler.h index 449143894924..0f90a8402523 100644 --- a/src/auth/none/AuthNoneServiceHandler.h +++ b/src/auth/none/AuthNoneServiceHandler.h @@ -26,10 +26,12 @@ public: : AuthServiceHandler(cct_) {} ~AuthNoneServiceHandler() override {} - int start_session(EntityName& name, bufferlist::const_iterator& indata, bufferlist& result_bl, AuthCapsInfo& caps) override { + int start_session(const EntityName& name, + bufferlist *result_bl, + AuthCapsInfo *caps) override { entity_name = name; - caps.allow_all = true; - return CEPH_AUTH_NONE; + caps->allow_all = true; + return 0; } int handle_request(bufferlist::const_iterator& indata, bufferlist& result_bl, uint64_t& global_id, AuthCapsInfo& caps) override { return 0; diff --git a/src/auth/unknown/AuthUnknownServiceHandler.h b/src/auth/unknown/AuthUnknownServiceHandler.h index f89174d9aa13..a7856093e7c6 100644 --- a/src/auth/unknown/AuthUnknownServiceHandler.h +++ b/src/auth/unknown/AuthUnknownServiceHandler.h @@ -26,8 +26,10 @@ public: : AuthServiceHandler(cct_) {} ~AuthUnknownServiceHandler() {} - int start_session(EntityName& name, bufferlist::iterator& indata, bufferlist& result_bl, AuthCapsInfo& caps) { - return CEPH_AUTH_UNKNOWN; + int start_session(const EntityName& name, + bufferlist *result_bl, + AuthCapsInfo *caps) { + return 0; } int handle_request(bufferlist::iterator& indata, bufferlist& result_bl, uint64_t& global_id, AuthCapsInfo& caps) { ceph_abort(); // shouldn't get called diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 871b246ddcbf..6f2e676edaac 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -599,6 +599,7 @@ bool AuthMonitor::prep_auth(MonOpRequestRef op, bool paxos_writable) goto reply; } start = true; + proto = type; } else if (!s->auth_handler) { dout(10) << "protocol specified but no s->auth_handler" << dendl; ret = -EINVAL; @@ -639,8 +640,8 @@ bool AuthMonitor::prep_auth(MonOpRequestRef op, bool paxos_writable) try { if (start) { // new session - proto = s->auth_handler->start_session(entity_name, indata, response_bl, - s->con->peer_caps_info); + s->auth_handler->start_session(entity_name, &response_bl, + &s->con->peer_caps_info); ret = 0; } else { // request