From ebfd713d9a40e1cb33dfdf2198c20d621e387e36 Mon Sep 17 00:00:00 2001 From: Weijun Duan Date: Sat, 27 Feb 2016 04:28:14 -0500 Subject: [PATCH] rgw:user email can modify to empty Fixes: http://tracker.ceph.com/issues/13286 Signed-off-by: Weijun Duan --- src/rgw/rgw_admin.cc | 1 + src/rgw/rgw_user.cc | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index a7a732f22f1..0ba2f2bab19 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2105,6 +2105,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)) { diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index d4104c45b24..23f9e73d65c 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -2150,8 +2150,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()) -- 2.39.5