1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * All operations via the rados gateway are carried out by
6 * small classes known as RGWOps. This class contains a req_state
7 * and each possible command is a subclass of this with a defined
8 * execute() method that does whatever the subclass name implies.
9 * These subclasses must be further subclassed (by interface type)
10 * to provide additional virtual methods such as send_response or get_params.
25 #include <boost/optional.hpp>
26 #include <boost/utility/in_place_factory.hpp>
27 #include <boost/function.hpp>
28 #include <boost/container/flat_map.hpp>
30 #include "common/armor.h"
31 #include "common/mime.h"
32 #include "common/utf8.h"
33 #include "common/ceph_json.h"
34 #include "common/ceph_time.h"
36 #include "rgw_common.h"
37 #include "rgw_dmclock.h"
40 #include "rgw_bucket.h"
43 #include "rgw_quota.h"
44 #include "rgw_putobj.h"
45 #include "rgw_multi.h"
49 #include "rgw_torrent.h"
51 #include "rgw_object_lock.h"
52 #include "cls/rgw/cls_rgw_client.h"
53 #include "rgw_public_access.h"
55 #include "services/svc_sys_obj.h"
56 #include "services/svc_tier_rados.h"
58 #include "include/ceph_assert.h"
60 using ceph::crypto::SHA1
;
71 class StrategyRegistry
;
77 int rgw_op_get_bucket_policy_from_attr(const DoutPrefixProvider
*dpp
,
79 rgw::sal::RGWStore
*store
,
80 RGWBucketInfo
& bucket_info
,
81 map
<string
, bufferlist
>& bucket_attrs
,
82 RGWAccessControlPolicy
*policy
,
87 rgw::sal::RGWRadosStore
* store
{nullptr};
88 struct req_state
*s
{nullptr};
90 int do_init_permissions(const DoutPrefixProvider
*dpp
, optional_yield y
);
91 int do_read_permissions(RGWOp
* op
, bool only_bucket
, optional_yield y
);
95 virtual ~RGWHandler();
97 virtual int init(rgw::sal::RGWRadosStore
* store
,
99 rgw::io::BasicClient
* cio
);
101 virtual int init_permissions(RGWOp
*, optional_yield y
) {
105 virtual int retarget(RGWOp
* op
, RGWOp
** new_op
, optional_yield
) {
110 virtual int read_permissions(RGWOp
* op
, optional_yield y
) = 0;
111 virtual int authorize(const DoutPrefixProvider
* dpp
, optional_yield y
) = 0;
112 virtual int postauth_init(optional_yield y
) = 0;
113 virtual int error_handler(int err_no
, std::string
* error_content
, optional_yield y
);
114 virtual void dump(const string
& code
, const string
& message
) const {}
116 virtual bool supports_quota() {
123 void rgw_bucket_object_pre_exec(struct req_state
*s
);
125 namespace dmc
= rgw::dmclock
;
128 * Provide the base class for all ops.
130 class RGWOp
: public DoutPrefixProvider
{
133 RGWHandler
*dialect_handler
;
134 rgw::sal::RGWRadosStore
*store
;
135 RGWCORSConfiguration bucket_cors
;
137 RGWQuotaInfo bucket_quota
;
138 RGWQuotaInfo user_quota
;
140 int do_aws4_auth_completion();
142 virtual int init_quota();
147 dialect_handler(nullptr),
153 virtual ~RGWOp() = default;
155 int get_ret() const { return op_ret
; }
157 virtual int init_processing(optional_yield y
) {
158 if (dialect_handler
->supports_quota()) {
159 op_ret
= init_quota();
167 virtual void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*dialect_handler
) {
170 this->dialect_handler
= dialect_handler
;
172 int read_bucket_cors();
173 bool generate_cors_headers(string
& origin
, string
& method
, string
& headers
, string
& exp_headers
, unsigned *max_age
);
175 virtual int verify_params() { return 0; }
176 virtual bool prefetch_data() { return false; }
178 /* Authenticate requester -- verify its identity.
180 * NOTE: typically the procedure is common across all operations of the same
181 * dialect (S3, Swift API). However, there are significant exceptions in
182 * both APIs: browser uploads, /info and OPTIONS handlers. All of them use
183 * different, specific authentication schema driving the need for per-op
184 * authentication. The alternative is to duplicate parts of the method-
185 * dispatch logic in RGWHandler::authorize() and pollute it with a lot
186 * of special cases. */
187 virtual int verify_requester(const rgw::auth::StrategyRegistry
& auth_registry
, optional_yield y
) {
188 /* TODO(rzarzynski): rename RGWHandler::authorize to generic_authenticate. */
189 return dialect_handler
->authorize(this, y
);
191 virtual int verify_permission(optional_yield y
) = 0;
192 virtual int verify_op_mask();
193 virtual void pre_exec() {}
194 virtual void execute(optional_yield y
) = 0;
195 virtual void send_response() {}
196 virtual void complete() {
199 virtual const char* name() const = 0;
200 virtual RGWOpType
get_type() { return RGW_OP_UNKNOWN
; }
202 virtual uint32_t op_mask() { return 0; }
204 virtual int error_handler(int err_no
, string
*error_content
, optional_yield y
);
206 // implements DoutPrefixProvider
207 std::ostream
& gen_prefix(std::ostream
& out
) const override
;
208 CephContext
* get_cct() const override
{ return s
->cct
; }
209 unsigned get_subsys() const override
{ return ceph_subsys_rgw
; }
211 virtual dmc::client_id
dmclock_client() { return dmc::client_id::metadata
; }
212 virtual dmc::Cost
dmclock_cost() { return 1; }
215 class RGWDefaultResponseOp
: public RGWOp
{
217 void send_response() override
;
220 class RGWGetObj_Filter
: public RGWGetDataCB
223 RGWGetObj_Filter
*next
{nullptr};
225 RGWGetObj_Filter() {}
226 explicit RGWGetObj_Filter(RGWGetObj_Filter
*next
): next(next
) {}
227 ~RGWGetObj_Filter() override
{}
229 * Passes data through filter.
230 * Filter can modify content of bl.
231 * When bl_len == 0 , it means 'flush
233 int handle_data(bufferlist
& bl
, off_t bl_ofs
, off_t bl_len
) override
{
235 return next
->handle_data(bl
, bl_ofs
, bl_len
);
240 * Flushes any cached data. Used by RGWGetObjFilter.
241 * Return logic same as handle_data.
243 virtual int flush() {
245 return next
->flush();
250 * Allows filter to extend range required for successful filtering
252 virtual int fixup_range(off_t
& ofs
, off_t
& end
) {
254 return next
->fixup_range(ofs
, end
);
260 class RGWGetObj
: public RGWOp
{
262 seed torrent
; // get torrent
263 const char *range_str
;
265 const char *if_unmod
;
266 const char *if_match
;
267 const char *if_nomatch
;
268 uint32_t mod_zone_id
;
274 ceph::real_time mod_time
;
275 ceph::real_time lastmod
;
276 ceph::real_time unmod_time
;
277 ceph::real_time
*mod_ptr
;
278 ceph::real_time
*unmod_ptr
;
279 rgw::sal::RGWAttrs attrs
;
281 bool partial_content
;
282 bool ignore_invalid_range
;
285 bool skip_decrypt
{false};
286 utime_t gc_invalidate_time
;
289 bool rgwx_stat
; /* extended rgw stat operation */
293 RGWCompressionInfo cs_info
;
294 off_t first_block
, last_block
;
321 partial_content
= false;
322 range_parsed
= false;
323 skip_manifest
= false;
331 get_retention
= false;
332 get_legal_hold
= false;
335 bool prefetch_data() override
;
337 void set_get_data(bool get_data
) {
338 this->get_data
= get_data
;
341 int verify_permission(optional_yield y
) override
;
342 void pre_exec() override
;
343 void execute(optional_yield y
) override
;
345 int read_user_manifest_part(
346 rgw::sal::RGWBucket
* bucket
,
347 const rgw_bucket_dir_entry
& ent
,
348 RGWAccessControlPolicy
* const bucket_acl
,
349 const boost::optional
<rgw::IAM::Policy
>& bucket_policy
,
350 const off_t start_ofs
,
353 int handle_user_manifest(const char *prefix
, optional_yield y
);
354 int handle_slo_manifest(bufferlist
& bl
, optional_yield y
);
356 int get_data_cb(bufferlist
& bl
, off_t ofs
, off_t len
);
358 virtual int get_params(optional_yield y
) = 0;
359 virtual int send_response_data_error(optional_yield y
) = 0;
360 virtual int send_response_data(bufferlist
& bl
, off_t ofs
, off_t len
) = 0;
362 const char* name() const override
{ return "get_obj"; }
363 RGWOpType
get_type() override
{ return RGW_OP_GET_OBJ
; }
364 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
365 virtual bool need_object_expiration() { return false; }
367 * calculates filter used to decrypt RGW objects data
369 virtual int get_decrypt_filter(std::unique_ptr
<RGWGetObj_Filter
>* filter
, RGWGetObj_Filter
* cb
, bufferlist
* manifest_bl
) {
373 dmc::client_id
dmclock_client() override
{ return dmc::client_id::data
; }
376 class RGWGetObj_CB
: public RGWGetObj_Filter
380 explicit RGWGetObj_CB(RGWGetObj
*_op
) : op(_op
) {}
381 ~RGWGetObj_CB() override
{}
383 int handle_data(bufferlist
& bl
, off_t bl_ofs
, off_t bl_len
) override
{
384 return op
->get_data_cb(bl
, bl_ofs
, bl_len
);
388 class RGWGetObjTags
: public RGWOp
{
391 bool has_tags
{false};
393 int verify_permission(optional_yield y
) override
;
394 void execute(optional_yield y
) override
;
395 void pre_exec() override
;
397 virtual void send_response_data(bufferlist
& bl
) = 0;
398 const char* name() const override
{ return "get_obj_tags"; }
399 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
400 RGWOpType
get_type() override
{ return RGW_OP_GET_OBJ_TAGGING
; }
404 class RGWPutObjTags
: public RGWOp
{
408 int verify_permission(optional_yield y
) override
;
409 void execute(optional_yield y
) override
;
411 virtual void send_response() override
= 0;
412 virtual int get_params(optional_yield y
) = 0;
413 const char* name() const override
{ return "put_obj_tags"; }
414 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
415 RGWOpType
get_type() override
{ return RGW_OP_PUT_OBJ_TAGGING
; }
419 class RGWDeleteObjTags
: public RGWOp
{
421 void pre_exec() override
;
422 int verify_permission(optional_yield y
) override
;
423 void execute(optional_yield y
) override
;
425 const char* name() const override
{ return "delete_obj_tags"; }
426 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
427 RGWOpType
get_type() override
{ return RGW_OP_DELETE_OBJ_TAGGING
;}
430 class RGWGetBucketTags
: public RGWOp
{
433 bool has_tags
{false};
435 int verify_permission(optional_yield y
) override
;
436 void execute(optional_yield y
) override
;
437 void pre_exec() override
;
439 virtual void send_response_data(bufferlist
& bl
) = 0;
440 const char* name() const override
{ return "get_bucket_tags"; }
441 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
442 RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_TAGGING
; }
445 class RGWPutBucketTags
: public RGWOp
{
450 int verify_permission(optional_yield y
) override
;
451 void execute(optional_yield y
) override
;
453 virtual void send_response() override
= 0;
454 virtual int get_params(const DoutPrefixProvider
*dpp
, optional_yield y
) = 0;
455 const char* name() const override
{ return "put_bucket_tags"; }
456 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
457 RGWOpType
get_type() override
{ return RGW_OP_PUT_BUCKET_TAGGING
; }
460 class RGWDeleteBucketTags
: public RGWOp
{
462 void pre_exec() override
;
463 int verify_permission(optional_yield y
) override
;
464 void execute(optional_yield y
) override
;
466 const char* name() const override
{ return "delete_bucket_tags"; }
467 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
468 RGWOpType
get_type() override
{ return RGW_OP_DELETE_BUCKET_TAGGING
;}
471 struct rgw_sync_policy_group
;
473 class RGWGetBucketReplication
: public RGWOp
{
475 int verify_permission(optional_yield y
) override
;
476 void execute(optional_yield y
) override
;
477 void pre_exec() override
;
479 virtual void send_response_data() = 0;
480 const char* name() const override
{ return "get_bucket_replication"; }
481 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
482 RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_REPLICATION
; }
485 class RGWPutBucketReplication
: public RGWOp
{
488 std::vector
<rgw_sync_policy_group
> sync_policy_groups
;
490 int verify_permission(optional_yield y
) override
;
491 void execute(optional_yield y
) override
;
493 virtual void send_response() override
= 0;
494 virtual int get_params(optional_yield y
) = 0;
495 const char* name() const override
{ return "put_bucket_replication"; }
496 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
497 RGWOpType
get_type() override
{ return RGW_OP_PUT_BUCKET_REPLICATION
; }
500 class RGWDeleteBucketReplication
: public RGWOp
{
502 virtual void update_sync_policy(rgw_sync_policy_info
*policy
) = 0;
504 void pre_exec() override
;
505 int verify_permission(optional_yield y
) override
;
506 void execute(optional_yield y
) override
;
508 const char* name() const override
{ return "delete_bucket_replication"; }
509 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
510 RGWOpType
get_type() override
{ return RGW_OP_DELETE_BUCKET_REPLICATION
;}
513 class RGWBulkDelete
: public RGWOp
{
516 std::string bucket_name
;
527 const DoutPrefixProvider
* dpp
;
528 unsigned int num_deleted
;
529 unsigned int num_unfound
;
530 std::list
<fail_desc_t
> failures
;
532 rgw::sal::RGWRadosStore
* const store
;
536 Deleter(const DoutPrefixProvider
* dpp
, rgw::sal::RGWRadosStore
* const str
, req_state
* const s
)
544 unsigned int get_num_deleted() const {
548 unsigned int get_num_unfound() const {
552 const std::list
<fail_desc_t
> get_failures() const {
556 bool verify_permission(RGWBucketInfo
& binfo
,
557 map
<string
, bufferlist
>& battrs
,
558 ACLOwner
& bucket_owner
/* out */,
560 bool delete_single(const acct_path_t
& path
, optional_yield y
);
561 bool delete_chunk(const std::list
<acct_path_t
>& paths
, optional_yield y
);
563 /* End of Deleter subclass */
565 static const size_t MAX_CHUNK_ENTRIES
= 1024;
568 std::unique_ptr
<Deleter
> deleter
;
575 int verify_permission(optional_yield y
) override
;
576 void pre_exec() override
;
577 void execute(optional_yield y
) override
;
579 virtual int get_data(std::list
<acct_path_t
>& items
,
580 bool * is_truncated
) = 0;
581 void send_response() override
= 0;
583 const char* name() const override
{ return "bulk_delete"; }
584 RGWOpType
get_type() override
{ return RGW_OP_BULK_DELETE
; }
585 uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
586 dmc::client_id
dmclock_client() override
{ return dmc::client_id::data
; }
589 inline ostream
& operator<<(ostream
& out
, const RGWBulkDelete::acct_path_t
&o
) {
590 return out
<< o
.bucket_name
<< "/" << o
.obj_key
;
594 class RGWBulkUploadOp
: public RGWOp
{
595 boost::optional
<RGWSysObjectCtx
> dir_ctx
;
600 fail_desc_t(const int err
, std::string path
)
602 path(std::move(path
)) {
606 const std::string path
;
609 static constexpr std::array
<int, 2> terminal_errors
= {
613 /* FIXME: boost::container::small_vector<fail_desc_t, 4> failures; */
614 std::vector
<fail_desc_t
> failures
;
618 class DecoratedStreamGetter
;
619 class AlignedStreamGetter
;
621 virtual std::unique_ptr
<StreamGetter
> create_stream() = 0;
622 virtual void send_response() override
= 0;
624 boost::optional
<std::pair
<std::string
, rgw_obj_key
>>
625 parse_path(const std::string_view
& path
);
627 std::pair
<std::string
, std::string
>
628 handle_upload_path(struct req_state
*s
);
630 bool handle_file_verify_permission(RGWBucketInfo
& binfo
,
632 std::map
<std::string
, ceph::bufferlist
>& battrs
,
633 ACLOwner
& bucket_owner
/* out */,
635 int handle_file(std::string_view path
,
637 AlignedStreamGetter
& body
,
640 int handle_dir_verify_permission(optional_yield y
);
641 int handle_dir(std::string_view path
, optional_yield y
);
648 void init(rgw::sal::RGWRadosStore
* const store
,
649 struct req_state
* const s
,
650 RGWHandler
* const h
) override
;
652 int verify_permission(optional_yield y
) override
;
653 void pre_exec() override
;
654 void execute(optional_yield y
) override
;
656 const char* name() const override
{ return "bulk_upload"; }
658 RGWOpType
get_type() override
{
659 return RGW_OP_BULK_UPLOAD
;
662 uint32_t op_mask() override
{
663 return RGW_OP_TYPE_WRITE
;
665 dmc::client_id
dmclock_client() override
{ return dmc::client_id::data
; }
666 }; /* RGWBulkUploadOp */
669 class RGWBulkUploadOp::StreamGetter
{
671 StreamGetter() = default;
672 virtual ~StreamGetter() = default;
674 virtual ssize_t
get_at_most(size_t want
, ceph::bufferlist
& dst
) = 0;
675 virtual ssize_t
get_exactly(size_t want
, ceph::bufferlist
& dst
) = 0;
676 }; /* End of nested subclass StreamGetter */
679 class RGWBulkUploadOp::DecoratedStreamGetter
: public StreamGetter
{
680 StreamGetter
& decoratee
;
683 StreamGetter
& get_decoratee() {
688 explicit DecoratedStreamGetter(StreamGetter
& decoratee
)
689 : decoratee(decoratee
) {
691 virtual ~DecoratedStreamGetter() = default;
693 ssize_t
get_at_most(const size_t want
, ceph::bufferlist
& dst
) override
{
694 return get_decoratee().get_at_most(want
, dst
);
697 ssize_t
get_exactly(const size_t want
, ceph::bufferlist
& dst
) override
{
698 return get_decoratee().get_exactly(want
, dst
);
700 }; /* RGWBulkUploadOp::DecoratedStreamGetter */
703 class RGWBulkUploadOp::AlignedStreamGetter
704 : public RGWBulkUploadOp::DecoratedStreamGetter
{
710 template <typename U
>
711 AlignedStreamGetter(const size_t position
,
713 const size_t alignment
,
715 : DecoratedStreamGetter(std::forward
<U
>(decoratee
)),
718 alignment(alignment
) {
720 virtual ~AlignedStreamGetter();
721 ssize_t
get_at_most(size_t want
, ceph::bufferlist
& dst
) override
;
722 ssize_t
get_exactly(size_t want
, ceph::bufferlist
& dst
) override
;
723 }; /* RGWBulkUploadOp::AlignedStreamGetter */
726 struct RGWUsageStats
{
727 uint64_t bytes_used
= 0;
728 uint64_t bytes_used_rounded
= 0;
729 uint64_t buckets_count
= 0;
730 uint64_t objects_count
= 0;
733 #define RGW_LIST_BUCKETS_LIMIT_MAX 10000
735 class RGWListBuckets
: public RGWOp
{
739 std::string end_marker
;
742 std::map
<std::string
, ceph::bufferlist
> attrs
;
745 RGWUsageStats global_stats
;
746 std::map
<std::string
, RGWUsageStats
> policies_stats
;
748 virtual uint64_t get_default_max() const {
755 limit(RGW_LIST_BUCKETS_LIMIT_MAX
),
756 limit_max(RGW_LIST_BUCKETS_LIMIT_MAX
),
757 is_truncated(false) {
760 int verify_permission(optional_yield y
) override
;
761 void execute(optional_yield y
) override
;
763 virtual int get_params(optional_yield y
) = 0;
764 virtual void handle_listing_chunk(rgw::sal::RGWBucketList
&& buckets
) {
765 /* The default implementation, used by e.g. S3, just generates a new
766 * part of listing and sends it client immediately. Swift can behave
767 * differently: when the reverse option is requested, all incoming
768 * instances of RGWBucketList are buffered and finally reversed. */
769 return send_response_data(buckets
);
771 virtual void send_response_begin(bool has_buckets
) = 0;
772 virtual void send_response_data(rgw::sal::RGWBucketList
& buckets
) = 0;
773 virtual void send_response_end() = 0;
774 void send_response() override
{}
776 virtual bool should_get_stats() { return false; }
777 virtual bool supports_account_metadata() { return false; }
779 const char* name() const override
{ return "list_buckets"; }
780 RGWOpType
get_type() override
{ return RGW_OP_LIST_BUCKETS
; }
781 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
782 }; // class RGWListBuckets
784 class RGWGetUsage
: public RGWOp
{
789 int show_log_entries
;
791 map
<string
, bool> categories
;
792 map
<rgw_user_bucket
, rgw_usage_log_entry
> usage
;
793 map
<string
, rgw_usage_log_entry
> summary_map
;
794 map
<string
, cls_user_bucket_entry
> buckets_usage
;
795 cls_user_header header
;
796 RGWStorageStats stats
;
798 RGWGetUsage() : sent_data(false), show_log_entries(true), show_log_sum(true){
801 int verify_permission(optional_yield y
) override
;
802 void execute(optional_yield y
) override
;
804 virtual int get_params(optional_yield y
) = 0;
805 void send_response() override
{}
807 virtual bool should_get_stats() { return false; }
809 const char* name() const override
{ return "get_self_usage"; }
810 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
813 class RGWStatAccount
: public RGWOp
{
815 RGWUsageStats global_stats
;
816 std::map
<std::string
, RGWUsageStats
> policies_stats
;
819 RGWStatAccount() = default;
821 int verify_permission(optional_yield y
) override
;
822 void execute(optional_yield y
) override
;
824 void send_response() override
= 0;
825 const char* name() const override
{ return "stat_account"; }
826 RGWOpType
get_type() override
{ return RGW_OP_STAT_ACCOUNT
; }
827 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
830 class RGWListBucket
: public RGWOp
{
834 rgw_obj_key next_marker
;
835 rgw_obj_key end_marker
;
838 string encoding_type
;
841 vector
<rgw_bucket_dir_entry
> objs
;
842 map
<string
, bool> common_prefixes
;
846 bool allow_unordered
;
850 int parse_max_keys();
853 RGWListBucket() : list_versions(false), max(0),
854 default_max(0), is_truncated(false),
855 allow_unordered(false), shard_id(-1) {}
856 int verify_permission(optional_yield y
) override
;
857 void pre_exec() override
;
858 void execute(optional_yield y
) override
;
860 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
861 RGWOp::init(store
, s
, h
);
863 virtual int get_params(optional_yield y
) = 0;
864 void send_response() override
= 0;
865 const char* name() const override
{ return "list_bucket"; }
866 RGWOpType
get_type() override
{ return RGW_OP_LIST_BUCKET
; }
867 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
868 virtual bool need_container_stats() { return false; }
871 class RGWGetBucketLogging
: public RGWOp
{
873 RGWGetBucketLogging() {}
874 int verify_permission(optional_yield y
) override
;
875 void execute(optional_yield
) override
{ }
877 void send_response() override
= 0;
878 const char* name() const override
{ return "get_bucket_logging"; }
879 RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_LOGGING
; }
880 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
883 class RGWGetBucketLocation
: public RGWOp
{
885 RGWGetBucketLocation() {}
886 ~RGWGetBucketLocation() override
{}
887 int verify_permission(optional_yield y
) override
;
888 void execute(optional_yield
) override
{ }
890 void send_response() override
= 0;
891 const char* name() const override
{ return "get_bucket_location"; }
892 RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_LOCATION
; }
893 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
896 class RGWGetBucketVersioning
: public RGWOp
{
898 bool versioned
{false};
899 bool versioning_enabled
{false};
900 bool mfa_enabled
{false};
902 RGWGetBucketVersioning() = default;
904 int verify_permission(optional_yield y
) override
;
905 void pre_exec() override
;
906 void execute(optional_yield y
) override
;
908 void send_response() override
= 0;
909 const char* name() const override
{ return "get_bucket_versioning"; }
910 RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_VERSIONING
; }
911 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
914 enum BucketVersionStatus
{
915 VersioningStatusInvalid
= -1,
916 VersioningNotChanged
= 0,
917 VersioningEnabled
= 1,
918 VersioningSuspended
=2,
921 class RGWSetBucketVersioning
: public RGWOp
{
923 int versioning_status
;
924 bool mfa_set_status
{false};
925 bool mfa_status
{false};
928 RGWSetBucketVersioning() : versioning_status(VersioningNotChanged
) {}
930 int verify_permission(optional_yield y
) override
;
931 void pre_exec() override
;
932 void execute(optional_yield y
) override
;
934 virtual int get_params(optional_yield y
) { return 0; }
936 void send_response() override
= 0;
937 const char* name() const override
{ return "set_bucket_versioning"; }
938 RGWOpType
get_type() override
{ return RGW_OP_SET_BUCKET_VERSIONING
; }
939 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
942 class RGWGetBucketWebsite
: public RGWOp
{
944 RGWGetBucketWebsite() {}
946 int verify_permission(optional_yield y
) override
;
947 void pre_exec() override
;
948 void execute(optional_yield y
) override
;
950 void send_response() override
= 0;
951 const char* name() const override
{ return "get_bucket_website"; }
952 RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_WEBSITE
; }
953 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
956 class RGWSetBucketWebsite
: public RGWOp
{
959 RGWBucketWebsiteConf website_conf
;
961 RGWSetBucketWebsite() {}
963 int verify_permission(optional_yield y
) override
;
964 void pre_exec() override
;
965 void execute(optional_yield y
) override
;
967 virtual int get_params(optional_yield y
) { return 0; }
969 void send_response() override
= 0;
970 const char* name() const override
{ return "set_bucket_website"; }
971 RGWOpType
get_type() override
{ return RGW_OP_SET_BUCKET_WEBSITE
; }
972 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
975 class RGWDeleteBucketWebsite
: public RGWOp
{
977 RGWDeleteBucketWebsite() {}
979 int verify_permission(optional_yield y
) override
;
980 void pre_exec() override
;
981 void execute(optional_yield y
) override
;
983 void send_response() override
= 0;
984 const char* name() const override
{ return "delete_bucket_website"; }
985 RGWOpType
get_type() override
{ return RGW_OP_SET_BUCKET_WEBSITE
; }
986 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
989 class RGWStatBucket
: public RGWOp
{
991 std::unique_ptr
<rgw::sal::RGWBucket
> bucket
;
994 int verify_permission(optional_yield y
) override
;
995 void pre_exec() override
;
996 void execute(optional_yield y
) override
;
998 void send_response() override
= 0;
999 const char* name() const override
{ return "stat_bucket"; }
1000 RGWOpType
get_type() override
{ return RGW_OP_STAT_BUCKET
; }
1001 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1004 class RGWCreateBucket
: public RGWOp
{
1006 RGWAccessControlPolicy policy
;
1007 string location_constraint
;
1008 rgw_placement_rule placement_rule
;
1010 obj_version ep_objv
;
1012 bool relaxed_region_enforcement
;
1013 bool obj_lock_enabled
;
1014 RGWCORSConfiguration cors_config
;
1015 boost::optional
<std::string
> swift_ver_location
;
1016 map
<string
, buffer::list
> attrs
;
1017 set
<string
> rmattr_names
;
1021 virtual bool need_metadata_upload() const { return false; }
1024 RGWCreateBucket() : has_cors(false), relaxed_region_enforcement(false), obj_lock_enabled(false) {}
1026 void emplace_attr(std::string
&& key
, buffer::list
&& bl
) {
1027 attrs
.emplace(std::move(key
), std::move(bl
)); /* key and bl are r-value refs */
1030 int verify_permission(optional_yield y
) override
;
1031 void pre_exec() override
;
1032 void execute(optional_yield y
) override
;
1033 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1034 RGWOp::init(store
, s
, h
);
1035 policy
.set_ctx(s
->cct
);
1036 relaxed_region_enforcement
=
1037 s
->cct
->_conf
.get_val
<bool>("rgw_relaxed_region_enforcement");
1039 virtual int get_params(optional_yield y
) { return 0; }
1040 void send_response() override
= 0;
1041 const char* name() const override
{ return "create_bucket"; }
1042 RGWOpType
get_type() override
{ return RGW_OP_CREATE_BUCKET
; }
1043 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1046 class RGWDeleteBucket
: public RGWOp
{
1048 RGWObjVersionTracker objv_tracker
;
1051 RGWDeleteBucket() {}
1053 int verify_permission(optional_yield y
) override
;
1054 void pre_exec() override
;
1055 void execute(optional_yield y
) override
;
1057 void send_response() override
= 0;
1058 const char* name() const override
{ return "delete_bucket"; }
1059 RGWOpType
get_type() override
{ return RGW_OP_DELETE_BUCKET
; }
1060 uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
1063 struct rgw_slo_entry
{
1066 uint64_t size_bytes
;
1068 rgw_slo_entry() : size_bytes(0) {}
1070 void encode(bufferlist
& bl
) const {
1071 ENCODE_START(1, 1, bl
);
1074 encode(size_bytes
, bl
);
1078 void decode(bufferlist::const_iterator
& bl
) {
1079 DECODE_START(1, bl
);
1082 decode(size_bytes
, bl
);
1086 void decode_json(JSONObj
*obj
);
1088 WRITE_CLASS_ENCODER(rgw_slo_entry
)
1091 vector
<rgw_slo_entry
> entries
;
1092 uint64_t total_size
;
1094 /* in memory only */
1095 bufferlist raw_data
;
1097 RGWSLOInfo() : total_size(0) {}
1100 void encode(bufferlist
& bl
) const {
1101 ENCODE_START(1, 1, bl
);
1102 encode(entries
, bl
);
1103 encode(total_size
, bl
);
1107 void decode(bufferlist::const_iterator
& bl
) {
1108 DECODE_START(1, bl
);
1109 decode(entries
, bl
);
1110 decode(total_size
, bl
);
1114 WRITE_CLASS_ENCODER(RGWSLOInfo
)
1116 class RGWPutObj
: public RGWOp
{
1120 const char *supplied_md5_b64
;
1121 const char *supplied_etag
;
1122 const char *if_match
;
1123 const char *if_nomatch
;
1124 std::string copy_source
;
1125 const char *copy_source_range
;
1126 RGWBucketInfo copy_source_bucket_info
;
1127 string copy_source_tenant_name
;
1128 string copy_source_bucket_name
;
1129 string copy_source_object_name
;
1130 string copy_source_version_id
;
1131 off_t copy_source_range_fst
;
1132 off_t copy_source_range_lst
;
1134 bool chunked_upload
;
1135 RGWAccessControlPolicy policy
;
1136 std::unique_ptr
<RGWObjTags
> obj_tags
;
1137 const char *dlo_manifest
;
1138 RGWSLOInfo
*slo_info
;
1139 rgw::sal::RGWAttrs attrs
;
1140 ceph::real_time mtime
;
1144 map
<string
, string
> crypt_http_responses
;
1147 std::string multipart_upload_id
;
1148 std::string multipart_part_str
;
1149 int multipart_part_num
= 0;
1151 boost::optional
<ceph::real_time
> delete_at
;
1155 uint64_t cur_accounted_size
;
1158 RGWObjectRetention
*obj_retention
;
1159 RGWObjectLegalHold
*obj_legal_hold
;
1162 RGWPutObj() : ofs(0),
1163 supplied_md5_b64(NULL
),
1164 supplied_etag(NULL
),
1167 copy_source_range(NULL
),
1168 copy_source_range_fst(0),
1169 copy_source_range_lst(0),
1176 cur_accounted_size(0),
1177 obj_retention(nullptr),
1178 obj_legal_hold(nullptr) {}
1180 ~RGWPutObj() override
{
1182 delete obj_retention
;
1183 delete obj_legal_hold
;
1186 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1187 RGWOp::init(store
, s
, h
);
1188 policy
.set_ctx(s
->cct
);
1191 virtual int init_processing(optional_yield y
) override
;
1193 void emplace_attr(std::string
&& key
, buffer::list
&& bl
) {
1194 attrs
.emplace(std::move(key
), std::move(bl
)); /* key and bl are r-value refs */
1197 int verify_permission(optional_yield y
) override
;
1198 void pre_exec() override
;
1199 void execute(optional_yield y
) override
;
1201 /* this is for cases when copying data from other object */
1202 virtual int get_decrypt_filter(std::unique_ptr
<RGWGetObj_Filter
>* filter
,
1203 RGWGetObj_Filter
* cb
,
1204 map
<string
, bufferlist
>& attrs
,
1205 bufferlist
* manifest_bl
) {
1209 virtual int get_encrypt_filter(std::unique_ptr
<rgw::putobj::DataProcessor
> *filter
,
1210 rgw::putobj::DataProcessor
*cb
) {
1214 int get_data_cb(bufferlist
& bl
, off_t bl_ofs
, off_t bl_len
);
1215 int get_data(const off_t fst
, const off_t lst
, bufferlist
& bl
);
1217 virtual int get_params(optional_yield y
) = 0;
1218 virtual int get_data(bufferlist
& bl
) = 0;
1219 void send_response() override
= 0;
1220 const char* name() const override
{ return "put_obj"; }
1221 RGWOpType
get_type() override
{ return RGW_OP_PUT_OBJ
; }
1222 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1223 dmc::client_id
dmclock_client() override
{ return dmc::client_id::data
; }
1226 class RGWPostObj
: public RGWOp
{
1232 const char *supplied_md5_b64
;
1233 const char *supplied_etag
;
1235 RGWAccessControlPolicy policy
;
1236 map
<string
, bufferlist
> attrs
;
1237 boost::optional
<ceph::real_time
> delete_at
;
1239 /* Must be called after get_data() or the result is undefined. */
1240 virtual std::string
get_current_filename() const = 0;
1241 virtual std::string
get_current_content_type() const = 0;
1242 virtual bool is_next_file_to_upload() {
1246 RGWPostObj() : min_len(0),
1250 supplied_md5_b64(nullptr),
1251 supplied_etag(nullptr) {
1254 void emplace_attr(std::string
&& key
, buffer::list
&& bl
) {
1255 attrs
.emplace(std::move(key
), std::move(bl
)); /* key and bl are r-value refs */
1258 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1259 RGWOp::init(store
, s
, h
);
1260 policy
.set_ctx(s
->cct
);
1263 int verify_permission(optional_yield y
) override
;
1264 void pre_exec() override
;
1265 void execute(optional_yield y
) override
;
1267 virtual int get_encrypt_filter(std::unique_ptr
<rgw::putobj::DataProcessor
> *filter
,
1268 rgw::putobj::DataProcessor
*cb
) {
1271 virtual int get_params(optional_yield y
) = 0;
1272 virtual int get_data(ceph::bufferlist
& bl
, bool& again
) = 0;
1273 void send_response() override
= 0;
1274 const char* name() const override
{ return "post_obj"; }
1275 RGWOpType
get_type() override
{ return RGW_OP_POST_OBJ
; }
1276 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1277 dmc::client_id
dmclock_client() override
{ return dmc::client_id::data
; }
1280 class RGWPutMetadataAccount
: public RGWOp
{
1282 std::set
<std::string
> rmattr_names
;
1283 std::map
<std::string
, bufferlist
> attrs
, orig_attrs
;
1284 std::map
<int, std::string
> temp_url_keys
;
1285 RGWQuotaInfo new_quota
;
1286 bool new_quota_extracted
;
1288 RGWObjVersionTracker acct_op_tracker
;
1290 RGWAccessControlPolicy policy
;
1294 RGWPutMetadataAccount()
1295 : new_quota_extracted(false),
1299 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1300 RGWOp::init(store
, s
, h
);
1301 policy
.set_ctx(s
->cct
);
1303 int init_processing(optional_yield y
) override
;
1304 int verify_permission(optional_yield y
) override
;
1305 void pre_exec() override
{ }
1306 void execute(optional_yield y
) override
;
1308 virtual int get_params(optional_yield y
) = 0;
1309 void send_response() override
= 0;
1310 virtual void filter_out_temp_url(map
<string
, bufferlist
>& add_attrs
,
1311 const set
<string
>& rmattr_names
,
1312 map
<int, string
>& temp_url_keys
);
1313 const char* name() const override
{ return "put_account_metadata"; }
1314 RGWOpType
get_type() override
{ return RGW_OP_PUT_METADATA_ACCOUNT
; }
1315 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1318 class RGWPutMetadataBucket
: public RGWOp
{
1320 rgw::sal::RGWAttrs attrs
;
1321 set
<string
> rmattr_names
;
1322 bool has_policy
, has_cors
;
1323 uint32_t policy_rw_mask
;
1324 RGWAccessControlPolicy policy
;
1325 RGWCORSConfiguration cors_config
;
1326 rgw_placement_rule placement_rule
;
1327 boost::optional
<std::string
> swift_ver_location
;
1330 RGWPutMetadataBucket()
1331 : has_policy(false), has_cors(false), policy_rw_mask(0)
1334 void emplace_attr(std::string
&& key
, buffer::list
&& bl
) {
1335 attrs
.emplace(std::move(key
), std::move(bl
)); /* key and bl are r-value refs */
1338 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1339 RGWOp::init(store
, s
, h
);
1340 policy
.set_ctx(s
->cct
);
1343 int verify_permission(optional_yield y
) override
;
1344 void pre_exec() override
;
1345 void execute(optional_yield y
) override
;
1347 virtual int get_params(optional_yield y
) = 0;
1348 void send_response() override
= 0;
1349 const char* name() const override
{ return "put_bucket_metadata"; }
1350 RGWOpType
get_type() override
{ return RGW_OP_PUT_METADATA_BUCKET
; }
1351 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1354 class RGWPutMetadataObject
: public RGWOp
{
1356 RGWAccessControlPolicy policy
;
1357 boost::optional
<ceph::real_time
> delete_at
;
1358 const char *dlo_manifest
;
1361 RGWPutMetadataObject()
1362 : dlo_manifest(NULL
)
1365 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1366 RGWOp::init(store
, s
, h
);
1367 policy
.set_ctx(s
->cct
);
1369 int verify_permission(optional_yield y
) override
;
1370 void pre_exec() override
;
1371 void execute(optional_yield y
) override
;
1373 virtual int get_params(optional_yield y
) = 0;
1374 void send_response() override
= 0;
1375 const char* name() const override
{ return "put_obj_metadata"; }
1376 RGWOpType
get_type() override
{ return RGW_OP_PUT_METADATA_OBJECT
; }
1377 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1378 virtual bool need_object_expiration() { return false; }
1381 class RGWDeleteObj
: public RGWOp
{
1384 bool multipart_delete
;
1386 ceph::real_time unmod_since
; /* if unmodified since */
1387 bool no_precondition_error
;
1388 std::unique_ptr
<RGWBulkDelete::Deleter
> deleter
;
1390 bool bypass_governance_mode
;
1394 : delete_marker(false),
1395 multipart_delete(false),
1396 no_precondition_error(false),
1399 bypass_governance_mode(false) {
1402 int verify_permission(optional_yield y
) override
;
1403 void pre_exec() override
;
1404 void execute(optional_yield y
) override
;
1405 int handle_slo_manifest(bufferlist
& bl
, optional_yield y
);
1407 virtual int get_params(optional_yield y
) { return 0; }
1408 void send_response() override
= 0;
1409 const char* name() const override
{ return "delete_obj"; }
1410 RGWOpType
get_type() override
{ return RGW_OP_DELETE_OBJ
; }
1411 uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
1412 virtual bool need_object_expiration() { return false; }
1413 dmc::client_id
dmclock_client() override
{ return dmc::client_id::data
; }
1416 class RGWCopyObj
: public RGWOp
{
1418 RGWAccessControlPolicy dest_policy
;
1420 const char *if_unmod
;
1421 const char *if_match
;
1422 const char *if_nomatch
;
1423 // Required or it is not a copy operation
1424 std::string_view copy_source
;
1425 // Not actually required
1426 std::optional
<std::string_view
> md_directive
;
1431 ceph::real_time mod_time
;
1432 ceph::real_time unmod_time
;
1433 ceph::real_time
*mod_ptr
;
1434 ceph::real_time
*unmod_ptr
;
1435 rgw::sal::RGWAttrs attrs
;
1436 string src_tenant_name
, src_bucket_name
, src_obj_name
;
1437 std::unique_ptr
<rgw::sal::RGWBucket
> src_bucket
;
1438 std::unique_ptr
<rgw::sal::RGWObject
> src_object
;
1439 string dest_tenant_name
, dest_bucket_name
, dest_obj_name
;
1440 std::unique_ptr
<rgw::sal::RGWBucket
> dest_bucket
;
1441 std::unique_ptr
<rgw::sal::RGWObject
> dest_object
;
1442 ceph::real_time src_mtime
;
1443 ceph::real_time mtime
;
1444 rgw::sal::AttrsMod attrs_mod
;
1453 boost::optional
<ceph::real_time
> delete_at
;
1456 bool need_to_check_storage_class
= false;
1471 attrs_mod
= rgw::sal::ATTRSMOD_NONE
;
1474 copy_if_newer
= false;
1477 static bool parse_copy_location(const std::string_view
& src
,
1478 string
& bucket_name
,
1479 rgw_obj_key
& object
,
1480 struct req_state
*s
);
1482 void emplace_attr(std::string
&& key
, buffer::list
&& bl
) {
1483 attrs
.emplace(std::move(key
), std::move(bl
));
1486 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1487 RGWOp::init(store
, s
, h
);
1488 dest_policy
.set_ctx(s
->cct
);
1490 int verify_permission(optional_yield y
) override
;
1491 void pre_exec() override
;
1492 void execute(optional_yield y
) override
;
1493 void progress_cb(off_t ofs
);
1495 virtual int check_storage_class(const rgw_placement_rule
& src_placement
) {
1499 virtual int init_dest_policy() { return 0; }
1500 virtual int get_params(optional_yield y
) = 0;
1501 virtual void send_partial_response(off_t ofs
) {}
1502 void send_response() override
= 0;
1503 const char* name() const override
{ return "copy_obj"; }
1504 RGWOpType
get_type() override
{ return RGW_OP_COPY_OBJ
; }
1505 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1506 dmc::client_id
dmclock_client() override
{ return dmc::client_id::data
; }
1509 class RGWGetACLs
: public RGWOp
{
1516 int verify_permission(optional_yield y
) override
;
1517 void pre_exec() override
;
1518 void execute(optional_yield y
) override
;
1520 void send_response() override
= 0;
1521 const char* name() const override
{ return "get_acls"; }
1522 RGWOpType
get_type() override
{ return RGW_OP_GET_ACLS
; }
1523 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1526 class RGWPutACLs
: public RGWOp
{
1533 ~RGWPutACLs() override
{}
1535 int verify_permission(optional_yield y
) override
;
1536 void pre_exec() override
;
1537 void execute(optional_yield y
) override
;
1539 virtual int get_policy_from_state(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, stringstream
& ss
) { return 0; }
1540 virtual int get_params(optional_yield y
) = 0;
1541 void send_response() override
= 0;
1542 const char* name() const override
{ return "put_acls"; }
1543 RGWOpType
get_type() override
{ return RGW_OP_PUT_ACLS
; }
1544 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1547 class RGWGetLC
: public RGWOp
{
1552 ~RGWGetLC() override
{ }
1554 int verify_permission(optional_yield y
) override
;
1555 void pre_exec() override
;
1556 void execute(optional_yield
) override
= 0;
1558 void send_response() override
= 0;
1559 const char* name() const override
{ return "get_lifecycle"; }
1560 RGWOpType
get_type() override
{ return RGW_OP_GET_LC
; }
1561 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1564 class RGWPutLC
: public RGWOp
{
1567 const char *content_md5
;
1572 content_md5
= nullptr;
1574 ~RGWPutLC() override
{}
1576 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*dialect_handler
) override
{
1577 #define COOKIE_LEN 16
1578 char buf
[COOKIE_LEN
+ 1];
1580 RGWOp::init(store
, s
, dialect_handler
);
1581 gen_rand_alphanumeric(s
->cct
, buf
, sizeof(buf
) - 1);
1585 int verify_permission(optional_yield y
) override
;
1586 void pre_exec() override
;
1587 void execute(optional_yield y
) override
;
1589 // virtual int get_policy_from_state(RGWRados *store, struct req_state *s, stringstream& ss) { return 0; }
1590 virtual int get_params(optional_yield y
) = 0;
1591 void send_response() override
= 0;
1592 const char* name() const override
{ return "put_lifecycle"; }
1593 RGWOpType
get_type() override
{ return RGW_OP_PUT_LC
; }
1594 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1597 class RGWDeleteLC
: public RGWOp
{
1599 RGWDeleteLC() = default;
1600 int verify_permission(optional_yield y
) override
;
1601 void pre_exec() override
;
1602 void execute(optional_yield y
) override
;
1604 void send_response() override
= 0;
1605 const char* name() const override
{ return "delete_lifecycle"; }
1606 RGWOpType
get_type() override
{ return RGW_OP_DELETE_LC
; }
1607 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1610 class RGWGetCORS
: public RGWOp
{
1616 int verify_permission(optional_yield y
) override
;
1617 void execute(optional_yield y
) override
;
1619 void send_response() override
= 0;
1620 const char* name() const override
{ return "get_cors"; }
1621 RGWOpType
get_type() override
{ return RGW_OP_GET_CORS
; }
1622 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1625 class RGWPutCORS
: public RGWOp
{
1632 ~RGWPutCORS() override
{}
1634 int verify_permission(optional_yield y
) override
;
1635 void execute(optional_yield y
) override
;
1637 virtual int get_params(optional_yield y
) = 0;
1638 void send_response() override
= 0;
1639 const char* name() const override
{ return "put_cors"; }
1640 RGWOpType
get_type() override
{ return RGW_OP_PUT_CORS
; }
1641 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1644 class RGWDeleteCORS
: public RGWOp
{
1650 int verify_permission(optional_yield y
) override
;
1651 void execute(optional_yield y
) override
;
1653 void send_response() override
= 0;
1654 const char* name() const override
{ return "delete_cors"; }
1655 RGWOpType
get_type() override
{ return RGW_OP_DELETE_CORS
; }
1656 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1659 class RGWOptionsCORS
: public RGWOp
{
1662 const char *origin
, *req_hdrs
, *req_meth
;
1665 RGWOptionsCORS() : rule(NULL
), origin(NULL
),
1666 req_hdrs(NULL
), req_meth(NULL
) {
1669 int verify_permission(optional_yield y
) override
{return 0;}
1670 int validate_cors_request(RGWCORSConfiguration
*cc
);
1671 void execute(optional_yield y
) override
;
1672 void get_response_params(string
& allowed_hdrs
, string
& exp_hdrs
, unsigned *max_age
);
1673 void send_response() override
= 0;
1674 const char* name() const override
{ return "options_cors"; }
1675 RGWOpType
get_type() override
{ return RGW_OP_OPTIONS_CORS
; }
1676 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1679 class RGWGetRequestPayment
: public RGWOp
{
1681 bool requester_pays
;
1684 RGWGetRequestPayment() : requester_pays(0) {}
1686 int verify_permission(optional_yield y
) override
;
1687 void pre_exec() override
;
1688 void execute(optional_yield y
) override
;
1690 void send_response() override
= 0;
1691 const char* name() const override
{ return "get_request_payment"; }
1692 RGWOpType
get_type() override
{ return RGW_OP_GET_REQUEST_PAYMENT
; }
1693 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1696 class RGWSetRequestPayment
: public RGWOp
{
1698 bool requester_pays
;
1701 RGWSetRequestPayment() : requester_pays(false) {}
1703 int verify_permission(optional_yield y
) override
;
1704 void pre_exec() override
;
1705 void execute(optional_yield y
) override
;
1707 virtual int get_params(optional_yield y
) { return 0; }
1709 void send_response() override
= 0;
1710 const char* name() const override
{ return "set_request_payment"; }
1711 RGWOpType
get_type() override
{ return RGW_OP_SET_REQUEST_PAYMENT
; }
1712 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1715 class RGWInitMultipart
: public RGWOp
{
1718 RGWAccessControlPolicy policy
;
1719 ceph::real_time mtime
;
1722 RGWInitMultipart() {}
1724 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1725 RGWOp::init(store
, s
, h
);
1726 policy
.set_ctx(s
->cct
);
1728 int verify_permission(optional_yield y
) override
;
1729 void pre_exec() override
;
1730 void execute(optional_yield y
) override
;
1732 virtual int get_params(optional_yield y
) = 0;
1733 void send_response() override
= 0;
1734 const char* name() const override
{ return "init_multipart"; }
1735 RGWOpType
get_type() override
{ return RGW_OP_INIT_MULTIPART
; }
1736 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1737 virtual int prepare_encryption(map
<string
, bufferlist
>& attrs
) { return 0; }
1740 class RGWCompleteMultipart
: public RGWOp
{
1746 rgw::sal::MPSerializer
* serializer
;
1749 RGWCompleteMultipart() : serializer(nullptr) {}
1750 ~RGWCompleteMultipart() override
{ delete serializer
; }
1752 int verify_permission(optional_yield y
) override
;
1753 void pre_exec() override
;
1754 void execute(optional_yield y
) override
;
1755 void complete() override
;
1757 virtual int get_params(optional_yield y
) = 0;
1758 void send_response() override
= 0;
1759 const char* name() const override
{ return "complete_multipart"; }
1760 RGWOpType
get_type() override
{ return RGW_OP_COMPLETE_MULTIPART
; }
1761 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
1764 class RGWAbortMultipart
: public RGWOp
{
1766 RGWAbortMultipart() {}
1768 int verify_permission(optional_yield y
) override
;
1769 void pre_exec() override
;
1770 void execute(optional_yield y
) override
;
1772 void send_response() override
= 0;
1773 const char* name() const override
{ return "abort_multipart"; }
1774 RGWOpType
get_type() override
{ return RGW_OP_ABORT_MULTIPART
; }
1775 uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
1778 class RGWListMultipart
: public RGWOp
{
1781 map
<uint32_t, RGWUploadPartInfo
> parts
;
1784 RGWAccessControlPolicy policy
;
1788 RGWListMultipart() {
1794 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1795 RGWOp::init(store
, s
, h
);
1796 policy
= RGWAccessControlPolicy(s
->cct
);
1798 int verify_permission(optional_yield y
) override
;
1799 void pre_exec() override
;
1800 void execute(optional_yield y
) override
;
1802 virtual int get_params(optional_yield y
) = 0;
1803 void send_response() override
= 0;
1804 const char* name() const override
{ return "list_multipart"; }
1805 RGWOpType
get_type() override
{ return RGW_OP_LIST_MULTIPART
; }
1806 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1809 struct RGWMultipartUploadEntry
{
1810 rgw_bucket_dir_entry obj
;
1813 friend std::ostream
& operator<<(std::ostream
& out
,
1814 const RGWMultipartUploadEntry
& e
) {
1815 constexpr char quote
= '"';
1816 return out
<< "RGWMultipartUploadEntry{ obj.key=" <<
1817 quote
<< e
.obj
.key
<< quote
<< " mp=" << e
.mp
<< " }";
1821 class RGWListBucketMultiparts
: public RGWOp
{
1825 RGWMultipartUploadEntry next_marker
;
1828 vector
<RGWMultipartUploadEntry
> uploads
;
1829 map
<string
, bool> common_prefixes
;
1832 bool encode_url
{false};
1835 RGWListBucketMultiparts() {
1837 is_truncated
= false;
1841 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
1842 RGWOp::init(store
, s
, h
);
1843 max_uploads
= default_max
;
1846 int verify_permission(optional_yield y
) override
;
1847 void pre_exec() override
;
1848 void execute(optional_yield y
) override
;
1850 virtual int get_params(optional_yield y
) = 0;
1851 void send_response() override
= 0;
1852 const char* name() const override
{ return "list_bucket_multiparts"; }
1853 RGWOpType
get_type() override
{ return RGW_OP_LIST_BUCKET_MULTIPARTS
; }
1854 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1858 class RGWGetCrossDomainPolicy
: public RGWOp
{
1860 RGWGetCrossDomainPolicy() = default;
1861 ~RGWGetCrossDomainPolicy() override
= default;
1863 int verify_permission(optional_yield
) override
{
1867 void execute(optional_yield
) override
{
1871 const char* name() const override
{ return "get_crossdomain_policy"; }
1873 RGWOpType
get_type() override
{
1874 return RGW_OP_GET_CROSS_DOMAIN_POLICY
;
1877 uint32_t op_mask() override
{
1878 return RGW_OP_TYPE_READ
;
1883 class RGWGetHealthCheck
: public RGWOp
{
1885 RGWGetHealthCheck() = default;
1886 ~RGWGetHealthCheck() override
= default;
1888 int verify_permission(optional_yield
) override
{
1892 void execute(optional_yield y
) override
;
1894 const char* name() const override
{ return "get_health_check"; }
1896 RGWOpType
get_type() override
{
1897 return RGW_OP_GET_HEALTH_CHECK
;
1900 uint32_t op_mask() override
{
1901 return RGW_OP_TYPE_READ
;
1906 class RGWDeleteMultiObj
: public RGWOp
{
1909 rgw::sal::RGWBucket
* bucket
;
1912 bool acl_allowed
= false;
1914 bool bypass_governance_mode
;
1918 RGWDeleteMultiObj() {
1920 status_dumped
= false;
1922 bypass_governance_mode
= false;
1924 int verify_permission(optional_yield y
) override
;
1925 void pre_exec() override
;
1926 void execute(optional_yield y
) override
;
1928 virtual int get_params(optional_yield y
) = 0;
1929 virtual void send_status() = 0;
1930 virtual void begin_response() = 0;
1931 virtual void send_partial_response(rgw_obj_key
& key
, bool delete_marker
,
1932 const string
& marker_version_id
, int ret
) = 0;
1933 virtual void end_response() = 0;
1934 const char* name() const override
{ return "multi_object_delete"; }
1935 RGWOpType
get_type() override
{ return RGW_OP_DELETE_MULTI_OBJ
; }
1936 uint32_t op_mask() override
{ return RGW_OP_TYPE_DELETE
; }
1939 class RGWInfo
: public RGWOp
{
1941 RGWInfo() = default;
1942 ~RGWInfo() override
= default;
1944 int verify_permission(optional_yield
) override
{ return 0; }
1945 const char* name() const override
{ return "get info"; }
1946 RGWOpType
get_type() override
{ return RGW_OP_GET_INFO
; }
1947 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
1950 extern int rgw_build_bucket_policies(const DoutPrefixProvider
*dpp
, rgw::sal::RGWRadosStore
* store
, struct req_state
* s
, optional_yield y
);
1951 extern int rgw_build_object_policies(const DoutPrefixProvider
*dpp
, rgw::sal::RGWRadosStore
*store
, struct req_state
*s
,
1952 bool prefetch_data
, optional_yield y
);
1953 extern void rgw_build_iam_environment(rgw::sal::RGWRadosStore
* store
,
1954 struct req_state
* s
);
1955 extern vector
<rgw::IAM::Policy
> get_iam_user_policy_from_attr(CephContext
* cct
,
1956 rgw::sal::RGWRadosStore
* store
,
1957 map
<string
, bufferlist
>& attrs
,
1958 const string
& tenant
);
1960 inline int get_system_versioning_params(req_state
*s
,
1961 uint64_t *olh_epoch
,
1964 if (!s
->system_request
) {
1969 string epoch_str
= s
->info
.args
.get(RGW_SYS_PARAM_PREFIX
"versioned-epoch");
1970 if (!epoch_str
.empty()) {
1972 *olh_epoch
= strict_strtol(epoch_str
.c_str(), 10, &err
);
1974 ldpp_subdout(s
, rgw
, 0) << "failed to parse versioned-epoch param"
1982 *version_id
= s
->info
.args
.get(RGW_SYS_PARAM_PREFIX
"version-id");
1986 } /* get_system_versioning_params */
1988 static inline void format_xattr(std::string
&xattr
)
1990 /* If the extended attribute is not valid UTF-8, we encode it using
1991 * quoted-printable encoding.
1993 if ((check_utf8(xattr
.c_str(), xattr
.length()) != 0) ||
1994 (check_for_control_characters(xattr
.c_str(), xattr
.length()) != 0)) {
1995 static const char MIME_PREFIX_STR
[] = "=?UTF-8?Q?";
1996 static const int MIME_PREFIX_LEN
= sizeof(MIME_PREFIX_STR
) - 1;
1997 static const char MIME_SUFFIX_STR
[] = "?=";
1998 static const int MIME_SUFFIX_LEN
= sizeof(MIME_SUFFIX_STR
) - 1;
1999 int mlen
= mime_encode_as_qp(xattr
.c_str(), NULL
, 0);
2000 char *mime
= new char[MIME_PREFIX_LEN
+ mlen
+ MIME_SUFFIX_LEN
+ 1];
2001 strcpy(mime
, MIME_PREFIX_STR
);
2002 mime_encode_as_qp(xattr
.c_str(), mime
+ MIME_PREFIX_LEN
, mlen
);
2003 strcpy(mime
+ MIME_PREFIX_LEN
+ (mlen
- 1), MIME_SUFFIX_STR
);
2007 } /* format_xattr */
2010 * Get the HTTP request metadata out of the req_state as a
2011 * map(<attr_name, attr_contents>, where attr_name is RGW_ATTR_PREFIX.HTTP_NAME)
2012 * s: The request state
2013 * attrs: will be filled up with attrs mapped as <attr_name, attr_contents>
2014 * On success returns 0.
2015 * On failure returns a negative error code.
2018 inline int rgw_get_request_metadata(const DoutPrefixProvider
*dpp
,
2019 CephContext
* const cct
,
2020 struct req_info
& info
,
2021 std::map
<std::string
, ceph::bufferlist
>& attrs
,
2022 const bool allow_empty_attrs
= true)
2024 static const std::set
<std::string
> blocklisted_headers
= {
2025 "x-amz-server-side-encryption-customer-algorithm",
2026 "x-amz-server-side-encryption-customer-key",
2027 "x-amz-server-side-encryption-customer-key-md5",
2028 "x-amz-storage-class"
2031 size_t valid_meta_count
= 0;
2032 for (auto& kv
: info
.x_meta_map
) {
2033 const std::string
& name
= kv
.first
;
2034 std::string
& xattr
= kv
.second
;
2036 if (blocklisted_headers
.count(name
) == 1) {
2037 ldpp_subdout(dpp
, rgw
, 10) << "skipping x>> " << name
<< dendl
;
2039 } else if (allow_empty_attrs
|| !xattr
.empty()) {
2040 ldpp_subdout(dpp
, rgw
, 10) << "x>> " << name
<< ":" << xattr
<< dendl
;
2041 format_xattr(xattr
);
2043 std::string
attr_name(RGW_ATTR_PREFIX
);
2044 attr_name
.append(name
);
2046 /* Check roughly whether we aren't going behind the limit on attribute
2047 * name. Passing here doesn't guarantee that an OSD will accept that
2048 * as ObjectStore::get_max_attr_name_length() can set the limit even
2049 * lower than the "osd_max_attr_name_len" configurable. */
2050 const auto max_attr_name_len
= cct
->_conf
->rgw_max_attr_name_len
;
2051 if (max_attr_name_len
&& attr_name
.length() > max_attr_name_len
) {
2052 return -ENAMETOOLONG
;
2055 /* Similar remarks apply to the check for value size. We're veryfing
2056 * it early at the RGW's side as it's being claimed in /info. */
2057 const auto max_attr_size
= cct
->_conf
->rgw_max_attr_size
;
2058 if (max_attr_size
&& xattr
.length() > max_attr_size
) {
2062 /* Swift allows administrators to limit the number of metadats items
2063 * send _in a single request_. */
2064 const auto max_attrs_num_in_req
= cct
->_conf
->rgw_max_attrs_num_in_req
;
2065 if (max_attrs_num_in_req
&&
2066 ++valid_meta_count
> max_attrs_num_in_req
) {
2070 auto rval
= attrs
.emplace(std::move(attr_name
), ceph::bufferlist());
2071 /* At the moment the value of the freshly created attribute key-value
2072 * pair is an empty bufferlist. */
2074 ceph::bufferlist
& bl
= rval
.first
->second
;
2075 bl
.append(xattr
.c_str(), xattr
.size() + 1);
2080 } /* rgw_get_request_metadata */
2082 inline void encode_delete_at_attr(boost::optional
<ceph::real_time
> delete_at
,
2083 map
<string
, bufferlist
>& attrs
)
2085 if (delete_at
== boost::none
) {
2090 encode(*delete_at
, delatbl
);
2091 attrs
[RGW_ATTR_DELETE_AT
] = delatbl
;
2092 } /* encode_delete_at_attr */
2094 inline void encode_obj_tags_attr(RGWObjTags
* obj_tags
, map
<string
, bufferlist
>& attrs
)
2096 if (obj_tags
== nullptr){
2097 // we assume the user submitted a tag format which we couldn't parse since
2098 // this wouldn't be parsed later by get/put obj tags, lets delete if the
2099 // attr was populated
2104 obj_tags
->encode(tagsbl
);
2105 attrs
[RGW_ATTR_TAGS
] = tagsbl
;
2108 inline int encode_dlo_manifest_attr(const char * const dlo_manifest
,
2109 map
<string
, bufferlist
>& attrs
)
2111 string dm
= dlo_manifest
;
2113 if (dm
.find('/') == string::npos
) {
2117 bufferlist manifest_bl
;
2118 manifest_bl
.append(dlo_manifest
, strlen(dlo_manifest
) + 1);
2119 attrs
[RGW_ATTR_USER_MANIFEST
] = manifest_bl
;
2122 } /* encode_dlo_manifest_attr */
2124 inline void complete_etag(MD5
& hash
, string
*etag
)
2126 char etag_buf
[CEPH_CRYPTO_MD5_DIGESTSIZE
];
2127 char etag_buf_str
[CEPH_CRYPTO_MD5_DIGESTSIZE
* 2 + 16];
2129 hash
.Final((unsigned char *)etag_buf
);
2130 buf_to_hex((const unsigned char *)etag_buf
, CEPH_CRYPTO_MD5_DIGESTSIZE
,
2133 *etag
= etag_buf_str
;
2134 } /* complete_etag */
2136 using boost::container::flat_map
;
2138 class RGWGetAttrs
: public RGWOp
{
2140 using get_attrs_t
= flat_map
<std::string
, std::optional
<buffer::list
>>;
2148 virtual ~RGWGetAttrs() {}
2150 void emplace_key(std::string
&& key
) {
2151 attrs
.emplace(std::move(key
), std::nullopt
);
2154 int verify_permission(optional_yield y
);
2156 void execute(optional_yield y
);
2158 virtual int get_params() = 0;
2159 virtual void send_response() = 0;
2160 virtual const char* name() const { return "get_attrs"; }
2161 virtual RGWOpType
get_type() { return RGW_OP_GET_ATTRS
; }
2162 virtual uint32_t op_mask() { return RGW_OP_TYPE_READ
; }
2163 }; /* RGWGetAttrs */
2165 class RGWSetAttrs
: public RGWOp
{
2167 map
<std::string
, buffer::list
> attrs
;
2171 ~RGWSetAttrs() override
{}
2173 void emplace_attr(std::string
&& key
, buffer::list
&& bl
) {
2174 attrs
.emplace(std::move(key
), std::move(bl
));
2177 int verify_permission(optional_yield y
) override
;
2178 void pre_exec() override
;
2179 void execute(optional_yield y
) override
;
2181 virtual int get_params(optional_yield y
) = 0;
2182 void send_response() override
= 0;
2183 const char* name() const override
{ return "set_attrs"; }
2184 RGWOpType
get_type() override
{ return RGW_OP_SET_ATTRS
; }
2185 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
2188 class RGWRMAttrs
: public RGWOp
{
2190 rgw::sal::RGWAttrs attrs
;
2196 virtual ~RGWRMAttrs() {}
2198 void emplace_key(std::string
&& key
) {
2199 attrs
.emplace(std::move(key
), buffer::list());
2202 int verify_permission(optional_yield y
);
2204 void execute(optional_yield y
);
2206 virtual int get_params() = 0;
2207 virtual void send_response() = 0;
2208 virtual const char* name() const { return "rm_attrs"; }
2209 virtual RGWOpType
get_type() { return RGW_OP_DELETE_ATTRS
; }
2210 virtual uint32_t op_mask() { return RGW_OP_TYPE_DELETE
; }
2213 class RGWGetObjLayout
: public RGWOp
{
2215 RGWObjManifest
*manifest
{nullptr};
2216 rgw_raw_obj head_obj
;
2222 int check_caps(RGWUserCaps
& caps
) {
2223 return caps
.check_cap("admin", RGW_CAP_READ
);
2225 int verify_permission(optional_yield
) override
{
2226 return check_caps(s
->user
->get_info().caps
);
2228 void pre_exec() override
;
2229 void execute(optional_yield y
) override
;
2231 const char* name() const override
{ return "get_obj_layout"; }
2232 virtual RGWOpType
get_type() override
{ return RGW_OP_GET_OBJ_LAYOUT
; }
2233 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
2236 class RGWPutBucketPolicy
: public RGWOp
{
2239 RGWPutBucketPolicy() = default;
2240 ~RGWPutBucketPolicy() {
2242 void send_response() override
;
2243 int verify_permission(optional_yield y
) override
;
2244 uint32_t op_mask() override
{
2245 return RGW_OP_TYPE_WRITE
;
2247 void execute(optional_yield y
) override
;
2248 int get_params(optional_yield y
);
2249 const char* name() const override
{ return "put_bucket_policy"; }
2250 RGWOpType
get_type() override
{
2251 return RGW_OP_PUT_BUCKET_POLICY
;
2255 class RGWGetBucketPolicy
: public RGWOp
{
2256 buffer::list policy
;
2258 RGWGetBucketPolicy() = default;
2259 void send_response() override
;
2260 int verify_permission(optional_yield y
) override
;
2261 uint32_t op_mask() override
{
2262 return RGW_OP_TYPE_READ
;
2264 void execute(optional_yield y
) override
;
2265 const char* name() const override
{ return "get_bucket_policy"; }
2266 RGWOpType
get_type() override
{
2267 return RGW_OP_GET_BUCKET_POLICY
;
2271 class RGWDeleteBucketPolicy
: public RGWOp
{
2273 RGWDeleteBucketPolicy() = default;
2274 void send_response() override
;
2275 int verify_permission(optional_yield y
) override
;
2276 uint32_t op_mask() override
{
2277 return RGW_OP_TYPE_WRITE
;
2279 void execute(optional_yield y
) override
;
2280 int get_params(optional_yield y
);
2281 const char* name() const override
{ return "delete_bucket_policy"; }
2282 RGWOpType
get_type() override
{
2283 return RGW_OP_DELETE_BUCKET_POLICY
;
2287 class RGWPutBucketObjectLock
: public RGWOp
{
2290 bufferlist obj_lock_bl
;
2291 RGWObjectLock obj_lock
;
2293 RGWPutBucketObjectLock() = default;
2294 ~RGWPutBucketObjectLock() {}
2295 int verify_permission(optional_yield y
) override
;
2296 void pre_exec() override
;
2297 void execute(optional_yield y
) override
;
2298 virtual void send_response() override
= 0;
2299 virtual int get_params(optional_yield y
) = 0;
2300 const char* name() const override
{ return "put_bucket_object_lock"; }
2301 RGWOpType
get_type() override
{ return RGW_OP_PUT_BUCKET_OBJ_LOCK
; }
2302 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
2305 class RGWGetBucketObjectLock
: public RGWOp
{
2307 int verify_permission(optional_yield y
) override
;
2308 void pre_exec() override
;
2309 void execute(optional_yield y
) override
;
2310 virtual void send_response() override
= 0;
2311 const char* name() const override
{return "get_bucket_object_lock"; }
2312 RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_OBJ_LOCK
; }
2313 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
2316 class RGWPutObjRetention
: public RGWOp
{
2319 RGWObjectRetention obj_retention
;
2321 bool bypass_governance_mode
;
2323 RGWPutObjRetention():bypass_perm(true), bypass_governance_mode(false) {}
2324 int verify_permission(optional_yield y
) override
;
2325 void pre_exec() override
;
2326 void execute(optional_yield y
) override
;
2327 virtual void send_response() override
= 0;
2328 virtual int get_params(optional_yield y
) = 0;
2329 const char* name() const override
{ return "put_obj_retention"; }
2330 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
2331 RGWOpType
get_type() override
{ return RGW_OP_PUT_OBJ_RETENTION
; }
2334 class RGWGetObjRetention
: public RGWOp
{
2336 RGWObjectRetention obj_retention
;
2338 int verify_permission(optional_yield y
) override
;
2339 void pre_exec() override
;
2340 void execute(optional_yield y
) override
;
2341 virtual void send_response() override
= 0;
2342 const char* name() const override
{return "get_obj_retention"; }
2343 RGWOpType
get_type() override
{ return RGW_OP_GET_OBJ_RETENTION
; }
2344 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
2347 class RGWPutObjLegalHold
: public RGWOp
{
2350 RGWObjectLegalHold obj_legal_hold
;
2352 int verify_permission(optional_yield y
) override
;
2353 void pre_exec() override
;
2354 void execute(optional_yield y
) override
;
2355 virtual void send_response() override
= 0;
2356 virtual int get_params(optional_yield y
) = 0;
2357 const char* name() const override
{ return "put_obj_legal_hold"; }
2358 uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
2359 RGWOpType
get_type() override
{ return RGW_OP_PUT_OBJ_LEGAL_HOLD
; }
2362 class RGWGetObjLegalHold
: public RGWOp
{
2364 RGWObjectLegalHold obj_legal_hold
;
2366 int verify_permission(optional_yield y
) override
;
2367 void pre_exec() override
;
2368 void execute(optional_yield y
) override
;
2369 virtual void send_response() override
= 0;
2370 const char* name() const override
{return "get_obj_legal_hold"; }
2371 RGWOpType
get_type() override
{ return RGW_OP_GET_OBJ_LEGAL_HOLD
; }
2372 uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
2376 class RGWConfigBucketMetaSearch
: public RGWOp
{
2378 std::map
<std::string
, uint32_t> mdsearch_config
;
2380 RGWConfigBucketMetaSearch() {}
2382 int verify_permission(optional_yield y
) override
;
2383 void pre_exec() override
;
2384 void execute(optional_yield y
) override
;
2386 virtual int get_params(optional_yield y
) = 0;
2387 const char* name() const override
{ return "config_bucket_meta_search"; }
2388 virtual RGWOpType
get_type() override
{ return RGW_OP_CONFIG_BUCKET_META_SEARCH
; }
2389 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
2392 class RGWGetBucketMetaSearch
: public RGWOp
{
2394 RGWGetBucketMetaSearch() {}
2396 int verify_permission(optional_yield y
) override
;
2397 void pre_exec() override
;
2398 void execute(optional_yield
) override
{}
2400 const char* name() const override
{ return "get_bucket_meta_search"; }
2401 virtual RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_META_SEARCH
; }
2402 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
2405 class RGWDelBucketMetaSearch
: public RGWOp
{
2407 RGWDelBucketMetaSearch() {}
2409 int verify_permission(optional_yield y
) override
;
2410 void pre_exec() override
;
2411 void execute(optional_yield y
) override
;
2413 const char* name() const override
{ return "delete_bucket_meta_search"; }
2414 virtual RGWOpType
delete_type() { return RGW_OP_DEL_BUCKET_META_SEARCH
; }
2415 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
2418 class RGWGetClusterStat
: public RGWOp
{
2420 RGWClusterStat stats_op
;
2422 RGWGetClusterStat() {}
2424 void init(rgw::sal::RGWRadosStore
*store
, struct req_state
*s
, RGWHandler
*h
) override
{
2425 RGWOp::init(store
, s
, h
);
2427 int verify_permission(optional_yield
) override
{return 0;}
2428 virtual void send_response() override
= 0;
2429 virtual int get_params(optional_yield y
) = 0;
2430 void execute(optional_yield y
) override
;
2431 const char* name() const override
{ return "get_cluster_stat"; }
2432 dmc::client_id
dmclock_client() override
{ return dmc::client_id::admin
; }
2435 class RGWGetBucketPolicyStatus
: public RGWOp
{
2437 bool isPublic
{false};
2439 int verify_permission(optional_yield y
) override
;
2440 const char* name() const override
{ return "get_bucket_policy_status"; }
2441 virtual RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_POLICY_STATUS
; }
2442 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
2443 void execute(optional_yield y
) override
;
2444 dmc::client_id
dmclock_client() override
{ return dmc::client_id::metadata
; }
2447 class RGWPutBucketPublicAccessBlock
: public RGWOp
{
2450 PublicAccessBlockConfiguration access_conf
;
2452 int verify_permission(optional_yield y
) override
;
2453 const char* name() const override
{ return "put_bucket_public_access_block";}
2454 virtual RGWOpType
get_type() override
{ return RGW_OP_PUT_BUCKET_PUBLIC_ACCESS_BLOCK
; }
2455 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
2456 int get_params(optional_yield y
);
2457 void execute(optional_yield y
) override
;
2458 dmc::client_id
dmclock_client() override
{ return dmc::client_id::metadata
; }
2461 class RGWGetBucketPublicAccessBlock
: public RGWOp
{
2463 PublicAccessBlockConfiguration access_conf
;
2465 int verify_permission(optional_yield y
) override
;
2466 const char* name() const override
{ return "get_bucket_public_access_block";}
2467 virtual RGWOpType
get_type() override
{ return RGW_OP_GET_BUCKET_PUBLIC_ACCESS_BLOCK
; }
2468 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_READ
; }
2469 int get_params(optional_yield y
);
2470 void execute(optional_yield y
) override
;
2471 dmc::client_id
dmclock_client() override
{ return dmc::client_id::metadata
; }
2474 class RGWDeleteBucketPublicAccessBlock
: public RGWOp
{
2476 PublicAccessBlockConfiguration access_conf
;
2478 int verify_permission(optional_yield y
) override
;
2479 const char* name() const override
{ return "delete_bucket_public_access_block";}
2480 virtual RGWOpType
get_type() override
{ return RGW_OP_DELETE_BUCKET_PUBLIC_ACCESS_BLOCK
; }
2481 virtual uint32_t op_mask() override
{ return RGW_OP_TYPE_WRITE
; }
2482 int get_params(optional_yield y
);
2483 void execute(optional_yield y
) override
;
2484 void send_response() override
;
2485 dmc::client_id
dmclock_client() override
{ return dmc::client_id::metadata
; }
2488 inline int parse_value_and_bound(
2489 const string
&input
,
2491 const long lower_bound
,
2492 const long upper_bound
,
2493 const long default_val
)
2495 if (!input
.empty()) {
2497 output
= strtol(input
.c_str(), &endptr
, 10);
2499 if (endptr
== input
.c_str()) return -EINVAL
;
2500 while (*endptr
&& isspace(*endptr
)) // ignore white space
2506 if(output
> upper_bound
) {
2507 output
= upper_bound
;
2509 if(output
< lower_bound
) {
2510 output
= lower_bound
;
2513 output
= default_val
;
2519 #endif /* CEPH_RGW_OP_H */