From: Yehuda Sadeh Date: Fri, 26 Apr 2019 18:30:43 +0000 (-0700) Subject: rgw: trivial cleanups X-Git-Tag: v15.1.0~1898^2^2~90 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=65cac2f596a4c564b586dc17f662c21679123c61;p=ceph-ci.git rgw: trivial cleanups in rgw_user.cc Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index ba65666642d..171a5bd9440 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -470,24 +470,14 @@ static void dump_user_info(Formatter *f, RGWUserInfo &info, RGWAccessKeyPool::RGWAccessKeyPool(RGWUser* usr) { - user = usr; - swift_keys = NULL; - access_keys = NULL; - - if (!user) { - keys_allowed = false; - store = NULL; + if (!usr) { return; } - keys_allowed = true; + user = usr; store = user->get_store(); -} - -RGWAccessKeyPool::~RGWAccessKeyPool() -{ - + user_ctl = user->get_user_ctl(); } int RGWAccessKeyPool::init(RGWUserAdminOpState& op_state) @@ -996,18 +986,15 @@ int RGWAccessKeyPool::remove_subuser_keys(RGWUserAdminOpState& op_state, RGWSubUserPool::RGWSubUserPool(RGWUser *usr) { - subusers_allowed = (usr != NULL); - if (usr) - store = usr->get_store(); - else - store = NULL; - user = usr; - subuser_map = NULL; -} + if (!usr) { + return; + } -RGWSubUserPool::~RGWSubUserPool() -{ + user = usr; + subusers_allowed = true; + store = user->get_store(); + user_ctl = user->get_user_ctl(); } int RGWSubUserPool::init(RGWUserAdminOpState& op_state) @@ -1299,14 +1286,11 @@ int RGWSubUserPool::modify(RGWUserAdminOpState& op_state, std::string *err_msg, RGWUserCapPool::RGWUserCapPool(RGWUser *usr) { + if (!usr) { + return; + } user = usr; - caps = NULL; - caps_allowed = (user != NULL); -} - -RGWUserCapPool::~RGWUserCapPool() -{ - + caps_allowed = true; } int RGWUserCapPool::init(RGWUserAdminOpState& op_state) @@ -1414,7 +1398,7 @@ int RGWUserCapPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg, return 0; } -RGWUser::RGWUser() : store(NULL), info_stored(false), caps(this), keys(this), subusers(this) +RGWUser::RGWUser() : caps(this), keys(this), subusers(this) { init_default(); } @@ -1433,10 +1417,6 @@ int RGWUser::init(RGWRados *storage, RGWUserAdminOpState& op_state) return 0; } -RGWUser::~RGWUser() -{ -} - void RGWUser::init_default() { // use anonymous user info as a placeholder @@ -1453,6 +1433,7 @@ int RGWUser::init_storage(RGWRados *storage) } store = storage; + user_ctl = *store->ctl.user; clear_populated(); diff --git a/src/rgw/rgw_user.h b/src/rgw/rgw_user.h index 16889fbdfbb..b69a74c07f1 100644 --- a/src/rgw/rgw_user.h +++ b/src/rgw/rgw_user.h @@ -543,17 +543,18 @@ class RGWUser; class RGWAccessKeyPool { - RGWUser *user; + RGWUser *user{nullptr}; std::map key_type_map; rgw_user user_id; - RGWRados *store; + RGWRados *store{nullptr}; + RGWUserCtl *user_ctl{nullptr}; - map *swift_keys; - map *access_keys; + map *swift_keys{nullptr}; + map *access_keys{nullptr}; // we don't want to allow keys for the anonymous user or a null user - bool keys_allowed; + bool keys_allowed{false}; private: int create_key(RGWUserAdminOpState& op_state, std::string *err_msg = NULL); @@ -573,7 +574,6 @@ private: int remove(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); public: explicit RGWAccessKeyPool(RGWUser* usr); - ~RGWAccessKeyPool(); int init(RGWUserAdminOpState& op_state); @@ -587,13 +587,14 @@ public: class RGWSubUserPool { - RGWUser *user; + RGWUser *user{nullptr}; rgw_user user_id; - RGWRados *store; - bool subusers_allowed; + RGWRados *store{nullptr}; + RGWUserCtl *user_ctl{nullptr}; + bool subusers_allowed{false}; - map *subuser_map; + map *subuser_map{nullptr}; private: int check_op(RGWUserAdminOpState& op_state, std::string *err_msg = NULL); @@ -608,7 +609,6 @@ private: int modify(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); public: explicit RGWSubUserPool(RGWUser *user); - ~RGWSubUserPool(); bool exists(std::string subuser); int init(RGWUserAdminOpState& op_state); @@ -623,9 +623,9 @@ public: class RGWUserCapPool { - RGWUserCaps *caps; - bool caps_allowed; - RGWUser *user; + RGWUserCaps *caps{false}; + bool caps_allowed{false}; + RGWUser *user{false}; private: int add(RGWUserAdminOpState& op_state, std::string *err_msg, bool defer_save); @@ -633,7 +633,6 @@ private: public: explicit RGWUserCapPool(RGWUser *user); - ~RGWUserCapPool(); int init(RGWUserAdminOpState& op_state); @@ -649,10 +648,11 @@ class RGWUser private: RGWUserInfo old_info; - RGWRados *store; + RGWRados *store{nullptr}; + RGWUserCtl *user_ctl{nullptr}; rgw_user user_id; - bool info_stored; + bool info_stored{false}; void set_populated() { info_stored = true; } void clear_populated() { info_stored = false; } @@ -672,7 +672,6 @@ private: public: RGWUser(); - ~RGWUser(); int init(RGWRados *storage, RGWUserAdminOpState& op_state); @@ -681,6 +680,7 @@ public: int init_members(RGWUserAdminOpState& op_state); RGWRados *get_store() { return store; } + RGWUserCtl *get_user_ctl() { return user_ctl; } /* API Contracted Members */ RGWUserCapPool caps;