diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 792fdf2e180..9176e0fa561 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -934,7 +934,7 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_ } else if (strcmp(prev_cmd, "role") == 0) { if (strcmp(cmd, "create") == 0) return OPT_ROLE_CREATE; - if (strcmp(cmd, "delete") == 0) + if (strcmp(cmd, "rm") == 0) return OPT_ROLE_DELETE; if (strcmp(cmd, "get") == 0) return OPT_ROLE_GET; @@ -5090,26 +5090,20 @@ int main(int argc, const char **argv) return -EINVAL; } - /* The following two calls will be replaced by read_decode_json or something - similar when the code for AWS Policies is in place */ - bufferlist bl; - int ret = read_input(assume_role_doc, bl); - if (ret < 0) { - cerr << "ERROR: failed to read input: " << cpp_strerror(-ret) << std::endl; - return ret; - } - JSONParser p; - if (!p.parse(bl.c_str(), bl.length())) { - cout << "ERROR: failed to parse JSON: " << assume_role_doc << std::endl; + bufferlist bl = bufferlist::static_from_string(assume_role_doc); + try { + const rgw::IAM::Policy p(g_ceph_context, tenant, bl); + } catch (rgw::IAM::PolicyParseException& e) { + cerr << "failed to parse policy: " << e.what() << std::endl; return -EINVAL; } - string trust_policy = bl.to_str(); + RGWRole role(g_ceph_context, store, role_name, tenant); ret = role.get(); if (ret < 0) { return -ret; } - role.update_trust_policy(trust_policy); + role.update_trust_policy(assume_role_doc); ret = role.update(); if (ret < 0) { return -ret;