Skip to content

Commit 772fbbb

Browse files
committed
rgw/admin: allow listing account's root users
`radosgw-admin user list`, when given `--account-id` or `--account-name`, lists only the users from that account add support for the `--account-root` option to list only that account's root users Fixes: https://tracker.ceph.com/issues/72847 Signed-off-by: Casey Bodley <[email protected]>
1 parent 6a69922 commit 772fbbb

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/rgw/radosgw-admin/radosgw-admin.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9742,8 +9742,8 @@ int main(int argc, const char **argv)
97429742
std::string err_msg;
97439743
int ret = rgw::account::list_users(
97449744
dpp(), driver, op_state, path_prefix, marker,
9745-
max_entries_specified, max_entries, err_msg,
9746-
stream_flusher, null_yield);
9745+
max_entries_specified, max_entries, account_root,
9746+
err_msg, stream_flusher, null_yield);
97479747
if (ret < 0) {
97489748
cerr << "ERROR: " << err_msg << std::endl;
97499749
return -ret;

src/rgw/rgw_account.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ int stats(const DoutPrefixProvider* dpp,
487487
int list_users(const DoutPrefixProvider* dpp, rgw::sal::Driver* driver,
488488
AdminOpState& op_state, const std::string& path_prefix,
489489
const std::string& marker, bool max_entries_specified,
490-
int max_entries, std::string& err_msg,
490+
int max_entries, bool root_only, std::string& err_msg,
491491
RGWFormatterFlusher& flusher, optional_yield y)
492492
{
493493
int ret = 0;
@@ -541,6 +541,9 @@ int list_users(const DoutPrefixProvider* dpp, rgw::sal::Driver* driver,
541541
}
542542

543543
for (const auto& user : listing.users) {
544+
if (root_only && user.type != TYPE_ROOT) {
545+
continue; // skip non-root users if requested
546+
}
544547
encode_json("key", user.user_id, formatter);
545548
}
546549
flusher.flush();

src/rgw/rgw_account.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int stats(const DoutPrefixProvider* dpp, rgw::sal::Driver* driver,
8686
int list_users(const DoutPrefixProvider* dpp, rgw::sal::Driver* driver,
8787
AdminOpState& op_state, const std::string& path_prefix,
8888
const std::string& marker, bool max_entries_specified,
89-
int max_entries, std::string& err_msg,
89+
int max_entries, bool root_only, std::string& err_msg,
9090
RGWFormatterFlusher& flusher, optional_yield y);
9191

9292
} // namespace rgw::account

0 commit comments

Comments
 (0)