From acf51eb8a0536b7c7367980d4cae309bcc9aa8f7 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 30 Oct 2009 16:17:57 -0700 Subject: [PATCH] auth: fix 'auth none' authentication --- src/auth/AuthClientHandler.h | 2 +- src/auth/cephx/CephxClientHandler.cc | 3 ++- src/auth/cephx/CephxClientHandler.h | 2 +- src/auth/none/AuthNoneClientHandler.h | 2 +- src/mon/MonClient.cc | 7 +++++-- src/mon/Monitor.cc | 6 +++++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/auth/AuthClientHandler.h b/src/auth/AuthClientHandler.h index 35a13b17a0cb8..679c909f12cc3 100644 --- a/src/auth/AuthClientHandler.h +++ b/src/auth/AuthClientHandler.h @@ -63,7 +63,7 @@ public: virtual void reset() = 0; virtual int build_request(bufferlist& bl) = 0; virtual int handle_response(int ret, bufferlist::iterator& iter) = 0; - virtual void build_rotating_request(bufferlist& bl) = 0; + virtual bool build_rotating_request(bufferlist& bl) = 0; virtual void tick() = 0; diff --git a/src/auth/cephx/CephxClientHandler.cc b/src/auth/cephx/CephxClientHandler.cc index 6e2d86237b720..9b9c39dc1d71b 100644 --- a/src/auth/cephx/CephxClientHandler.cc +++ b/src/auth/cephx/CephxClientHandler.cc @@ -161,12 +161,13 @@ AuthAuthorizer *CephxClientHandler::build_authorizer(uint32_t service_id) } -void CephxClientHandler::build_rotating_request(bufferlist& bl) +bool CephxClientHandler::build_rotating_request(bufferlist& bl) { dout(10) << "build_rotating_request" << dendl; CephXRequestHeader header; header.request_type = CEPHX_GET_ROTATING_KEY; ::encode(header, bl); + return true; } void CephxClientHandler::validate_tickets() diff --git a/src/auth/cephx/CephxClientHandler.h b/src/auth/cephx/CephxClientHandler.h index 61f42a505a455..3e1ad47d95f7c 100644 --- a/src/auth/cephx/CephxClientHandler.h +++ b/src/auth/cephx/CephxClientHandler.h @@ -39,7 +39,7 @@ public: } int build_request(bufferlist& bl); int handle_response(int ret, bufferlist::iterator& iter); - void build_rotating_request(bufferlist& bl); + bool build_rotating_request(bufferlist& bl); int get_protocol() { return CEPH_AUTH_CEPHX; } diff --git a/src/auth/none/AuthNoneClientHandler.h b/src/auth/none/AuthNoneClientHandler.h index 398bade2dcc5a..a191a4cd8a997 100644 --- a/src/auth/none/AuthNoneClientHandler.h +++ b/src/auth/none/AuthNoneClientHandler.h @@ -26,7 +26,7 @@ public: int build_request(bufferlist& bl) { return 0; } int handle_response(int ret, bufferlist::iterator& iter) { return 0; } - void build_rotating_request(bufferlist& bl) { } + bool build_rotating_request(bufferlist& bl) { return false; } int get_protocol() { return CEPH_AUTH_NONE; } diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index bcbc0a9b0ea1f..f53a5f4fa84fa 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -574,8 +574,11 @@ int MonClient::_check_auth_rotating() if (auth) { MAuth *m = new MAuth; m->protocol = auth->get_protocol(); - auth->build_rotating_request(m->auth_payload); - _send_mon_message(m); + if (auth->build_rotating_request(m->auth_payload)) { + _send_mon_message(m); + } else { + delete m; + } } return 0; } diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 8733069e1e260..2981316e361fb 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -985,13 +985,17 @@ bool Monitor::ms_verify_authorizer(Connection *con, int peer_type, { dout(0) << "Monitor::verify_authorizer start" << dendl; + if (protocol == CEPH_AUTH_NONE) { + isvalid = true; + return true; + } + if (protocol != CEPH_AUTH_CEPHX) return false; bufferlist::iterator iter = authorizer_data.begin(); CephXServiceTicketInfo auth_ticket_info; - isvalid = true; if (!authorizer_data.length()) -- 2.39.5