From 2629d513929ce57d01c909a8461444e06e8f55ed Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Mon, 12 Mar 2018 14:14:22 +0100 Subject: [PATCH] rgw: radosgw-admin abort early for user stats for empty uids Otherwise we'll call sync stats with an empty argument which results in creation of an empty ".buckets" object Fixes: http://tracker.ceph.com/issues/23322 Signed-off-by: Abhishek Lekshmanan (cherry picked from commit aa3a408d4a66296cbf273551920f8ac9b381b2dd) (cherry picked from commit 99dec6115bb6d8ef1cdaf658fc359a301d31017d) --- src/rgw/rgw_admin.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index d05ebe239c7f9..83427fe09f4a4 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -6056,6 +6056,11 @@ next: } if (opt_cmd == OPT_USER_STATS) { + if (user_id.empty()) { + cerr << "ERROR: uid not specified" << std::endl; + return EINVAL; + } + if (sync_stats) { if (!bucket_name.empty()) { int ret = rgw_bucket_sync_user_stats(store, tenant, bucket_name); @@ -6072,10 +6077,6 @@ next: } } - if (user_id.empty()) { - cerr << "ERROR: uid not specified" << std::endl; - return EINVAL; - } cls_user_header header; string user_str = user_id.to_str(); int ret = store->cls_user_get_header(user_str, &header); -- 2.39.5