From: Pritha Srivastava Date: Wed, 24 Oct 2018 07:31:36 +0000 (+0530) Subject: rgw: Minor fixes to radosgw-admin commands for a role. X-Git-Tag: v14.1.0~882^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=08b8c7e0b3202efb0b0754eb42a889da465c2e54;p=ceph.git rgw: Minor fixes to radosgw-admin commands for a role. Signed-off-by: Pritha Srivastava --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 047a506248c..1c801bc6666 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -928,7 +928,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; @@ -5062,26 +5062,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;