From: wangzhong Date: Tue, 27 Jul 2021 09:52:44 +0000 (-0700) Subject: rgw: add the condition of lock mode conversion to PutObjRentention X-Git-Tag: v17.1.0~1190^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F42505%2Fhead;p=ceph.git rgw: add the condition of lock mode conversion to PutObjRentention Signed-off-by: wangzhong --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 25b2afa4435f5..7f885a95c90e5 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -8255,10 +8255,20 @@ void RGWPutObjRetention::execute(optional_yield y) } if (ceph::real_clock::to_time_t(obj_retention.get_retain_until_date()) < ceph::real_clock::to_time_t(old_obj_retention.get_retain_until_date())) { if (old_obj_retention.get_mode().compare("GOVERNANCE") != 0 || !bypass_perm || !bypass_governance_mode) { - s->err.message = "proposed retain-until date shortens an existing retention period and governance bypass check failed"; + s->err.message = "proposed retain-until date shortens an existing retention period and governance bypass check failed"; op_ret = -EACCES; return; } + } else if (old_obj_retention.get_mode() == obj_retention.get_mode()) { + // ok if retention mode doesn't change + } else if (obj_retention.get_mode() == "GOVERNANCE") { + s->err.message = "can't change retention mode from COMPLIANCE to GOVERNANCE"; + op_ret = -EACCES; + return; + } else if (!bypass_perm || !bypass_governance_mode) { + s->err.message = "can't change retention mode from GOVERNANCE without governance bypass"; + op_ret = -EACCES; + return; } }