From cb2d36602098ae10497d7836245569b7ecba625b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 29 Sep 2011 23:17:12 -0700 Subject: [PATCH] radosgw-admin: fix acl vs content-length check Signed-off-by: Sage Weil --- src/rgw/rgw_common.h | 34 +++++++++++++++++++--------------- src/rgw/rgw_rest.cc | 4 +--- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index de97558754891..4870e17946606 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -165,21 +165,25 @@ class XMLArgs map val_map; map sub_resources; public: - XMLArgs() {} - XMLArgs(string s) : str(s) {} - /** Set the arguments; as received */ - 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 */ - string& get(string& name); - string& get(const char *name); - /** see if a parameter is contained in this XMLArgs */ - bool exists(const char *name) { - map::iterator iter = val_map.find(name); - return (iter != val_map.end()); - } - map& get_sub_resources() { return sub_resources; } + XMLArgs() {} + XMLArgs(string s) : str(s) {} + /** Set the arguments; as received */ + 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 */ + string& get(string& name); + string& get(const char *name); + /** see if a parameter is contained in this XMLArgs */ + bool exists(const char *name) { + map::iterator iter = val_map.find(name); + return (iter != val_map.end()); + } + bool sub_resource_exists(const char *name) { + map::iterator iter = sub_resources.find(name); + return (iter != sub_resources.end()); + } + map& get_sub_resources() { return sub_resources; } }; class RGWConf; diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index a776c0eb2230b..ab63a7aeef51d 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -694,9 +694,7 @@ int RGWHandler_REST::preprocess(struct req_state *s, FCGX_Request *fcgx) s->path_name = s->env->get("SCRIPT_NAME"); s->path_name_url = s->env->get("REQUEST_URI"); int pos = s->path_name_url.find('?'); - string path_arg; if (pos >= 0) { - path_arg = s->path_name_url.substr(pos+1); s->path_name_url = s->path_name_url.substr(0, pos); } s->method = s->env->get("REQUEST_METHOD"); @@ -724,7 +722,7 @@ int RGWHandler_REST::preprocess(struct req_state *s, FCGX_Request *fcgx) init_entities_from_header(s); switch (s->op) { case OP_PUT: - if (s->object && path_arg != "acl") { + if (s->object && !s->args.sub_resource_exists("acl")) { if (!s->length) ret = -ERR_LENGTH_REQUIRED; else if (*s->length == '\0') -- 2.39.5