diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2014-01-06 21:53:58 +0100 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2014-01-06 21:53:58 +0100 |
commit | b1976dd00f5b29c01791272f63a18250319f2edb (patch) | |
tree | 1f18e420fe57eaba29d08e2dccd97ebe82e26632 /src/rgw | |
parent | Merge pull request #1038 from ceph/wip-objectcacher-backoff (diff) | |
download | ceph-b1976dd00f5b29c01791272f63a18250319f2edb.tar.xz ceph-b1976dd00f5b29c01791272f63a18250319f2edb.zip |
radosgw-admin: fix object policy read op
Fixes: #7083
This was broken when we fixed #6940. We use the same function to both
read the bucket policy and the object policy. However, each needed to be
treated differently. Restore old behavior for objects.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Diffstat (limited to 'src/rgw')
-rw-r--r-- | src/rgw/rgw_bucket.cc | 40 | ||||
-rw-r--r-- | src/rgw/rgw_bucket.h | 1 |
2 files changed, 28 insertions, 13 deletions
diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 5481b67ba45..50d89b5794e 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -717,11 +717,37 @@ int RGWBucket::check_index(RGWBucketAdminOpState& op_state, return 0; } + +int RGWBucket::policy_bl_to_stream(bufferlist& bl, ostream& o) +{ + RGWAccessControlPolicy_S3 policy(g_ceph_context); + bufferlist::iterator iter = bl.begin(); + try { + policy.decode(iter); + } catch (buffer::error& err) { + dout(0) << "ERROR: caught buffer::error, could not decode policy" << dendl; + return -EIO; + } + policy.to_xml(o); + return 0; +} + int RGWBucket::get_policy(RGWBucketAdminOpState& op_state, ostream& o) { std::string object_name = op_state.get_object_name(); rgw_bucket bucket = op_state.get_bucket(); + if (!object_name.empty()) { + bufferlist bl; + rgw_obj obj(bucket, object_name); + int ret = store->get_attr(NULL, obj, RGW_ATTR_ACL, bl); + if (ret < 0) + return ret; + + return policy_bl_to_stream(bl, o); + } + + RGWBucketInfo bucket_info; map<string, bufferlist> attrs; int ret = store->get_bucket_info(NULL, bucket.name, bucket_info, NULL, &attrs); @@ -734,19 +760,7 @@ int RGWBucket::get_policy(RGWBucketAdminOpState& op_state, ostream& o) return -ENOENT; } - bufferlist& bl = aiter->second; - - RGWAccessControlPolicy_S3 policy(g_ceph_context); - bufferlist::iterator iter = bl.begin(); - try { - policy.decode(iter); - } catch (buffer::error& err) { - dout(0) << "ERROR: caught buffer::error, could not decode policy" << dendl; - return -EIO; - } - policy.to_xml(o); - - return 0; + return policy_bl_to_stream(aiter->second, o); } diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 47795403dc6..ce94d440c55 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -205,6 +205,7 @@ public: int unlink(RGWBucketAdminOpState& op_state, std::string *err_msg = NULL); int remove_object(RGWBucketAdminOpState& op_state, std::string *err_msg = NULL); + int policy_bl_to_stream(bufferlist& bl, ostream& o); int get_policy(RGWBucketAdminOpState& op_state, ostream& o); void clear_failure() { failure = false; }; |