if (gen_secret_key)
user_op.set_gen_secret(); // assume that a key pair should be created
- if (max_buckets >= 0)
+ if (max_buckets_specified)
user_op.set_max_buckets(max_buckets);
+ if (admin_specified)
+ user_op.set_admin(admin);
+
if (system_specified)
user_op.set_system(system);
map<string, RGWAccessKey> swift_keys;
map<string, RGWSubUser> subusers;
__u8 suspended;
- uint32_t max_buckets;
+ int32_t max_buckets;
uint32_t op_mask;
RGWUserCaps caps;
+ __u8 admin;
__u8 system;
string default_placement;
list<string> placement_tags;
int RGWCreateBucket::verify_permission()
{
- if (!rgw_user_is_authenticated(*(s->user)))
+ /* This check is mostly needed for S3 that doesn't support account ACL.
+ * Swift doesn't allow to delegate any permission to an anonymous user,
+ * so it will become an early exit in such case. */
+ if (s->auth_identity->is_anonymous()) {
return -EACCES;
+ }
+
+ if (!verify_user_permission(s, RGW_PERM_WRITE)) {
+ return -EACCES;
+ }
if (s->user->user_id.tenant != s->bucket_tenant) {
- ldout(s->cct, 10)
- << "user cannot create a bucket in a different tenant (user_id.tenant="
- << s->user->user_id.tenant << " requested=" << s->bucket_tenant << ")"
- << dendl;
+ ldout(s->cct, 10) << "user cannot create a bucket in a different tenant"
+ << " (user_id.tenant=" << s->user->user_id.tenant
+ << " requested=" << s->bucket_tenant << ")"
+ << dendl;
return -EACCES;
}
+ if (s->user->max_buckets < 0) {
+ return -EPERM;
+ }
if (s->user->max_buckets) {
RGWUserBuckets buckets;
op_ret = rgw_read_user_buckets(store, s->user->user_id, buckets,
marker, string(), s->user->max_buckets,
false, &is_truncated);
- if (op_ret < 0)
+ if (op_ret < 0) {
return op_ret;
+ }
- if (buckets.count() >= s->user->max_buckets) {
+ if ((int)buckets.count() >= s->user->max_buckets) {
return -ERR_TOO_MANY_BUCKETS;
}
}