From: Casey Bodley Date: Wed, 18 Jul 2018 20:24:24 +0000 (-0400) Subject: rgw: RGWBucket::link supports tenant X-Git-Tag: v14.0.1~833^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F23119%2Fhead;p=ceph.git rgw: RGWBucket::link supports tenant use tenant-aware helper functions to generate metadata keys/oids this allows 'radosgw-admin bucket link' to succeed for a tenanted user, provided that the bucket belongs to the same tenant Fixes: http://tracker.ceph.com/issues/22666 Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 34036572848..6cce9f7c154 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -819,21 +819,20 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) rgw_bucket bucket = op_state.get_bucket(); const rgw_pool& root_pool = store->get_zone_params().domain_root; - rgw_raw_obj obj(root_pool, bucket.name); + std::string bucket_entry; + rgw_make_bucket_entry_name(tenant, bucket_name, bucket_entry); + rgw_raw_obj obj(root_pool, bucket_entry); RGWObjVersionTracker objv_tracker; map attrs; RGWBucketInfo bucket_info; - string key = bucket.name + ":" + bucket_id; RGWObjectCtx obj_ctx(store); - int r = store->get_bucket_instance_info(obj_ctx, key, bucket_info, NULL, &attrs); + int r = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, &attrs); if (r < 0) { return r; } - rgw_user user_id = op_state.get_user_id(); - map::iterator aiter = attrs.find(RGW_ATTR_ACL); if (aiter != attrs.end()) { bufferlist aclbl = aiter->second; @@ -881,8 +880,8 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) aclbl.clear(); policy_instance.encode(aclbl); - string oid_bucket_instance = RGW_BUCKET_INSTANCE_MD_PREFIX + key; - rgw_raw_obj obj_bucket_instance(root_pool, oid_bucket_instance); + rgw_raw_obj obj_bucket_instance; + store->get_bucket_instance_obj(bucket, obj_bucket_instance); r = store->system_obj_set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker); if (r < 0) { return r;