From: Dunrong Huang Date: Wed, 23 Dec 2015 14:19:36 +0000 (+0800) Subject: rgw: add a new error code for invalid admin capability X-Git-Tag: v10.0.3~107^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8ea80a0ee3b857df3910d29de179182747a86816;p=ceph.git rgw: add a new error code for invalid admin capability From http://docs.ceph.com/docs/master/radosgw/adminops/ when attempt to grant invalid admin capability, rgw should return InvalidCap rather than InvalidArgument. Signed-off-by: Dunrong Huang --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 9e20fa328195..dfd31050a43c 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -1010,7 +1010,7 @@ int RGWUserCaps::get_cap(const string& cap, string& type, uint32_t *pperm) } if (!is_valid_cap_type(type)) - return -EINVAL; + return -ERR_INVALID_CAP; string cap_perm; uint32_t perm = 0; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 7ff0d87a1b28..59893527d03b 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -160,6 +160,7 @@ using ceph::crypto::MD5; #define ERR_KEY_EXIST 2033 #define ERR_INVALID_SECRET_KEY 2034 #define ERR_INVALID_KEY_TYPE 2035 +#define ERR_INVALID_CAP 2036 #define ERR_USER_SUSPENDED 2100 #define ERR_INTERNAL_ERROR 2200 #define ERR_NOT_IMPLEMENTED 2201 diff --git a/src/rgw/rgw_http_errors.h b/src/rgw/rgw_http_errors.h index df1b59db1a12..fbe805f41de2 100644 --- a/src/rgw/rgw_http_errors.h +++ b/src/rgw/rgw_http_errors.h @@ -55,6 +55,7 @@ const static struct rgw_http_errors RGW_HTTP_ERRORS[] = { { ERR_KEY_EXIST, 409, "KeyExists"}, { ERR_INVALID_SECRET_KEY, 400, "InvalidSecretKey"}, { ERR_INVALID_KEY_TYPE, 400, "InvalidKeyType"}, + { ERR_INVALID_CAP, 400, "InvalidCapability"}, { ENOTEMPTY, 409, "BucketNotEmpty" }, { ERR_PRECONDITION_FAILED, 412, "PreconditionFailed" }, { ERANGE, 416, "InvalidRange" }, diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 296a400e0c6d..49c579fd1be7 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -1521,7 +1521,7 @@ int RGWUserCapPool::init(RGWUserAdminOpState& op_state) caps = op_state.get_caps_obj(); if (!caps) { caps_allowed = false; - return -EINVAL; + return -ERR_INVALID_CAP; } caps_allowed = true; @@ -1551,7 +1551,7 @@ int RGWUserCapPool::add(RGWUserAdminOpState& op_state, std::string *err_msg, boo if (caps_str.empty()) { set_err_msg(err_msg, "empty user caps"); - return -EINVAL; + return -ERR_INVALID_CAP; } int r = caps->add_from_string(caps_str); @@ -1592,7 +1592,7 @@ int RGWUserCapPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg, if (caps_str.empty()) { set_err_msg(err_msg, "empty user caps"); - return -EINVAL; + return -ERR_INVALID_CAP; } int r = caps->remove_from_string(caps_str);