From 3e85041a6735230b437a4d5b2d66030951db55d8 Mon Sep 17 00:00:00 2001 From: Ray Lv Date: Wed, 11 Jun 2014 22:13:23 +0800 Subject: [PATCH] rgw: admin ops create user API can not determine existing user Fixes: #8583 Signed-off-by: Ray Lv --- src/rgw/rgw_rest_user.cc | 5 +++++ src/rgw/rgw_user.cc | 3 ++- src/rgw/rgw_user.h | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_rest_user.cc b/src/rgw/rgw_rest_user.cc index 3d08e40322955..580cd7f17e756 100644 --- a/src/rgw/rgw_rest_user.cc +++ b/src/rgw/rgw_rest_user.cc @@ -60,6 +60,7 @@ void RGWOp_User_Create::execute() bool gen_key; bool suspended; bool system; + bool exclusive; uint32_t max_buckets; int32_t key_type = KEY_TYPE_UNDEFINED; @@ -77,6 +78,7 @@ void RGWOp_User_Create::execute() RESTArgs::get_bool(s, "suspended", false, &suspended); RESTArgs::get_uint32(s, "max-buckets", RGW_DEFAULT_MAX_BUCKETS, &max_buckets); RESTArgs::get_bool(s, "system", false, &system); + RESTArgs::get_bool(s, "exclusive", false, &exclusive); if (!s->user.system && system) { ldout(s->cct, 0) << "cannot set system flag by non-system user" << dendl; @@ -121,6 +123,9 @@ void RGWOp_User_Create::execute() if (s->info.args.exists("system")) op_state.set_system(system); + if (s->info.args.exists("exclusive")) + op_state.set_exclusive(exclusive); + if (gen_key) op_state.set_generate_key(); diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index de220e0055205..2b170d13c5ad8 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -1639,7 +1639,8 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg) // fail if the user exists already if (op_state.has_existing_user()) { - if ((user_email.empty() || old_info.user_email == user_email) && + if (!op_state.exclusive && + (user_email.empty() || old_info.user_email == user_email) && old_info.display_name == display_name) { return execute_modify(op_state, err_msg); } diff --git a/src/rgw/rgw_user.h b/src/rgw/rgw_user.h index 2f4b328ef0c7d..c697857317f0c 100644 --- a/src/rgw/rgw_user.h +++ b/src/rgw/rgw_user.h @@ -128,6 +128,7 @@ struct RGWUserAdminOpState { uint32_t max_buckets; __u8 suspended; __u8 system; + __u8 exclusive; std::string caps; RGWObjVersionTracker objv; uint32_t op_mask; @@ -263,6 +264,9 @@ struct RGWUserAdminOpState { system = is_system; system_specified = true; } + void set_exclusive(__u8 is_exclusive) { + exclusive = is_exclusive; + } void set_user_info(RGWUserInfo& user_info) { user_id = user_info.user_id; info = user_info; @@ -394,6 +398,7 @@ struct RGWUserAdminOpState { perm_mask = 0; suspended = 0; system = 0; + exclusive = 0; op_mask = 0; existing_user = false; -- 2.39.5