]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add a new error code for non-existed user. 16033/head
authorZhao Chao <zhaochao1984@gmail.com>
Fri, 30 Jun 2017 02:35:41 +0000 (10:35 +0800)
committerZhao Chao <zhaochao1984@gmail.com>
Fri, 7 Jul 2017 16:42:22 +0000 (00:42 +0800)
From http://docs.ceph.com/docs/master/radosgw/adminops/, There should be
a "NoSuchUser" response for user actions rather than "NoSuchKey".

Fixes: http://tracker.ceph.com/issues/20468
Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_rest_user.cc
src/rgw/rgw_user.cc

index 73c650c5ff6cd5ff4bda60419cd4a17049292754..72891f9c376d0b740ecea46d4ff95b2ce4a30eb5 100644 (file)
@@ -89,6 +89,7 @@ rgw_http_errors rgw_http_s3_errors({
     { ERR_NOT_FOUND, {404, "Not Found"}},
     { ERR_NO_SUCH_LC, {404, "NoSuchLifecycleConfiguration"}},
     { ERR_NO_SUCH_BUCKET_POLICY, {404, "NoSuchBucketPolicy"}},
+    { ERR_NO_SUCH_USER, {404, "NoSuchUser"}},
     { ERR_NO_SUCH_SUBUSER, {404, "NoSuchSubUser"}},
     { ERR_METHOD_NOT_ALLOWED, {405, "MethodNotAllowed" }},
     { ETIMEDOUT, {408, "RequestTimeout" }},
index c71aa4726093ab2c75183d15a92919c37f35482c..ef766d4d76a5489d9ae29d38e34ea6d7b142d96f 100644 (file)
@@ -198,6 +198,7 @@ using ceph::crypto::MD5;
 #define ERR_NO_SUCH_WEBSITE_CONFIGURATION 2039
 #define ERR_AMZ_CONTENT_SHA256_MISMATCH 2040
 #define ERR_NO_SUCH_LC           2041
+#define ERR_NO_SUCH_USER         2042
 #define ERR_NO_SUCH_SUBUSER      2043
 #define ERR_USER_SUSPENDED       2100
 #define ERR_INTERNAL_ERROR       2200
index 704ab241ddc6e6025d98a31836db4b2262b6322f..711fd3a0c1dca6c0d593d2b73ec1e1e437a30844 100644 (file)
@@ -693,6 +693,11 @@ void RGWOp_Quota_Info::execute()
   if (http_ret < 0)
     return;
 
+  if (!op_state.has_existing_user()) {
+    http_ret = -ERR_NO_SUCH_USER;
+    return;
+  }
+
   RGWUserInfo info;
   string err_msg;
   http_ret = user.info(info, &err_msg);
@@ -825,6 +830,11 @@ void RGWOp_Quota_Set::execute()
     return;
   }
 
+  if (!op_state.has_existing_user()) {
+    http_ret = -ERR_NO_SUCH_USER;
+    return;
+  }
+
 #define QUOTA_INPUT_MAX_LEN 1024
   if (set_all) {
     UserQuotas quotas;
index 4eb803e5cf4bc9c5f24fcc47da5c0dfc725ac129..57f2dc227c4700563932a96f7f0b63754042c914 100644 (file)
@@ -2299,7 +2299,7 @@ int RGWUserAdminOp_User::info(RGWRados *store, RGWUserAdminOpState& op_state,
     return ret;
 
   if (!op_state.has_existing_user())
-    return -ENOENT;
+    return -ERR_NO_SUCH_USER;
 
   Formatter *formatter = flusher.get_formatter();
 
@@ -2367,8 +2367,11 @@ int RGWUserAdminOp_User::modify(RGWRados *store, RGWUserAdminOpState& op_state,
   Formatter *formatter = flusher.get_formatter();
 
   ret = user.modify(op_state, NULL);
-  if (ret < 0)
+  if (ret < 0) {
+    if (ret == -ENOENT)
+      ret = -ERR_NO_SUCH_USER;
     return ret;
+  }
 
   ret = user.info(info, NULL);
   if (ret < 0)
@@ -2394,6 +2397,8 @@ int RGWUserAdminOp_User::remove(RGWRados *store, RGWUserAdminOpState& op_state,
 
   ret = user.remove(op_state, NULL);
 
+  if (ret == -ENOENT)
+    ret = -ERR_NO_SUCH_USER;
   return ret;
 }
 
@@ -2406,6 +2411,9 @@ int RGWUserAdminOp_Subuser::create(RGWRados *store, RGWUserAdminOpState& op_stat
   if (ret < 0)
     return ret;
 
+  if (!op_state.has_existing_user())
+    return -ERR_NO_SUCH_USER;
+
   Formatter *formatter = flusher.get_formatter();
 
   ret = user.subusers.add(op_state, NULL);
@@ -2433,6 +2441,9 @@ int RGWUserAdminOp_Subuser::modify(RGWRados *store, RGWUserAdminOpState& op_stat
   if (ret < 0)
     return ret;
 
+  if (!op_state.has_existing_user())
+    return -ERR_NO_SUCH_USER;
+
   Formatter *formatter = flusher.get_formatter();
 
   ret = user.subusers.modify(op_state, NULL);
@@ -2461,6 +2472,9 @@ int RGWUserAdminOp_Subuser::remove(RGWRados *store, RGWUserAdminOpState& op_stat
     return ret;
 
 
+  if (!op_state.has_existing_user())
+    return -ERR_NO_SUCH_USER;
+
   ret = user.subusers.remove(op_state, NULL);
   if (ret < 0)
     return ret;
@@ -2477,6 +2491,9 @@ int RGWUserAdminOp_Key::create(RGWRados *store, RGWUserAdminOpState& op_state,
   if (ret < 0)
     return ret;
 
+  if (!op_state.has_existing_user())
+    return -ERR_NO_SUCH_USER;
+
   Formatter *formatter = flusher.get_formatter();
 
   ret = user.keys.add(op_state, NULL);
@@ -2511,6 +2528,9 @@ int RGWUserAdminOp_Key::remove(RGWRados *store, RGWUserAdminOpState& op_state,
   if (ret < 0)
     return ret;
 
+  if (!op_state.has_existing_user())
+    return -ERR_NO_SUCH_USER;
+
 
   ret = user.keys.remove(op_state, NULL);
   if (ret < 0)
@@ -2528,6 +2548,9 @@ int RGWUserAdminOp_Caps::add(RGWRados *store, RGWUserAdminOpState& op_state,
   if (ret < 0)
     return ret;
 
+  if (!op_state.has_existing_user())
+    return -ERR_NO_SUCH_USER;
+
   Formatter *formatter = flusher.get_formatter();
 
   ret = user.caps.add(op_state, NULL);
@@ -2556,6 +2579,9 @@ int RGWUserAdminOp_Caps::remove(RGWRados *store, RGWUserAdminOpState& op_state,
   if (ret < 0)
     return ret;
 
+  if (!op_state.has_existing_user())
+    return -ERR_NO_SUCH_USER;
+
   Formatter *formatter = flusher.get_formatter();
 
   ret = user.caps.remove(op_state, NULL);