From 67e98eb413bdb18a3bcd6565d9926c0662d24354 Mon Sep 17 00:00:00 2001 From: Shilpa Jagannath Date: Tue, 30 Jul 2019 13:44:26 +0530 Subject: [PATCH] On new uid check, return EEXIST. Signed-off-by: Shilpa Jagannath --- src/rgw/rgw_user.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 960246ab096b7..59664fb806116 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -1962,8 +1962,17 @@ int RGWUser::execute_user_rename(RGWUserAdminOpState& op_state, std::string *err rgw_user& uid = op_state.get_new_uid(); + RGWUserInfo existing_uinfo; + if (!uid.empty()) { + ret = rgw_get_user_info_by_uid(store, uid, existing_uinfo); + if (ret >= 0) { + set_err_msg(err_msg, "user name given by --new-uid already exists"); + return -EEXIST; + } + } + if (old_uid.tenant != uid.tenant) { - set_err_msg(err_msg, "Users have to be under the same tenant namespace " + set_err_msg(err_msg, "users have to be under the same tenant namespace" + old_uid.tenant + "!=" + uid.tenant); return -EINVAL; } -- 2.39.5