From 772fbbbafcdd1d26ff95ef005211f2200b724741 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 3 Sep 2025 09:27:18 -0400 Subject: [PATCH] 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 --- src/rgw/radosgw-admin/radosgw-admin.cc | 4 ++-- src/rgw/rgw_account.cc | 5 ++++- src/rgw/rgw_account.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rgw/radosgw-admin/radosgw-admin.cc b/src/rgw/radosgw-admin/radosgw-admin.cc index 377665ef5b344..6713935b5dabb 100644 --- a/src/rgw/radosgw-admin/radosgw-admin.cc +++ b/src/rgw/radosgw-admin/radosgw-admin.cc @@ -9742,8 +9742,8 @@ next: std::string err_msg; int ret = rgw::account::list_users( dpp(), driver, op_state, path_prefix, marker, - max_entries_specified, max_entries, err_msg, - stream_flusher, null_yield); + max_entries_specified, max_entries, account_root, + err_msg, stream_flusher, null_yield); if (ret < 0) { cerr << "ERROR: " << err_msg << std::endl; return -ret; diff --git a/src/rgw/rgw_account.cc b/src/rgw/rgw_account.cc index fd9c479337ce0..5b9e54bbd02dc 100644 --- a/src/rgw/rgw_account.cc +++ b/src/rgw/rgw_account.cc @@ -487,7 +487,7 @@ int stats(const DoutPrefixProvider* dpp, int list_users(const DoutPrefixProvider* dpp, rgw::sal::Driver* driver, AdminOpState& op_state, const std::string& path_prefix, const std::string& marker, bool max_entries_specified, - int max_entries, std::string& err_msg, + int max_entries, bool root_only, std::string& err_msg, RGWFormatterFlusher& flusher, optional_yield y) { int ret = 0; @@ -541,6 +541,9 @@ int list_users(const DoutPrefixProvider* dpp, rgw::sal::Driver* driver, } for (const auto& user : listing.users) { + if (root_only && user.type != TYPE_ROOT) { + continue; // skip non-root users if requested + } encode_json("key", user.user_id, formatter); } flusher.flush(); diff --git a/src/rgw/rgw_account.h b/src/rgw/rgw_account.h index d3c9055f10143..9ebd81c100a1e 100644 --- a/src/rgw/rgw_account.h +++ b/src/rgw/rgw_account.h @@ -86,7 +86,7 @@ int stats(const DoutPrefixProvider* dpp, rgw::sal::Driver* driver, int list_users(const DoutPrefixProvider* dpp, rgw::sal::Driver* driver, AdminOpState& op_state, const std::string& path_prefix, const std::string& marker, bool max_entries_specified, - int max_entries, std::string& err_msg, + int max_entries, bool root_only, std::string& err_msg, RGWFormatterFlusher& flusher, optional_yield y); } // namespace rgw::account -- 2.39.5