@@ -6424,7 +6424,9 @@ int Monitor::handle_auth_request(
64246424 &auth_meta->connection_secret ,
64256425 &auth_meta->authorizer_challenge );
64266426 if (isvalid) {
6427- ms_handle_fast_authentication (con);
6427+ if (!ms_handle_fast_authentication (con)) {
6428+ return -EACCES;
6429+ }
64286430 return 1 ;
64296431 }
64306432 if (!more && !was_challenge && auth_meta->authorizer_challenge ) {
@@ -6545,7 +6547,9 @@ int Monitor::handle_auth_request(
65456547 }
65466548 if (r > 0 &&
65476549 !s->authenticated ) {
6548- ms_handle_fast_authentication (con);
6550+ if (!ms_handle_fast_authentication (con)) {
6551+ return -EACCES;
6552+ }
65496553 }
65506554
65516555 dout (30 ) << " r " << r << " reply:\n " ;
@@ -6583,12 +6587,12 @@ void Monitor::ms_handle_accept(Connection *con)
65836587 }
65846588}
65856589
6586- int Monitor::ms_handle_fast_authentication (Connection *con)
6590+ bool Monitor::ms_handle_fast_authentication (Connection *con)
65876591{
65886592 if (con->get_peer_type () == CEPH_ENTITY_TYPE_MON) {
65896593 // mon <-> mon connections need no Session, and setting one up
65906594 // creates an awkward ref cycle between Session and Connection.
6591- return 1 ;
6595+ return true ;
65926596 }
65936597
65946598 auto priv = con->get_priv ();
@@ -6598,7 +6602,7 @@ int Monitor::ms_handle_fast_authentication(Connection *con)
65986602 if (state == STATE_SHUTDOWN) {
65996603 dout (10 ) << __func__ << " ignoring new con " << con << " (shutdown)" << dendl;
66006604 con->mark_down ();
6601- return -EACCES ;
6605+ return false ;
66026606 }
66036607 s = session_map.new_session (
66046608 entity_name_t (con->get_peer_type (), -1 ), // we don't know yet
@@ -6616,11 +6620,10 @@ int Monitor::ms_handle_fast_authentication(Connection *con)
66166620 << " " << *s << dendl;
66176621
66186622 AuthCapsInfo &caps_info = con->get_peer_caps_info ();
6619- int ret = 0 ;
66206623 if (caps_info.allow_all ) {
66216624 s->caps .set_allow_all ();
66226625 s->authenticated = true ;
6623- ret = 1 ;
6626+ return true ;
66246627 } else if (caps_info.caps .length ()) {
66256628 bufferlist::const_iterator p = caps_info.caps .cbegin ();
66266629 string str;
@@ -6629,22 +6632,19 @@ int Monitor::ms_handle_fast_authentication(Connection *con)
66296632 } catch (const ceph::buffer::error &err) {
66306633 derr << __func__ << " corrupt cap data for " << con->get_peer_entity_name ()
66316634 << " in auth db" << dendl;
6632- str.clear ();
6633- ret = -EACCES;
6635+ return false ;
66346636 }
6635- if (ret >= 0 ) {
6636- if (s->caps .parse (str, NULL )) {
6637- s->authenticated = true ;
6638- ret = 1 ;
6639- } else {
6640- derr << __func__ << " unparseable caps '" << str << " ' for "
6641- << con->get_peer_entity_name () << dendl;
6642- ret = -EACCES;
6643- }
6637+ if (s->caps .parse (str, NULL )) {
6638+ s->authenticated = true ;
6639+ return true ;
6640+ } else {
6641+ derr << __func__ << " unparseable caps '" << str << " ' for "
6642+ << con->get_peer_entity_name () << dendl;
6643+ return false ;
66446644 }
6645+ } else {
6646+ return false ;
66456647 }
6646-
6647- return ret;
66486648}
66496649
66506650void Monitor::set_mon_crush_location (const string& loc)
0 commit comments