]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Fix subuser harder with tenants 7618/head
authorPete Zaitcev <zaitcev@kotori.zaitcev.us>
Fri, 12 Feb 2016 01:01:06 +0000 (18:01 -0700)
committerPete Zaitcev <zaitcev@kotori.zaitcev.us>
Fri, 12 Feb 2016 01:01:06 +0000 (18:01 -0700)
We have several ways to set the tenant and user in the operation
state now:

radosgw-admin --uid=user <command>  # default empty tenant
radosgw-admin --tenant=ten --uid=user <command>
radosgw-admin --uid='ten$user' <command>
radosgw-admin --subuser='ten$user:sub' <command>

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 <zaitcev@redhat.com>
src/rgw/rgw_user.h

index bff4a52912e8172eefde432a5d056716bdf9c338..93af86a3b346d38d697695aed6922b761879c213 100644 (file)
@@ -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;