From: Pete Zaitcev Date: Fri, 12 Feb 2016 01:01:06 +0000 (-0700) Subject: rgw: Fix subuser harder with tenants X-Git-Tag: v10.1.0~325^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f88c8522287b0bb4e8eed627f79646a8f7bcf4b5;p=ceph.git rgw: Fix subuser harder with tenants We have several ways to set the tenant and user in the operation state now: radosgw-admin --uid=user # default empty tenant radosgw-admin --tenant=ten --uid=user radosgw-admin --uid='ten$user' radosgw-admin --subuser='ten$user:sub' The previous commit a51fbf2d fixed some of these but broke the others. The root of the difficulty is that rgw_op.set_subuser() has a magical side effect of setting rgw_op.user_id, but the code pretends that it's one of many other setters. Unfortunately, getting rid of the side effect is not easy here. It is exactly what we want for historic compatibility, so killing the magic requires a pile of code elsewhere, or worse, implicit ordering requirements (invoke set_subuser before set_user or else). For now we doubled down on the magic. This way at least it is all in one place and you do not have to flip pages of code to understand what is going on. Signed-off-by: Pete Zaitcev --- diff --git a/src/rgw/rgw_user.h b/src/rgw/rgw_user.h index bff4a52912e8..93af86a3b346 100644 --- a/src/rgw/rgw_user.h +++ b/src/rgw/rgw_user.h @@ -268,7 +268,13 @@ struct RGWUserAdminOpState { size_t pos = _subuser.find(":"); if (pos != string::npos) { - user_id.from_str(_subuser.substr(0, pos)); + rgw_user tmp_id; + tmp_id.from_str(_subuser.substr(0, pos)); + if (tmp_id.tenant.empty()) { + user_id.id = tmp_id.id; + } else { + user_id = tmp_id; + } subuser = _subuser.substr(pos+1); } else { subuser = _subuser;