From 7e353df85acbffe432a21ea063e93b6bc8e35637 Mon Sep 17 00:00:00 2001 From: Shilpa Jagannath Date: Wed, 3 Jul 2019 16:36:52 +0530 Subject: [PATCH] rgw: Fail radosgw-admin commands on non-master zone that modify metadata but with an option to override, allowing changes only on the local zone. Fixes: http://tracker.ceph.com/issues/39548 Signed-off-by: Shilpa Jagannath (cherry picked from commit 79d884eb018cd2fea9ee9e763d0339b3e8626e6d) --- src/rgw/rgw_admin.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 3a8c84d199857..80a583acb78ae 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -4989,6 +4989,12 @@ int main(int argc, const char **argv) } break; case OPT_USER_CREATE: + if (!store->svc.zone->is_meta_master() && !yes_i_really_mean_it) { + cerr << "user created here will not be synced to master zone" << std::endl; + cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; + return EINVAL; + } + if (!user_op.has_existing_user()) { user_op.set_generate_key(); // generate a new key by default } @@ -5009,6 +5015,11 @@ int main(int argc, const char **argv) } break; case OPT_USER_RM: + if (!store->svc.zone->is_meta_master() && !yes_i_really_mean_it) { + cerr << "user delete operation will not be synced to master zone" << std::endl; + cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; + return EINVAL; + } ret = user.remove(user_op, &err_msg); if (ret < 0) { cerr << "could not remove user: " << err_msg << std::endl; @@ -5020,6 +5031,11 @@ int main(int argc, const char **argv) case OPT_USER_ENABLE: case OPT_USER_SUSPEND: case OPT_USER_MODIFY: + if (!store->svc.zone->is_meta_master() && !yes_i_really_mean_it) { + cerr << "user modify operation will not be synced to master zone" << std::endl; + cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; + return EINVAL; + } ret = user.modify(user_op, &err_msg); if (ret < 0) { cerr << "could not modify user: " << err_msg << std::endl; @@ -5498,6 +5514,11 @@ int main(int argc, const char **argv) } if (opt_cmd == OPT_BUCKET_LINK) { + if (!store->svc.zone->is_meta_master() && !yes_i_really_mean_it) { + cerr << "link operation will not be synced to master zone" << std::endl; + cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; + return EINVAL; + } bucket_op.set_bucket_id(bucket_id); string err; int r = RGWBucketAdminOp::link(store, bucket_op, &err); @@ -5508,6 +5529,11 @@ int main(int argc, const char **argv) } if (opt_cmd == OPT_BUCKET_UNLINK) { + if (!store->svc.zone->is_meta_master() && !yes_i_really_mean_it) { + cerr << "unlink operation will not be synced to master zone" << std::endl; + cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; + return EINVAL; + } int r = RGWBucketAdminOp::unlink(store, bucket_op); if (r < 0) { cerr << "failure: " << cpp_strerror(-r) << std::endl; @@ -6212,6 +6238,11 @@ next: } if (opt_cmd == OPT_BUCKET_RESHARD) { + if (!store->svc.zone->is_meta_master() && !yes_i_really_mean_it) { + cerr << "resharding only applies to the local zone and will not be synced to master" << std::endl; + cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; + return EINVAL; + } rgw_bucket bucket; RGWBucketInfo bucket_info; map attrs; @@ -6398,6 +6429,11 @@ next: } if (opt_cmd == OPT_OBJECT_UNLINK) { + if (!store->svc.zone->is_meta_master() && !yes_i_really_mean_it) { + cerr << "unlink operation will not be synced to master zone" << std::endl; + cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; + return EINVAL; + } RGWBucketInfo bucket_info; int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket); if (ret < 0) { @@ -6489,6 +6525,11 @@ next: } if (opt_cmd == OPT_BUCKET_RM) { + if (!store->svc.zone->is_meta_master() && !yes_i_really_mean_it) { + cerr << "bucket remove operation will not be synced to master zone" << std::endl; + cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl; + return EINVAL; + } if (!inconsistent_index) { RGWBucketAdminOp::remove_bucket(store, bucket_op, bypass_gc, true); } else { -- 2.39.5