]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: fix object policy read op
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 6 Jan 2014 20:53:58 +0000 (12:53 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Mon, 17 Feb 2014 05:53:28 +0000 (21:53 -0800)
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>
(cherry picked from commit b1976dd00f5b29c01791272f63a18250319f2edb)

src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h

index fee04dbba950fdd8aea8ccd7656e3be13417cf52..3e57b934fef7768fa06c62472224abb2251730e2 100644 (file)
@@ -727,11 +727,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);
@@ -744,19 +770,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);
 }
 
 
index d84a8a13fe2ea4020793a94165b4da23f539918b..f3fb4f22480f69e56f3fd00e5312e548cca24484 100644 (file)
@@ -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; };