mirror of
https://github.com/ceph/ceph
synced 2025-03-06 08:20:12 +00:00
rgw: check for subuser existence
This fixes #1856: looking up subuser that doesn't exist returns user as long as subuser prefix defined existing user. Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
This commit is contained in:
parent
e792cd9388
commit
addc744692
@ -732,20 +732,30 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
bool subuser_found = false;
|
||||
|
||||
if (!subuser.empty()) {
|
||||
map<string, RGWSubUser>::iterator iter = info.subusers.find(subuser);
|
||||
subuser_found = (iter != info.subusers.end());
|
||||
|
||||
if (!subuser_found && opt_cmd != OPT_SUBUSER_CREATE) {
|
||||
cerr << "subuser specified but was not found, aborting" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_cmd == OPT_SUBUSER_CREATE || opt_cmd == OPT_SUBUSER_MODIFY ||
|
||||
opt_cmd == OPT_SUBUSER_RM) {
|
||||
if (subuser.empty()) {
|
||||
cerr << "subuser creation was requires specifying subuser name" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
map<string, RGWSubUser>::iterator iter = info.subusers.find(subuser);
|
||||
bool found = (iter != info.subusers.end());
|
||||
if (opt_cmd == OPT_SUBUSER_CREATE) {
|
||||
if (found) {
|
||||
if (subuser_found) {
|
||||
cerr << "error: subuser already exists" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
} else if (!found) {
|
||||
} else if (!subuser_found) {
|
||||
cerr << "error: subuser doesn't exist" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user