From a0d521b2ee8102651639b6457b55dd7eb845040c Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 27 May 2011 13:35:47 -0700 Subject: [PATCH] rgw: fix signing for some requests --- src/rgw/rgw_common.cc | 15 ++++++++------- src/rgw/rgw_common.h | 6 +++--- src/rgw/rgw_rest_s3.cc | 17 +++++++++++++---- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 9e9b5fb71b123..ba2640ab95756 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -109,13 +109,14 @@ int XMLArgs::parse() if (ret >= 0) { val_map[nv.get_name()] = nv.get_val(); - if (ret > 0) { /* this might be a sub-resource */ - if ((nv.get_name().compare("acl") == 0) || - (nv.get_name().compare("location") == 0) || - (nv.get_name().compare("uploads") == 0) || - (nv.get_name().compare("versionid") == 0) || - (nv.get_name().compare("torrent") == 0)) - sub_resource = nv.get_name(); + if ((nv.get_name().compare("acl") == 0) || + (nv.get_name().compare("location") == 0) || + (nv.get_name().compare("uploads") == 0) || + (nv.get_name().compare("partNumber") == 0) || + (nv.get_name().compare("uploadId") == 0) || + (nv.get_name().compare("versionid") == 0) || + (nv.get_name().compare("torrent") == 0)) { + sub_resources[nv.get_name()] = nv.get_val(); } } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index fec011a12ad05..68749d481d603 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -119,12 +119,12 @@ class XMLArgs { string str, empty_str; map val_map; - string sub_resource; + map sub_resources; public: XMLArgs() {} XMLArgs(string s) : str(s) {} /** Set the arguments; as received */ - void set(string s) { val_map.clear(); sub_resource.clear(); str = s; } + void set(string s) { val_map.clear(); sub_resources.clear(); str = s; } /** parse the received arguments */ int parse(); /** Get the value for a specific argument parameter */ @@ -135,7 +135,7 @@ class XMLArgs map::iterator iter = val_map.find(name); return (iter != val_map.end()); } - string& get_sub_resource() { return sub_resource; } + map& get_sub_resources() { return sub_resources; } }; enum http_op { diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 0286d6f4e2db1..5a26a0e238e0a 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -354,11 +354,20 @@ static void get_canon_resource(struct req_state *s, string& dest) dest.append(s->path_name_url.c_str()); - string& sub = s->args.get_sub_resource(); - if (sub.size() > 0) { - dest.append("?"); - dest.append(sub); + map& sub = s->args.get_sub_resources(); + map::iterator iter; + for (iter = sub.begin(); iter != sub.end(); ++iter) { + if (iter == sub.begin()) + dest.append("?"); + else + dest.append("&"); + dest.append(iter->first); + if (!iter->second.empty()) { + dest.append("="); + dest.append(iter->second); + } } + RGW_LOG(0) << "dest=" << dest << dendl; } /* -- 2.39.5