]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: protect the id-based accesses from namespace collisions
authorGreg Farnum <gregory.farnum@dreamhost.com>
Wed, 28 Sep 2011 21:37:06 +0000 (14:37 -0700)
committerSage Weil <sage@newdream.net>
Thu, 29 Sep 2011 15:39:10 +0000 (08:39 -0700)
Users can create buckets named "8", but they can't name them ".8". So
prepend the actual on-disk objects with a period.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/rgw/rgw_bucket.cc

index aaf4014089b22784bce68f1d290aeae39f49a6fa..e04a47158f104cde105ae163b1095294eec8e3f0 100644 (file)
@@ -36,7 +36,7 @@ int rgw_store_bucket_info(string& bucket_name, RGWBucketInfo& info)
 int rgw_store_bucket_info_id(uint64_t bucket_id, RGWBucketInfo& info)
 {
   char bucket_char[16];
-  snprintf(bucket_char, sizeof(bucket_char), "%lld",
+  snprintf(bucket_char, sizeof(bucket_char), ".%lld",
            (long long unsigned)bucket_id);
   string bucket_string(bucket_char);
 
@@ -73,7 +73,7 @@ int rgw_get_bucket_info(string& bucket_name, RGWBucketInfo& info)
 int rgw_get_bucket_info_id(uint64_t bucket_id, RGWBucketInfo& info)
 {
   char bucket_char[16];
-  snprintf(bucket_char, sizeof(bucket_char), "%lld",
+  snprintf(bucket_char, sizeof(bucket_char), ".%lld",
            (long long unsigned)bucket_id);
   string bucket_string(bucket_char);