From af0af94a88f7404ce8c6c8fa4d30fea5b758ebde Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 30 May 2019 17:20:32 -0700 Subject: [PATCH] rgw: acl: api adjustments Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_acl_s3.cc | 22 +++++++++++----------- src/rgw/rgw_acl_s3.h | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/rgw/rgw_acl_s3.cc b/src/rgw/rgw_acl_s3.cc index 5f026ff3547..f196b5f7ead 100644 --- a/src/rgw/rgw_acl_s3.cc +++ b/src/rgw/rgw_acl_s3.cc @@ -290,7 +290,7 @@ static const char *get_acl_header(const RGWEnv *env, return env->get(header, NULL); } -static int parse_grantee_str(RGWRados *store, string& grantee_str, +static int parse_grantee_str(RGWUserCtl *user_ctl, string& grantee_str, const struct s3_acl_header *perm, ACLGrant& grant) { string id_type, id_val_quoted; @@ -306,14 +306,14 @@ static int parse_grantee_str(RGWRados *store, string& grantee_str, string id_val = rgw_trim_quotes(id_val_quoted); if (strcasecmp(id_type.c_str(), "emailAddress") == 0) { - ret = rgw_get_user_info_by_email(store, id_val, info); + ret = user_ctl->get_info_by_email(id_val, &info); if (ret < 0) return ret; grant.set_canon(info.user_id, info.display_name, rgw_perm); } else if (strcasecmp(id_type.c_str(), "id") == 0) { rgw_user user(id_val); - ret = rgw_get_user_info_by_uid(store, user, info); + ret = user_ctl->get_info_by_uid(user, &info); if (ret < 0) return ret; @@ -331,7 +331,7 @@ static int parse_grantee_str(RGWRados *store, string& grantee_str, return 0; } -static int parse_acl_header(RGWRados *store, const RGWEnv *env, +static int parse_acl_header(RGWUserCtl *user_ctl, const RGWEnv *env, const struct s3_acl_header *perm, std::list& _grants) { std::list grantees; @@ -346,7 +346,7 @@ static int parse_acl_header(RGWRados *store, const RGWEnv *env, for (list::iterator it = grantees.begin(); it != grantees.end(); ++it) { ACLGrant grant; - int ret = parse_grantee_str(store, *it, perm, grant); + int ret = parse_grantee_str(user_ctl, *it, perm, grant); if (ret < 0) return ret; @@ -451,13 +451,13 @@ static const s3_acl_header acl_header_perms[] = { {0, NULL} }; -int RGWAccessControlPolicy_S3::create_from_headers(RGWRados *store, const RGWEnv *env, ACLOwner& _owner) +int RGWAccessControlPolicy_S3::create_from_headers(RGWUserCtl *user_ctl, const RGWEnv *env, ACLOwner& _owner) { std::list grants; int r = 0; for (const struct s3_acl_header *p = acl_header_perms; p->rgw_perm; p++) { - r = parse_acl_header(store, env, p, grants); + r = parse_acl_header(user_ctl, env, p, grants); if (r < 0) { return r; } @@ -474,7 +474,7 @@ int RGWAccessControlPolicy_S3::create_from_headers(RGWRados *store, const RGWEnv /* can only be called on object that was parsed */ -int RGWAccessControlPolicy_S3::rebuild(RGWRados *store, ACLOwner *owner, RGWAccessControlPolicy& dest) +int RGWAccessControlPolicy_S3::rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RGWAccessControlPolicy& dest) { if (!owner) return -EINVAL; @@ -487,7 +487,7 @@ int RGWAccessControlPolicy_S3::rebuild(RGWRados *store, ACLOwner *owner, RGWAcce } RGWUserInfo owner_info; - if (rgw_get_user_info_by_uid(store, owner->get_id(), owner_info) < 0) { + if (user_ctl->get_info_by_uid(owner->get_id(), &owner_info) < 0) { ldout(cct, 10) << "owner info does not exist" << dendl; return -EINVAL; } @@ -520,7 +520,7 @@ int RGWAccessControlPolicy_S3::rebuild(RGWRados *store, ACLOwner *owner, RGWAcce } email = u.id; ldout(cct, 10) << "grant user email=" << email << dendl; - if (rgw_get_user_info_by_email(store, email, grant_user) < 0) { + if (user_ctl->get_info_by_email(email, &grant_user) < 0) { ldout(cct, 10) << "grant user email not found or other error" << dendl; return -ERR_UNRESOLVABLE_EMAIL; } @@ -535,7 +535,7 @@ int RGWAccessControlPolicy_S3::rebuild(RGWRados *store, ACLOwner *owner, RGWAcce } } - if (grant_user.user_id.empty() && rgw_get_user_info_by_uid(store, uid, grant_user) < 0) { + if (grant_user.user_id.empty() && user_ctl->get_info_by_uid(uid, &grant_user) < 0) { ldout(cct, 10) << "grant user does not exist:" << uid << dendl; return -EINVAL; } else { diff --git a/src/rgw/rgw_acl_s3.h b/src/rgw/rgw_acl_s3.h index 41877667a3e..34ee8906b31 100644 --- a/src/rgw/rgw_acl_s3.h +++ b/src/rgw/rgw_acl_s3.h @@ -13,7 +13,7 @@ #include "rgw_xml.h" #include "rgw_acl.h" -class RGWRados; +class RGWUserCtl; class ACLPermission_S3 : public ACLPermission, public XMLObj { @@ -83,7 +83,7 @@ public: bool xml_end(const char *el) override; void to_xml(ostream& out); - int rebuild(RGWRados *store, ACLOwner *owner, RGWAccessControlPolicy& dest); + int rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RGWAccessControlPolicy& dest); bool compare_group_name(string& id, ACLGroupTypeEnum group) override; virtual int create_canned(ACLOwner& _owner, ACLOwner& bucket_owner, const string& canned_acl) { @@ -92,7 +92,7 @@ public: owner = _owner; return ret; } - int create_from_headers(RGWRados *store, const RGWEnv *env, ACLOwner& _owner); + int create_from_headers(RGWUserCtl *user_ctl, const RGWEnv *env, ACLOwner& _owner); }; /** -- 2.39.5