From: Soumya Koduri Date: Fri, 14 Jul 2023 05:38:18 +0000 (+0530) Subject: rgw/sync-policy: Do not allow empty group names X-Git-Tag: v18.2.1~252^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a0a6788f5b1eca69b75063efec8ac31f3eb17d64;p=ceph.git rgw/sync-policy: Do not allow empty group names Fixes: https://tracker.ceph.com/issues/62015 Signed-off-by: Soumya Koduri (cherry picked from commit fa5759922f28f5cd638744117d233a1f51250628) --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 6a181c954d4b..f2c6cfef16ef 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -9517,7 +9517,7 @@ next: if (opt_cmd == OPT::SYNC_GROUP_CREATE || opt_cmd == OPT::SYNC_GROUP_MODIFY) { - CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); CHECK_TRUE(require_opt(opt_status), "ERROR: --status is not specified (options: forbidden, allowed, enabled)", EINVAL); SyncPolicyContext sync_policy_ctx(cfgstore.get(), opt_bucket); @@ -9577,7 +9577,7 @@ next: } if (opt_cmd == OPT::SYNC_GROUP_REMOVE) { - CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); SyncPolicyContext sync_policy_ctx(cfgstore.get(), opt_bucket); ret = sync_policy_ctx.init(zonegroup_id, zonegroup_name); @@ -9602,8 +9602,8 @@ next: } if (opt_cmd == OPT::SYNC_GROUP_FLOW_CREATE) { - CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); - CHECK_TRUE(require_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL); CHECK_TRUE(require_opt(opt_flow_type), "ERROR: --flow-type not specified (options: symmetrical, directional)", EINVAL); CHECK_TRUE((symmetrical_flow_opt(*opt_flow_type) || @@ -9653,8 +9653,8 @@ next: } if (opt_cmd == OPT::SYNC_GROUP_FLOW_REMOVE) { - CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); - CHECK_TRUE(require_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL); CHECK_TRUE(require_opt(opt_flow_type), "ERROR: --flow-type not specified (options: symmetrical, directional)", EINVAL); CHECK_TRUE((symmetrical_flow_opt(*opt_flow_type) || @@ -9695,8 +9695,8 @@ next: if (opt_cmd == OPT::SYNC_GROUP_PIPE_CREATE || opt_cmd == OPT::SYNC_GROUP_PIPE_MODIFY) { - CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); - CHECK_TRUE(require_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL); if (opt_cmd == OPT::SYNC_GROUP_PIPE_CREATE) { CHECK_TRUE(require_non_empty_opt(opt_source_zone_ids), "ERROR: --source-zones not provided or is empty; should be list of zones or '*'", EINVAL); CHECK_TRUE(require_non_empty_opt(opt_dest_zone_ids), "ERROR: --dest-zones not provided or is empty; should be list of zones or '*'", EINVAL); @@ -9781,8 +9781,8 @@ next: } if (opt_cmd == OPT::SYNC_GROUP_PIPE_REMOVE) { - CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); - CHECK_TRUE(require_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); + CHECK_TRUE(require_non_empty_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL); SyncPolicyContext sync_policy_ctx(cfgstore.get(), opt_bucket); ret = sync_policy_ctx.init(zonegroup_id, zonegroup_name);