]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw:user email can modify to empty
authorWeijun Duan <duanweijun@h3c.com>
Sat, 27 Feb 2016 09:28:14 +0000 (04:28 -0500)
committerLoic Dachary <ldachary@redhat.com>
Thu, 13 Oct 2016 09:37:38 +0000 (11:37 +0200)
Fixes: http://tracker.ceph.com/issues/13286
Signed-off-by: Weijun Duan <duanweijun@h3c.com>
(cherry picked from commit ebfd713d9a40e1cb33dfdf2198c20d621e387e36)

src/rgw/rgw_admin.cc
src/rgw/rgw_user.cc

index c36b913d5daeee3e525673dc851b8b285356834d..97f8a95f53b034adaf54939c767f973cd7be9b5c 100644 (file)
@@ -2076,6 +2076,7 @@ int main(int argc, char **argv)
       secret_key = val;
     } else if (ceph_argparse_witharg(args, i, &val, "-e", "--email", (char*)NULL)) {
       user_email = val;
+      user_op.user_email_specified=true;
     } else if (ceph_argparse_witharg(args, i, &val, "-n", "--display-name", (char*)NULL)) {
       display_name = val;
     } else if (ceph_argparse_witharg(args, i, &val, "-b", "--bucket", (char*)NULL)) {
index 6002aec8b93ae81351cc9dc3c2eb1baa26b63b9d..ef4e644063ef24915e308501af9d22c417df817b 100644 (file)
@@ -2126,8 +2126,17 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg)
       }
     }
     user_info.user_email = op_email;
-  }
+  } else if (op_email.empty() && op_state.user_email_specified) {
 
+    rgw_obj email_obj(store->zone.user_email_pool, user_info.user_email);
+    ldout(store->ctx(), 10) << "removing email index: " << user_info.user_email << dendl;
+    ret = store->delete_system_obj(email_obj);
+    if (ret < 0 && ret != -ENOENT) {
+      ldout(store->ctx(), 0) << "ERROR: could not remove " << user_info.user_id << ":" << email_obj << ", should be fixed (err=" << ret << ")" << dendl;
+      return ret;
+    }
+    user_info.user_email = "";
+  }
 
   // update the remaining user info
   if (!display_name.empty())