From: Yehuda Sadeh Date: Wed, 19 Feb 2014 00:43:48 +0000 (-0800) Subject: rgw: return error if accessing object in non-existent bucket X-Git-Tag: v0.67.10~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3663233a63df3a1fb1584d9800e1c6a8feac2fe0;p=ceph.git rgw: return error if accessing object in non-existent bucket 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 (cherry picked from commit 3ed68eb9fac9b3d0bf9111867d609f9ea08fb202) --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 5bdbb9d3177..c875018cfc9 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -340,7 +340,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); @@ -380,7 +380,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;