if (! s->auth.identity->is_admin_of(dest_policy.get_owner().get_id())){
if (dest_iam_policy != boost::none) {
rgw_add_to_iam_environment(s->env, "s3:x-amz-copy-source", copy_source);
- rgw_add_to_iam_environment(s->env, "s3:x-amz-metadata-directive", md_directive);
+ if (md_directive)
+ rgw_add_to_iam_environment(s->env, "s3:x-amz-metadata-directive",
+ *md_directive);
auto e = dest_iam_policy->eval(s->env, *s->auth.identity,
rgw::IAM::s3PutObject,
const char *if_unmod;
const char *if_match;
const char *if_nomatch;
- const char *copy_source = nullptr;
- const char *md_directive = nullptr;
+ // Required or it is not a copy operation
+ std::string_view copy_source;
+ // Not actually required
+ std::optional<std::string_view> md_directive;
off_t ofs;
off_t len;
}
copy_source = s->info.env->get("HTTP_X_AMZ_COPY_SOURCE");
- md_directive = s->info.env->get("HTTP_X_AMZ_METADATA_DIRECTIVE");
- if (md_directive) {
- if (strcasecmp(md_directive, "COPY") == 0) {
+ auto tmp_md_d = s->info.env->get("HTTP_X_AMZ_METADATA_DIRECTIVE");
+ if (tmp_md_d) {
+ if (strcasecmp(tmp_md_d, "COPY") == 0) {
attrs_mod = RGWRados::ATTRSMOD_NONE;
- } else if (strcasecmp(md_directive, "REPLACE") == 0) {
+ } else if (strcasecmp(tmp_md_d, "REPLACE") == 0) {
attrs_mod = RGWRados::ATTRSMOD_REPLACE;
} else if (!source_zone.empty()) {
attrs_mod = RGWRados::ATTRSMOD_NONE; // default for intra-zone_group copy
ldpp_dout(this, 0) << s->err.message << dendl;
return -EINVAL;
}
+ md_directive = tmp_md_d;
}
if (source_zone.empty() &&