]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add rename_swift_keys for user rename 29540/head
authorCasey Bodley <cbodley@redhat.com>
Wed, 7 Aug 2019 14:09:29 +0000 (10:09 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 7 Aug 2019 20:25:12 +0000 (16:25 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_user.cc

index 480dafc05073b77f4269e8c7151b12f2f82daad7..2efd31e76124d05f2cad1af8e99de89ac1a50926 100644 (file)
@@ -1936,6 +1936,21 @@ int RGWUser::check_op(RGWUserAdminOpState& op_state, std::string *err_msg)
   return 0;
 }
 
+// update swift_keys with new user id
+static void rename_swift_keys(const rgw_user& user,
+                              std::map<std::string, RGWAccessKey>& keys)
+{
+  std::string user_id;
+  user.to_str(user_id);
+
+  auto modify_keys = std::move(keys);
+  for (auto& [k, key] : modify_keys) {
+    std::string id = user_id + ":" + key.subuser;
+    key.id = id;
+    keys[id] = std::move(key);
+  }
+}
+
 int RGWUser::execute_rename(RGWUserAdminOpState& op_state, std::string *err_msg)
 {
   int ret;
@@ -2063,9 +2078,12 @@ int RGWUser::execute_rename(RGWUserAdminOpState& op_state, std::string *err_msg)
 
   // update the 'stub user' with all of the other fields and rewrite all of the
   // associated index objects
-  op_state.get_user_info().user_id = uid;
+  RGWUserInfo& user_info = op_state.get_user_info();
+  user_info.user_id = uid;
   op_state.objv = objv;
 
+  rename_swift_keys(uid, user_info.swift_keys);
+
   return update(op_state, err_msg);
 }