From af8d9bdf07ab97b9d9387f68ba0fedccce803073 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Mon, 5 Jun 2017 15:46:45 -0400 Subject: [PATCH] rgw: Support certain archaic and antiquated distributions Signed-off-by: Adam C. Emerson --- src/rgw/rgw_iam_policy.cc | 33 +++++++++++++++++++-------------- src/rgw/rgw_role.cc | 11 ++++++----- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/rgw/rgw_iam_policy.cc b/src/rgw/rgw_iam_policy.cc index c12e243f1e00d..574236101b26e 100644 --- a/src/rgw/rgw_iam_policy.cc +++ b/src/rgw/rgw_iam_policy.cc @@ -3,11 +3,12 @@ #include -#include #include #include #include +#include + #include "rapidjson/reader.h" #include "rgw_auth.h" @@ -22,10 +23,7 @@ using std::find; using std::int64_t; using std::move; using std::pair; -using std::regex; -using std::regex_match; using std::size_t; -using std::smatch; using std::string; using std::stringstream; using std::ostream; @@ -36,6 +34,11 @@ using std::unordered_map; using boost::container::flat_set; using boost::none; using boost::optional; +using boost::regex; +using boost::regex_constants::ECMAScript; +using boost::regex_constants::optimize; +using boost::regex_match; +using boost::smatch; using rapidjson::BaseReaderHandler; using rapidjson::UTF8; @@ -201,13 +204,15 @@ ARN::ARN(const rgw_bucket& b, const string& o) } optional ARN::parse(const string& s, bool wildcards) { - static const regex rx_wild("arn:([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)", - std::regex_constants::ECMAScript | - std::regex_constants::optimize); - static const regex rx_no_wild( - "arn:([^:*]*):([^:*]*):([^:*]*):([^:*]*):([^:*]*)", - std::regex_constants::ECMAScript | - std::regex_constants::optimize); + static const char str_wild[] = "arn:([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)"; + static const regex rx_wild(str_wild, + sizeof(str_wild) - 1, + ECMAScript | optimize); + static const char str_no_wild[] + = "arn:([^:*]*):([^:*]*):([^:*]*):([^:*]*):([^:*]*)"; + static const regex rx_no_wild(str_no_wild, + sizeof(str_no_wild) - 1, + ECMAScript | optimize); smatch match; @@ -703,9 +708,9 @@ static optional parse_principal(CephContext* cct, TokenID t, return Principal::tenant(std::move(a->account)); } - static const regex rx("([^/]*)/(.*)", - std::regex_constants::ECMAScript | - std::regex_constants::optimize); + static const char rx_str[] = "([^/]*)/(.*)"; + static const regex rx(rx_str, sizeof(rx_str) - 1, + ECMAScript | optimize); smatch match; if (regex_match(a->resource, match, rx)) { ceph_assert(match.size() == 2); diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index 236fe6e6aa448..732b49c7431ed 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -1,6 +1,7 @@ #include #include -#include + +#include #include "common/errno.h" #include "common/Formatter.h" @@ -377,14 +378,14 @@ bool RGWRole::validate_input() return false; } - std::regex regex_name("[A-Za-z0-9:=,.@-]+"); - if (! std::regex_match(name, regex_name)) { + boost::regex regex_name("[A-Za-z0-9:=,.@-]+"); + if (! boost::regex_match(name, regex_name)) { ldout(cct, 0) << "ERROR: Invalid chars in name " << dendl; return false; } - std::regex regex_path("(/[!-~]+/)|(/)"); - if (! std::regex_match(path,regex_path)) { + boost::regex regex_path("(/[!-~]+/)|(/)"); + if (! boost::regex_match(path,regex_path)) { ldout(cct, 0) << "ERROR: Invalid chars in path " << dendl; return false; } -- 2.39.5