@@ -6402,7 +6402,9 @@ int Monitor::handle_auth_request(
64026402 &auth_meta->connection_secret ,
64036403 &auth_meta->authorizer_challenge );
64046404 if (isvalid) {
6405- ms_handle_fast_authentication (con);
6405+ if (!ms_handle_fast_authentication (con)) {
6406+ return -EACCES;
6407+ }
64066408 return 1 ;
64076409 }
64086410 if (!more && !was_challenge && auth_meta->authorizer_challenge ) {
@@ -6523,7 +6525,9 @@ int Monitor::handle_auth_request(
65236525 }
65246526 if (r > 0 &&
65256527 !s->authenticated ) {
6526- ms_handle_fast_authentication (con);
6528+ if (!ms_handle_fast_authentication (con)) {
6529+ return -EACCES;
6530+ }
65276531 }
65286532
65296533 dout (30 ) << " r " << r << " reply:\n " ;
@@ -6561,12 +6565,12 @@ void Monitor::ms_handle_accept(Connection *con)
65616565 }
65626566}
65636567
6564- int Monitor::ms_handle_fast_authentication (Connection *con)
6568+ bool Monitor::ms_handle_fast_authentication (Connection *con)
65656569{
65666570 if (con->get_peer_type () == CEPH_ENTITY_TYPE_MON) {
65676571 // mon <-> mon connections need no Session, and setting one up
65686572 // creates an awkward ref cycle between Session and Connection.
6569- return 1 ;
6573+ return true ;
65706574 }
65716575
65726576 auto priv = con->get_priv ();
@@ -6576,7 +6580,7 @@ int Monitor::ms_handle_fast_authentication(Connection *con)
65766580 if (state == STATE_SHUTDOWN) {
65776581 dout (10 ) << __func__ << " ignoring new con " << con << " (shutdown)" << dendl;
65786582 con->mark_down ();
6579- return -EACCES ;
6583+ return false ;
65806584 }
65816585 s = session_map.new_session (
65826586 entity_name_t (con->get_peer_type (), -1 ), // we don't know yet
@@ -6594,11 +6598,10 @@ int Monitor::ms_handle_fast_authentication(Connection *con)
65946598 << " " << *s << dendl;
65956599
65966600 AuthCapsInfo &caps_info = con->get_peer_caps_info ();
6597- int ret = 0 ;
65986601 if (caps_info.allow_all ) {
65996602 s->caps .set_allow_all ();
66006603 s->authenticated = true ;
6601- ret = 1 ;
6604+ return true ;
66026605 } else if (caps_info.caps .length ()) {
66036606 bufferlist::const_iterator p = caps_info.caps .cbegin ();
66046607 string str;
@@ -6607,22 +6610,19 @@ int Monitor::ms_handle_fast_authentication(Connection *con)
66076610 } catch (const ceph::buffer::error &err) {
66086611 derr << __func__ << " corrupt cap data for " << con->get_peer_entity_name ()
66096612 << " in auth db" << dendl;
6610- str.clear ();
6611- ret = -EACCES;
6613+ return false ;
66126614 }
6613- if (ret >= 0 ) {
6614- if (s->caps .parse (str, NULL )) {
6615- s->authenticated = true ;
6616- ret = 1 ;
6617- } else {
6618- derr << __func__ << " unparseable caps '" << str << " ' for "
6619- << con->get_peer_entity_name () << dendl;
6620- ret = -EACCES;
6621- }
6615+ if (s->caps .parse (str, NULL )) {
6616+ s->authenticated = true ;
6617+ return true ;
6618+ } else {
6619+ derr << __func__ << " unparseable caps '" << str << " ' for "
6620+ << con->get_peer_entity_name () << dendl;
6621+ return false ;
66226622 }
6623+ } else {
6624+ return false ;
66236625 }
6624-
6625- return ret;
66266626}
66276627
66286628void Monitor::set_mon_crush_location (const string& loc)
0 commit comments