diff options
author | caleb miles <caleb.miles@inktank.com> | 2013-04-05 09:31:56 -0700 |
---|---|---|
committer | caleb miles <caleb.miles@inktank.com> | 2013-04-05 10:26:29 -0700 |
commit | be6961bd28f11a9e0dde8ebc92d62fbcefc487ea (patch) | |
tree | d840a5353ff5d79708a0d1584272fbd4da5ca703 | |
parent | debce05510e9371ae2b5102cb7daf2f96501f8f0 (diff) | |
download | ceph-be6961bd28f11a9e0dde8ebc92d62fbcefc487ea.tar.gz |
Allow creation of buckets starting with underscore in RGW
Signed-off-by caleb miles <caleb.miles@inktank.com>
-rw-r--r-- | src/common/config_opts.h | 1 | ||||
-rw-r--r-- | src/rgw/rgw_rest_s3.cc | 14 | ||||
-rw-r--r-- | src/rgw/rgw_rest_s3.h | 7 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/common/config_opts.h b/src/common/config_opts.h index fbb6e083b62..cb2fd391fc9 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -573,6 +573,7 @@ OPTION(rgw_extended_http_attrs, OPT_STR, "") // list of extended attrs that can OPTION(rgw_exit_timeout_secs, OPT_INT, 120) // how many seconds to wait for process to go down before exiting unconditionally OPTION(rgw_get_obj_window_size, OPT_INT, 16 << 20) // window size in bytes for single get obj request OPTION(rgw_get_obj_max_req_size, OPT_INT, 4 << 20) // max length of a single get obj rados op +OPTION(rgw_relaxed_s3_bucket_names, OPT_BOOL, false) // enable relaxed bucket name rules for US region buckets OPTION(mutex_perf_counter, OPT_BOOL, false) // enable/disable mutex perf counter diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 78efa72aa55..b46ff814663 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -1742,7 +1742,7 @@ static bool looks_like_ip_address(const char *bucket) return (num_periods == 3); } -int RGWHandler_ObjStore_S3::validate_bucket_name(const string& bucket) +int RGWHandler_ObjStore_S3::validate_bucket_name(const string& bucket, bool relaxed_names) { int ret = RGWHandler_ObjStore::validate_bucket_name(bucket); if (ret < 0) @@ -1751,10 +1751,13 @@ int RGWHandler_ObjStore_S3::validate_bucket_name(const string& bucket) if (bucket.size() == 0) return 0; + // bucket names must start with a number, letter, or underscore if (!(isalpha(bucket[0]) || isdigit(bucket[0]))) { - // bucket names must start with a number or letter - return -ERR_INVALID_BUCKET_NAME; - } + if (!relaxed_names) + return -ERR_INVALID_BUCKET_NAME; + else if (!(bucket[0] == '_' || bucket[0] == '.' || bucket[0] == '-')) + return -ERR_INVALID_BUCKET_NAME; + } for (const char *s = bucket.c_str(); *s; ++s) { char c = *s; @@ -1778,7 +1781,8 @@ int RGWHandler_ObjStore_S3::init(RGWRados *store, struct req_state *s, RGWClient { dout(10) << "s->object=" << (s->object ? s->object : "<NULL>") << " s->bucket=" << (s->bucket_name ? s->bucket_name : "<NULL>") << dendl; - int ret = validate_bucket_name(s->bucket_name_str); + bool relaxed_names = s->cct->_conf->rgw_relaxed_s3_bucket_names; + int ret = validate_bucket_name(s->bucket_name_str, relaxed_names); if (ret) return ret; ret = validate_object_name(s->object_str); diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index 277ebf1ffb8..204bee84456 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -261,7 +261,10 @@ public: RGWHandler_Auth_S3() : RGWHandler_ObjStore() {} virtual ~RGWHandler_Auth_S3() {} - virtual int validate_bucket_name(const string& bucket) { return 0; } + virtual int validate_bucket_name(const string& bucket) { + return 0; + } + virtual int validate_object_name(const string& bucket) { return 0; } virtual int init(RGWRados *store, struct req_state *state, RGWClientIO *cio); @@ -278,7 +281,7 @@ public: RGWHandler_ObjStore_S3() : RGWHandler_ObjStore() {} virtual ~RGWHandler_ObjStore_S3() {} - int validate_bucket_name(const string& bucket); + int validate_bucket_name(const string& bucket, bool relaxed_names); virtual int init(RGWRados *store, struct req_state *state, RGWClientIO *cio); virtual int authorize() { |