]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: fix 2 bugs in RGWListBuckets, remove scaffolding
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 4 Oct 2015 18:51:52 +0000 (14:51 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:04:39 +0000 (12:04 -0500)
1. the prior commit had authorize cognate with S3
1.1 which may be right
1.2 but maybe not for each request
1.3 and lacked priming/forged auth data

The forging of auth data is now easy, but the interesting part is
caching and efficiently attaching it so I paused, and

2. disabled auth, which was now overriding and anonymizing all
requests (good!)

3. fixed another instance of reinterpret_cast where (one of)
dynamic_cast or a saved pointer descendant request (avoids a runtime
check, so will add later) is needed

4. fixed bad offset argument to rgw_readdir

The list bucket facility now works, modulo non-auth.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/librgw.cc
src/rgw/rgw_file.cc
src/rgw/rgw_file.h
src/rgw/rgw_rest_lib.cc
src/test/librgw_file.cc

index 7c7d5d190122caf21c9c749fea0f2d8aaabfd7bb..b4bd1c8001cf188173602ca22d9e12e77a71dae3 100644 (file)
@@ -225,6 +225,8 @@ int RGWLibProcess::process_request(RGWLibRequest* req, RGWLibIO* io)
     goto done;
   }
 
+#warning authorize step disabled
+#if 0
   // just checks the HTTP header, and that the user can access the gateway
   // may be able to skip this after MOUNT (revalidate the user info)
   req->log(s, "authorizing");
@@ -234,6 +236,7 @@ int RGWLibProcess::process_request(RGWLibRequest* req, RGWLibIO* io)
     abort_req(s, op, ret);
     goto done;
   }
+#endif
 
   if (s->user.suspended) {
     dout(10) << "user is suspended, uid=" << s->user.user_id << dendl;
index e7c3de5abafaff77a40c8e2b8ca6c751a88ae498..d53090afca140a8a80ffd44a41cd38b3aba0d706 100644 (file)
@@ -298,11 +298,9 @@ int rgw_readdir(struct rgw_fs *rgw_fs,
 
   CephContext* cct = static_cast<CephContext*>(rgw_fs->rgw);
 
-#if 1
   /* TODO:
-   * take actual, um, arguments
    * deal with markers (continuation)
-   * deal with sync vs async
+   * deal with authorization
    * consider non-default tenancy/user and bucket layouts
    */
   if (is_root(uri)) {
@@ -315,45 +313,8 @@ int rgw_readdir(struct rgw_fs *rgw_fs,
       ...
     */
   }
-#else
-  /* XXX current open-coded logic should move into librgw (need
-   * functor mechanism wrapping callback */
 
-  if (is_root(uri)) {
-    /* get the bucket list */
-    string start; // XXX need to match offset
-    string end; // XXX need to match offset
-    uint64_t nread, bucket_count, bucket_objcount;
-    RGWUserBuckets buckets;
-    uint64_t max_buckets = cct->_conf->rgw_list_buckets_max_chunk;
-
-    /* XXX check offsets */
-    uint64_t ix = 3;
-    rgw_user uid(rgw_fs->user_id);
-    rc = rgw_read_user_buckets(store, uid, buckets, start, end, max_buckets,
-                              true);
-    if (rc < 0) {
-      ldout(cct, 10) << "WARNING: failed on rgw_get_user_buckets uid="
-                    << rgw_fs->user_id << dendl;
-      return rc;
-    } else {
-      bucket_count = 0;
-      bucket_objcount = 0;
-      map<string, RGWBucketEnt>& m = buckets.get_buckets();
-      for (auto& ib : m) {
-       RGWBucketEnt& bent = ib.second;
-       bucket_objcount += bent.count;
-       start = ib.first;
-       (void) rcb(bent.bucket.name.c_str(), cb_arg, ix++);
-      }
-      bucket_count += m.size();
-    }
-  } else {
-    /* !root uri */
-    
-  }
-#endif
-  *eof = true;
+  *eof = true; // XXX move into RGGWListBucket(s)Request
 
   return 0;
 }
index 6ebf94ad2cf2b95f41538047df4d5075783a256b..1fc149a9ff894f8f9dfaf063845213eefc4617a1 100644 (file)
@@ -54,6 +54,10 @@ public:
     s->info.request_params = "";
     s->info.domain = ""; /* XXX ? */
 
+    /* XXX fake user_id (will fix) */
+    s->user.user_id = user_id;
+    s->user.display_name = user_id;
+
     return 0;
   }
 
index 531720dfc1f5917849c10b886451d70867ad74c1..76132fd8423a4e78c582c3b6cad4b71bd4aff0a0 100644 (file)
@@ -71,8 +71,9 @@ void RGWListBuckets_ObjStore_Lib::send_response_data(RGWUserBuckets& buckets)
   if (!sent_data)
     return;
 
+  // XXX we can improve this
   RGWListBucketsRequest* req
-    = reinterpret_cast<RGWListBucketsRequest*>(this);
+    = dynamic_cast<RGWListBucketsRequest*>(this);
 
   map<string, RGWBucketEnt>& m = buckets.get_buckets();
   for (const auto& iter : m) {
index 7706bc14d16684111386e725c80e45c7ca2943a3..3769de8c4063a12f059ea436862925bf2d4c83cb 100644 (file)
@@ -61,7 +61,8 @@ TEST(LibRGW, LIST_BUCKETS) {
   using std::get;
 
   bool eof = false;
-  int ret = rgw_readdir(fs, &fs->root_fh, 0 /* offset */, r1_cb, &fids1, &eof);
+  uint64_t offset = 0;
+  int ret = rgw_readdir(fs, &fs->root_fh, &offset, r1_cb, &fids1, &eof);
   for (auto& fid : fids1) {
     std::cout << "fname: " << get<0>(fid) << " fid: " << get<1>(fid)
              << std::endl;