From: Dunrong Huang Date: Wed, 23 Dec 2015 14:05:49 +0000 (+0800) Subject: rgw: add a new error code for invalid secret key X-Git-Tag: v10.0.3~107^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df6d323908baaae56a0eed898ac2ec4351450803;p=ceph.git rgw: add a new error code for invalid secret key From http://docs.ceph.com/docs/master/radosgw/adminops/ when invalid secret key specified, rgw should return 400 with InvalidSecretKey Signed-off-by: Dunrong Huang --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 9565f98e84b2..505098a81d0d 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -158,6 +158,7 @@ using ceph::crypto::MD5; #define ERR_NOT_SLO_MANIFEST 2031 #define ERR_EMAIL_EXIST 2032 #define ERR_KEY_EXIST 2033 +#define ERR_INVALID_SECRET_KEY 2034 #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 0bb69fa73778..9d2ab3c71866 100644 --- a/src/rgw/rgw_http_errors.h +++ b/src/rgw/rgw_http_errors.h @@ -53,6 +53,7 @@ const static struct rgw_http_errors RGW_HTTP_ERRORS[] = { { ERR_USER_EXIST, 409, "UserAlreadyExists" }, { ERR_EMAIL_EXIST, 409, "EmailExists" }, { ERR_KEY_EXIST, 409, "KeyExists"}, + { ERR_INVALID_SECRET_KEY, 400, "InvalidSecretKey"}, { 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 fb46e4e8acf5..14b1f14c3139 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -917,7 +917,7 @@ int RGWAccessKeyPool::generate_key(RGWUserAdminOpState& op_state, std::string *e if (!gen_secret) { if (op_state.get_secret_key().empty()) { set_err_msg(err_msg, "empty secret key"); - return -EINVAL; + return -ERR_INVALID_SECRET_KEY; } key = op_state.get_secret_key(); @@ -1049,7 +1049,7 @@ int RGWAccessKeyPool::modify_key(RGWUserAdminOpState& op_state, std::string *err if (key.empty()) { set_err_msg(err_msg, "empty secret key"); - return -EINVAL; + return -ERR_INVALID_SECRET_KEY; } // update the access key with the new secret key