From 578b43e8d5cc22a47bcb3efd0168544f03cb801c Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 5 Nov 2021 16:02:17 -0400 Subject: [PATCH] rgw/auth: perm_mask uses std::optional MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit resolves a compiler warning about an uninitialized variable in boost::optional: In file included from ../src/rgw/rgw_common.h:1508, from ../src/rgw/rgw_main.cc:18: ../src/rgw/rgw_auth.h: In member function ‘virtual rgw::auth::swift::DefaultStrategy::aplptr_t rgw::auth::swift::DefaultStrategy::_ZThn56_NK3rgw4auth5swift15D efaultStrategy15create_apl_turlEPN4ceph6common11CephContextEPK9req_stateRK11RGWUserInfo(ceph::common::CephContext*, const req_state*, const RGWUserInfo&) cons t’: ../src/rgw/rgw_auth.h:652:38: warning: ‘.boost::optional::.boost::optional_detail::tc_optional_base::m_storage’ may be used uninitialized [-Wmaybe-uninitialized] 652 | this->perm_mask = perm_mask.get(); | ~~~~~~~~~~~~~^~ In file included from ../src/rgw/rgw_rest_swift.h:14, from ../src/rgw/rgw_main.cc:24: ../src/rgw/rgw_swift_auth.h:27:73: note: ‘’ declared here 27 | : LocalApplier(cct, user_info, LocalApplier::NO_SUBUSER, boost::none) { | Signed-off-by: Casey Bodley --- src/rgw/rgw_auth.cc | 2 +- src/rgw/rgw_auth.h | 13 +++++-------- src/rgw/rgw_auth_s3.h | 4 ++-- src/rgw/rgw_rest_s3.cc | 3 ++- src/rgw/rgw_swift_auth.cc | 4 ++-- src/rgw/rgw_swift_auth.h | 8 ++++---- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/rgw/rgw_auth.cc b/src/rgw/rgw_auth.cc index 78d9ee5272b8f..dfb338818d733 100644 --- a/src/rgw/rgw_auth.cc +++ b/src/rgw/rgw_auth.cc @@ -911,7 +911,7 @@ rgw::auth::AnonymousEngine::authenticate(const DoutPrefixProvider* dpp, const re auto apl = \ apl_factory->create_apl_local(cct, s, user_info, rgw::auth::LocalApplier::NO_SUBUSER, - boost::none); + std::nullopt); return result_t::grant(std::move(apl)); } } diff --git a/src/rgw/rgw_auth.h b/src/rgw/rgw_auth.h index c31e734a17bb3..db343649cc3d0 100644 --- a/src/rgw/rgw_auth.h +++ b/src/rgw/rgw_auth.h @@ -6,6 +6,7 @@ #define CEPH_RGW_AUTH_H #include +#include #include #include #include @@ -645,14 +646,10 @@ public: LocalApplier(CephContext* const cct, const RGWUserInfo& user_info, std::string subuser, - const boost::optional& perm_mask) + const std::optional& perm_mask) : user_info(user_info), - subuser(std::move(subuser)) { - if (perm_mask) { - this->perm_mask = perm_mask.get(); - } else { - this->perm_mask = RGW_PERM_INVALID; - } + subuser(std::move(subuser)), + perm_mask(perm_mask.value_or(RGW_PERM_INVALID)) { } @@ -679,7 +676,7 @@ public: const req_state* s, const RGWUserInfo& user_info, const std::string& subuser, - const boost::optional& perm_mask) const = 0; + const std::optional& perm_mask) const = 0; }; }; diff --git a/src/rgw/rgw_auth_s3.h b/src/rgw/rgw_auth_s3.h index ff28a27fb6d33..edec31a3c6b13 100644 --- a/src/rgw/rgw_auth_s3.h +++ b/src/rgw/rgw_auth_s3.h @@ -56,7 +56,7 @@ class STSAuthStrategy : public rgw::auth::Strategy, const req_state* const s, const RGWUserInfo& user_info, const std::string& subuser, - const boost::optional& perm_mask) const override { + const std::optional& perm_mask) const override { auto apl = rgw::auth::add_sysreq(cct, store, s, rgw::auth::LocalApplier(cct, user_info, subuser, perm_mask)); return aplptr_t(new decltype(apl)(std::move(apl))); @@ -174,7 +174,7 @@ class AWSAuthStrategy : public rgw::auth::Strategy, const req_state* const s, const RGWUserInfo& user_info, const std::string& subuser, - const boost::optional& perm_mask) const override { + const std::optional& perm_mask) const override { auto apl = rgw::auth::add_sysreq(cct, store, s, rgw::auth::LocalApplier(cct, user_info, subuser, perm_mask)); /* TODO(rzarzynski): replace with static_ptr. */ diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 73f3ed5729a3f..a02ca472ebc48 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -5926,7 +5926,8 @@ rgw::auth::s3::LocalEngine::authenticate( return result_t::deny(-ERR_SIGNATURE_NO_MATCH); } - auto apl = apl_factory->create_apl_local(cct, s, user->get_info(), k.subuser, boost::none); + auto apl = apl_factory->create_apl_local(cct, s, user->get_info(), + k.subuser, std::nullopt); return result_t::grant(std::move(apl), completer_factory(k.key)); } diff --git a/src/rgw/rgw_swift_auth.cc b/src/rgw/rgw_swift_auth.cc index 3791e7d9214b7..c34ee221edff3 100644 --- a/src/rgw/rgw_swift_auth.cc +++ b/src/rgw/rgw_swift_auth.cc @@ -461,7 +461,7 @@ ExternalTokenEngine::authenticate(const DoutPrefixProvider* dpp, auto apl = apl_factory->create_apl_local(cct, s, user->get_info(), extract_swift_subuser(swift_user), - boost::none); + std::nullopt); return result_t::grant(std::move(apl)); } @@ -615,7 +615,7 @@ SignedTokenEngine::authenticate(const DoutPrefixProvider* dpp, auto apl = apl_factory->create_apl_local(cct, s, user->get_info(), extract_swift_subuser(swift_user), - boost::none); + std::nullopt); return result_t::grant(std::move(apl)); } diff --git a/src/rgw/rgw_swift_auth.h b/src/rgw/rgw_swift_auth.h index 13dc1b63a569d..166a2ad793e8c 100644 --- a/src/rgw/rgw_swift_auth.h +++ b/src/rgw/rgw_swift_auth.h @@ -24,7 +24,7 @@ class TempURLApplier : public rgw::auth::LocalApplier { public: TempURLApplier(CephContext* const cct, const RGWUserInfo& user_info) - : LocalApplier(cct, user_info, LocalApplier::NO_SUBUSER, boost::none) { + : LocalApplier(cct, user_info, LocalApplier::NO_SUBUSER, std::nullopt) { }; void modify_request_state(const DoutPrefixProvider* dpp, req_state * s) const override; /* in/out */ @@ -153,8 +153,8 @@ class SwiftAnonymousApplier : public rgw::auth::LocalApplier { public: SwiftAnonymousApplier(CephContext* const cct, const RGWUserInfo& user_info) - : LocalApplier(cct, user_info, LocalApplier::NO_SUBUSER, boost::none) { - }; + : LocalApplier(cct, user_info, LocalApplier::NO_SUBUSER, std::nullopt) { + } bool is_admin_of(const rgw_user& uid) const {return false;} bool is_owner_of(const rgw_user& uid) const {return uid.id.compare(RGW_USER_ANON_ID) == 0;} }; @@ -225,7 +225,7 @@ class DefaultStrategy : public rgw::auth::Strategy, const req_state* const s, const RGWUserInfo& user_info, const std::string& subuser, - const boost::optional& perm_mask) const override { + const std::optional& perm_mask) const override { auto apl = \ rgw::auth::add_3rdparty(store, rgw_user(s->account_name), rgw::auth::add_sysreq(cct, store, s, -- 2.39.5