]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: return error if accessing object in non-existent bucket
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 19 Feb 2014 00:43:48 +0000 (16:43 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 19 Feb 2014 00:43:48 +0000 (16:43 -0800)
Fixes: #7064
Instead of trying to access the object, which is impossible as we don't
even have a proper bucket info. Up until now we ended up creating an
empty pool and eventually returning ENOENT, this fix catches the issue
earlier in the process.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_op.cc

index 018ae84595fe57e31eeb489120c4b94213b772d3..98b6fadc9c10f0a0c6544671080a92ce492df1c6 100644 (file)
@@ -342,7 +342,7 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu
     }
   }
 
-  if (s->bucket_name_str.size()) {
+  if (!s->bucket_name_str.empty()) {
     s->bucket_exists = true;
     if (s->bucket_instance_id.empty()) {
       ret = store->get_bucket_info(s->obj_ctx, s->bucket_name_str, s->bucket_info, NULL, &s->bucket_attrs);
@@ -382,7 +382,10 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu
 
   /* we're passed only_bucket = true when we specifically need the bucket's
      acls, that happens on write operations */
-  if (!only_bucket) {
+  if (!only_bucket && !s->object_str.empty()) {
+    if (!s->bucket_exists) {
+      return -ERR_NO_SUCH_BUCKET;
+    }
     s->object_acl = new RGWAccessControlPolicy(s->cct);
 
     obj_str = s->object_str;