Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jewel: rgw: radosgw-admin: inconsistency in uid/email handling #10520

Merged
3 commits merged into from Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/rgw/rgw_user.cc
Expand Up @@ -5,6 +5,7 @@

#include <string>
#include <map>
#include <boost/algorithm/string.hpp>

#include "common/errno.h"
#include "common/Formatter.h"
Expand Down Expand Up @@ -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");
Expand Down
25 changes: 25 additions & 0 deletions src/rgw/rgw_user.h
Expand Up @@ -5,6 +5,8 @@
#define CEPH_RGW_USER_H

#include <string>
#include <boost/algorithm/string.hpp>
#include "include/assert.h"

#include "include/types.h"
#include "rgw_common.h"
Expand Down Expand Up @@ -225,6 +227,7 @@ struct RGWUserAdminOpState {
gen_access = false;
key_op = true;
}

void set_secret_key(std::string& secret_key) {
if (secret_key.empty())
return;
Expand All @@ -234,26 +237,32 @@ struct RGWUserAdminOpState {
gen_secret = false;
key_op = true;
}

void set_user_id(rgw_user& id) {
if (id.empty())
return;

user_id = id;
}

void set_user_email(std::string& email) {
if (email.empty())
return;

/* always lowercase email address */
boost::algorithm::to_lower(email);
user_email = email;
user_email_specified = true;
}

void set_display_name(std::string& name) {
if (name.empty())
return;

display_name = name;
display_name_specified = true;
}

void set_subuser(std::string& _subuser) {
if (_subuser.empty())
return;
Expand All @@ -274,70 +283,86 @@ struct RGWUserAdminOpState {

subuser_specified = true;
}

void set_caps(std::string& _caps) {
if (_caps.empty())
return;

caps = _caps;
caps_specified = true;
}

void set_perm(uint32_t perm) {
perm_mask = perm;
perm_specified = true;
}

void set_op_mask(uint32_t mask) {
op_mask = mask;
op_mask_specified = true;
}

void set_temp_url_key(const string& key, int index) {
temp_url_keys[index] = key;
temp_url_key_specified = true;
}

void set_key_type(int32_t type) {
key_type = type;
type_specified = true;
}

void set_suspension(__u8 is_suspended) {
suspended = is_suspended;
suspension_op = true;
}

void set_system(__u8 is_system) {
system = is_system;
system_specified = true;
}

void set_exclusive(__u8 is_exclusive) {
exclusive = is_exclusive;
}

void set_fetch_stats(__u8 is_fetch_stats) {
fetch_stats = is_fetch_stats;
}

void set_user_info(RGWUserInfo& user_info) {
user_id = user_info.user_id;
info = user_info;
}

void set_max_buckets(uint32_t mb) {
max_buckets = mb;
max_buckets_specified = true;
}

void set_gen_access() {
gen_access = true;
key_op = true;
}

void set_gen_secret() {
gen_secret = true;
key_op = true;
}

void set_generate_key() {
if (id.empty())
gen_access = true;
if (key.empty())
gen_secret = true;
key_op = true;
}

void clear_generate_key() {
gen_access = false;
gen_secret = false;
}

void set_purge_keys() {
purge_keys = true;
key_op = true;
Expand Down