From: Aran85 Date: Mon, 28 Sep 2015 00:23:22 +0000 (+0800) Subject: rgw:bucket link now set the bucket.instance acl X-Git-Tag: v0.94.7~2^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F8583%2Fhead;p=ceph.git rgw:bucket link now set the bucket.instance acl Fixes: #11076 Signed-off-by: Zengran Zhang (cherry picked from commit 4d59b1d36f8924290c3ecb5b7608747191470188) Conflicts: src/rgw/rgw_bucket.cc 1. Do not use the rgw_user structure and remove the tenant parameter that describes as below 2. user_id is not used so just remove the line 3. instead of system_obj_set_attr you can use the method set_attr Backport Change: We do not use the rgw_user structure and remove the `tenant` parameter because this feature is not introduced on hammer version. The rgw multi-tenant feature is introduced on pr#6784 (https://github.com/ceph/ceph/pull/6784) This feature is supported from v10.0.2 and later version. --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 5d2af38ea6fb..1926b0a66ed4 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -138,9 +138,6 @@ int rgw_link_bucket(RGWRados *store, string user_id, rgw_bucket& bucket, time_t ret = store->get_bucket_entrypoint_info(obj_ctx, bucket_name, ep, &ot, NULL, &attrs); if (ret < 0 && ret != -ENOENT) { ldout(store->ctx(), 0) << "ERROR: store->get_bucket_entrypoint_info() returned " << ret << dendl; - } else if (ret >= 0 && ep.linked && ep.owner != user_id) { - ldout(store->ctx(), 0) << "can't link bucket, already linked to a different user: " << ep.owner << dendl; - return -EINVAL; } } @@ -542,7 +539,7 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) return -EIO; } - r = rgw_unlink_bucket(store, owner.get_id(), bucket.name); + r = rgw_unlink_bucket(store, owner.get_id(), bucket.name, false); if (r < 0) { set_err_msg(err_msg, "could not unlink policy from user " + owner.get_id()); return r; @@ -569,6 +566,17 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) if (r < 0) return r; + RGWAccessControlPolicy policy_instance; + policy_instance.create_default(user_info.user_id, display_name); + aclbl.clear(); + policy_instance.encode(aclbl); + + string oid_bucket_instance = RGW_BUCKET_INSTANCE_MD_PREFIX + key; + rgw_bucket bucket_instance; + bucket_instance.name = oid_bucket_instance; + rgw_obj obj_bucket_instance(bucket_instance, no_oid); + r = store->set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker); + r = rgw_link_bucket(store, user_info.user_id, bucket, 0); if (r < 0) return r;