using ceph::crypto::MD5;
+extern string rgw_root_bucket;
+
+#define RGW_ROOT_BUCKET ".rgw"
+
#define RGW_ATTR_PREFIX "user.rgw."
#define RGW_ATTR_ACL RGW_ATTR_PREFIX "acl"
void RGWCreateBucket::execute()
{
- RGWAccessControlPolicy policy;
+ RGWAccessControlPolicy policy, old_policy;
map<string, bufferlist> attrs;
bufferlist aclbl;
+ bool existed;
+ bool pol_ret;
- bool pol_ret = policy.create_canned(s->user.user_id, s->user.display_name, s->canned_acl);
+ int r = get_policy_from_attr(&old_policy, rgw_root_bucket, s->bucket_str);
+ if (r >= 0) {
+ if (old_policy.get_owner().get_id().compare(s->user.user_id) != 0) {
+ ret = -EEXIST;
+ goto done;
+ }
+ }
+
+ pol_ret = policy.create_canned(s->user.user_id, s->user.display_name, s->canned_acl);
if (!pol_ret) {
ret = -EINVAL;
goto done;
if (ret && ret != -EEXIST)
goto done;
+ existed = (ret == -EEXIST);
+
ret = rgwstore->create_bucket(s->user.user_id, s->bucket_str, attrs,
s->user.auid);
- if (ret && ret != -EEXIST) /* if it exists, don't remove it! */
+ if (ret && !existed && ret != -EEXIST) /* if it exists (or previously existed), don't remove it! */
rgw_remove_bucket(s->user.user_id, s->bucket_str);
+ if (ret == -EEXIST)
+ ret = 0;
+
done:
send_response();
}
Rados *rados = NULL;
-#define ROOT_BUCKET ".rgw" //keep this synced to rgw_user.cc::root_bucket!
-
-static string root_bucket(ROOT_BUCKET);
static librados::IoCtx root_pool_ctx;
/**
*/
int RGWRados::open_root_pool_ctx()
{
- int r = rados->ioctx_create(root_bucket.c_str(), root_pool_ctx);
+ int r = rados->ioctx_create(RGW_ROOT_BUCKET, root_pool_ctx);
if (r == -ENOENT) {
- r = rados->pool_create(root_bucket.c_str());
+ r = rados->pool_create(RGW_ROOT_BUCKET);
if (r < 0)
return r;
- r = rados->ioctx_create(root_bucket.c_str(), root_pool_ctx);
+ r = rados->ioctx_create(RGW_ROOT_BUCKET, root_pool_ctx);
}
return r;
return r;
librados::IoCtx io_ctx;
- r = rados->ioctx_create(ROOT_BUCKET, io_ctx);
+ r = rados->ioctx_create(RGW_ROOT_BUCKET, io_ctx);
if (r < 0) {
RGW_LOG(0) << "WARNING: failed to create context in delete_bucket, bucket object leaked" << std::endl;
return r;
if (actual_obj.size() == 0) {
actual_obj = bucket;
- actual_bucket = root_bucket;
+ actual_bucket = rgw_root_bucket;
}
int r = rados->ioctx_create(actual_bucket.c_str(), io_ctx);
if (actual_obj.size() == 0) {
actual_obj = bucket;
- actual_bucket = root_bucket;
+ actual_bucket = rgw_root_bucket;
}
int r = rados->ioctx_create(actual_bucket.c_str(), io_ctx);
::encode(key, cmdbl);
::encode(bl, cmdbl);
+RGW_LOG(0) << "tmap_set bucket=" << bucket << " obj=" << obj << " key=" << key << std::endl;
+
librados::IoCtx io_ctx;
int r = rados->ioctx_create(bucket.c_str(), io_ctx);
if (r < 0)
return r;
r = io_ctx.tmap_update(obj, cmdbl);
+RGW_LOG(0) << "tmap_set done" << std::endl;
+
return r;
}
static string ui_bucket = USER_INFO_BUCKET_NAME;
static string ui_email_bucket = USER_INFO_EMAIL_BUCKET_NAME;
static string ui_openstack_bucket = USER_INFO_OPENSTACK_BUCKET_NAME;
-static string root_bucket = ".rgw"; //keep this synced to rgw_rados.cc::ROOT_BUCKET!
+
+string rgw_root_bucket = RGW_ROOT_BUCKET;
#define READ_CHUNK_LEN (16 * 1024)
/**
i != buckets.end();
++i) {
string bucket_name = i->first;
- rgwstore->delete_obj(info.user_id, root_bucket, bucket_name);
+ rgwstore->delete_obj(info.user_id, rgw_root_bucket, bucket_name);
}
rgwstore->delete_obj(info.user_id, ui_bucket, info.user_id);
rgwstore->delete_obj(info.user_id, ui_email_bucket, info.user_email);