]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: return error on email address conflict (add user)
authorMatt Benjamin <mbenjamin@redhat.com>
Mon, 18 Jan 2016 20:58:07 +0000 (15:58 -0500)
committerAbhishek Varshney <abhishek.varshney@flipkart.com>
Mon, 1 Aug 2016 06:32:16 +0000 (12:02 +0530)
Fixes the error return inconsistency documented in upstream
Ceph issue #13598

Revised after upstream review, permits changing email address as
originally (but use case-insensitive comp).

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit 90c143efa2156e55dc017ebe81005315cacaf2c5)

src/rgw/rgw_user.cc

index 53f4a75fb1c1e764cff126229a1a674b175e0fda..6002aec8b93ae81351cc9dc3c2eb1baa26b63b9d 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <string>
 #include <map>
+#include <boost/algorithm/string.hpp>
 
 #include "common/errno.h"
 #include "common/Formatter.h"
@@ -1877,13 +1878,15 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg)
   // fail if the user exists already
   if (op_state.has_existing_user()) {
     if (!op_state.exclusive &&
-        (user_email.empty() || old_info.user_email == user_email) &&
+        (user_email.empty() ||
+        boost::iequals(user_email, old_info.user_email)) &&
         old_info.display_name == display_name) {
       return execute_modify(op_state, err_msg);
     }
 
     if (op_state.found_by_email) {
-      set_err_msg(err_msg, "email: " + user_email + " exists");
+      set_err_msg(err_msg, "email: " + user_email +
+                 " is the email address an existing user");
       ret = -ERR_EMAIL_EXIST;
     } else if (op_state.found_by_key) {
       set_err_msg(err_msg, "duplicate key provided");