From: Matt Benjamin Date: Sun, 4 Oct 2015 18:51:52 +0000 (-0400) Subject: librgw: fix 2 bugs in RGWListBuckets, remove scaffolding X-Git-Tag: v10.1.0~382^2~221 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=80a56f20044a73b095bbe1d79c55d48f50760108;p=ceph.git librgw: fix 2 bugs in RGWListBuckets, remove scaffolding 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 --- diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc index 7c7d5d190122..b4bd1c8001cf 100644 --- a/src/rgw/librgw.cc +++ b/src/rgw/librgw.cc @@ -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; diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index e7c3de5abafa..d53090afca14 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -298,11 +298,9 @@ int rgw_readdir(struct rgw_fs *rgw_fs, CephContext* cct = static_cast(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& 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; } diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 6ebf94ad2cf2..1fc149a9ff89 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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; } diff --git a/src/rgw/rgw_rest_lib.cc b/src/rgw/rgw_rest_lib.cc index 531720dfc1f5..76132fd8423a 100644 --- a/src/rgw/rgw_rest_lib.cc +++ b/src/rgw/rgw_rest_lib.cc @@ -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(this); + = dynamic_cast(this); map& m = buckets.get_buckets(); for (const auto& iter : m) { diff --git a/src/test/librgw_file.cc b/src/test/librgw_file.cc index 7706bc14d166..3769de8c4063 100644 --- a/src/test/librgw_file.cc +++ b/src/test/librgw_file.cc @@ -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;