]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: fix object policy read op 1050/head
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 6 Jan 2014 20:53:58 +0000 (12:53 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Mon, 6 Jan 2014 20:53:58 +0000 (12: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>
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h

index 5481b67ba4527e9bbc8471e7d236dd9b4bd045ed..50d89b5794ed9f8b4e2bfef9e322668cd6d7b958 100644 (file)
@@ -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);
 }
 
 
index 47795403dc6c0c36498d933608cb6e20c322efc2..ce94d440c55bbbedc32e7c7cfdfacb05430ad7a5 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; };