]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: clean up AuthServiceHandler::start_session()
authorSage Weil <sage@redhat.com>
Mon, 14 Jan 2019 22:13:53 +0000 (16:13 -0600)
committerSage Weil <sage@redhat.com>
Thu, 7 Feb 2019 12:53:03 +0000 (06:53 -0600)
- return error code, not type (which never changes)
- take const ref for input args
- pointers for output args

Signed-off-by: Sage Weil <sage@redhat.com>
src/auth/AuthServiceHandler.h
src/auth/cephx/CephxServiceHandler.cc
src/auth/cephx/CephxServiceHandler.h
src/auth/krb/KrbServiceHandler.cpp
src/auth/krb/KrbServiceHandler.hpp
src/auth/none/AuthNoneServiceHandler.h
src/auth/unknown/AuthUnknownServiceHandler.h
src/mon/AuthMonitor.cc

index 2230c75c71ffc86965b4a829da3fad1532019588..1aa1bcc7ea3d1141dffe1247be5d53b719369a52 100644 (file)
@@ -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; }
index 4bd197ae5a746687ceed47055ceae3812cca6810..ae0b2bb5e1145bfd8211615ad0b5ce97af753799 100644 (file)
 #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<uint64_t>::max();
   server_challenge = ceph::util::generate_random_number<uint64_t>(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)
index e961e38814ea771e2b03c88ee8cd743a6b69c1bf..4d8804d559d3c5beda3994e745e705737983d8ae 100644 (file)
@@ -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);
 };
index 52ebd0a56815c54b5381ca2c2621e43a645458a3..f896c3fd7778f843e467314410ae7633a8a8fec2 100644 (file)
@@ -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<int>(GSSAuthenticationRequest::GSS_MUTUAL);
 
     using ceph::encode;
-    encode(krb_response, buff_list);
+    encode(krb_response, *buff_list);
     return (CEPH_AUTH_GSS);
   }
 }
index 692a7ebd06ac7db8bf8daac36629b7f333ee750b..649c5f38887a349c0516e10e28ed043d536e50c4 100644 (file)
@@ -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; 
index 449143894924e732746d3de324efb0d6b3b4dc1f..0f90a840252309836a0eba07d0e9271cd9dbbe04 100644 (file)
@@ -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;
index f89174d9aa13ffcebcb62ec82b84e154dbd1f470..a7856093e7c6fc1b41e40881b5010618983455a9 100644 (file)
@@ -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
index 871b246ddcbfb1e5e1877cf471899179ab1a40f2..6f2e676edaac29e278ebb0343a4d41269af39d2b 100644 (file)
@@ -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