Skip to content

Commit da3545d

Browse files
author
Shilpa Jagannath
committed
rgw/multisite: forwarded bucket create requests reflect empty tenants as they
are requested by system user. this fix overloads SysReqApplier::get_tenant() with effective_owner's tenant to ensure proper bucket ownership when there is tenant involved. Signed-off-by: Shilpa Jagannath <[email protected]>
1 parent f781c5c commit da3545d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

qa/suites/rgw/multisite/tasks/test_multi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ tasks:
1515
- rgw-multisite-tests:
1616
config:
1717
reconfigure_delay: 90
18+
tenant: testx

src/rgw/rgw_auth_filters.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class SysReqApplier : public DecoratedApplier<T> {
238238
const RGWHTTPArgs& args;
239239
mutable boost::tribool is_system;
240240
mutable std::optional<ACLOwner> effective_owner;
241+
mutable std::optional<std::string> effective_tenant;
241242

242243
public:
243244
template <typename U>
@@ -262,6 +263,14 @@ class SysReqApplier : public DecoratedApplier<T> {
262263
}
263264
return DecoratedApplier<T>::get_aclowner();
264265
}
266+
267+
const std::string& get_tenant() const override {
268+
if (effective_tenant) {
269+
return *effective_tenant;
270+
}
271+
return DecoratedApplier<T>::get_tenant();
272+
}
273+
265274
};
266275

267276
template <typename T>
@@ -287,6 +296,7 @@ auto SysReqApplier<T>::load_acct_info(const DoutPrefixProvider* dpp) const -> st
287296
std::string str = args.sys_get(RGW_SYS_PARAM_PREFIX "uid");
288297
if (!str.empty()) {
289298
effective_owner.emplace();
299+
290300
effective_owner->id = parse_owner(str);
291301

292302
if (const auto* uid = std::get_if<rgw_user>(&effective_owner->id); uid) {
@@ -296,7 +306,17 @@ auto SysReqApplier<T>::load_acct_info(const DoutPrefixProvider* dpp) const -> st
296306
throw -EACCES;
297307
}
298308
effective_owner->display_name = user->get_display_name();
299-
}
309+
effective_tenant = uid->tenant;
310+
} else if (const auto* id = std::get_if<rgw_account_id>(&effective_owner->id); id) {
311+
RGWAccountInfo info;
312+
rgw::sal::Attrs attrs;
313+
RGWObjVersionTracker objv;
314+
int r = driver->load_account_by_id(dpp, null_yield, *id, info, attrs, objv);
315+
if (r < 0) {
316+
throw -EACCES;
317+
}
318+
effective_tenant = info.tenant;
319+
}
300320
}
301321
}
302322
return user;

0 commit comments

Comments
 (0)