1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2004-2009 Sage Weil <sage@newdream.net>
8 * Copyright (C) 2015 Yehuda Sadeh <yehuda@redhat.com>
10 * This is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License version 2.1, as published by the Free Software
13 * Foundation. See file COPYING.
20 #include <string_view>
22 #include <unordered_map>
24 #include "common/ceph_crypto.h"
25 #include "common/random_string.h"
27 #include "rgw_bucket_layout.h"
29 #include "rgw_iam_policy.h"
30 #include "rgw_quota.h"
31 #include "rgw_string.h"
32 #include "common/async/yield_context.h"
33 #include "rgw_website.h"
34 #include "rgw_object_lock.h"
36 #include "rgw_op_type.h"
37 #include "rgw_sync_policy.h"
38 #include "cls/version/cls_version_types.h"
39 #include "cls/user/cls_user_types.h"
40 #include "cls/rgw/cls_rgw_types.h"
41 #include "include/rados/librados.hpp"
42 #include "rgw_public_access.h"
43 #include "common/tracer.h"
53 using Attrs
= std::map
<std::string
, ceph::buffer::list
>;
56 using ceph::crypto::MD5
;
58 #define RGW_ATTR_PREFIX "user.rgw."
60 #define RGW_HTTP_RGWX_ATTR_PREFIX "RGWX_ATTR_"
61 #define RGW_HTTP_RGWX_ATTR_PREFIX_OUT "Rgwx-Attr-"
63 #define RGW_AMZ_PREFIX "x-amz-"
64 #define RGW_AMZ_META_PREFIX RGW_AMZ_PREFIX "meta-"
65 #define RGW_AMZ_WEBSITE_REDIRECT_LOCATION RGW_AMZ_PREFIX "website-redirect-location"
66 #define RGW_AMZ_TAG_COUNT RGW_AMZ_PREFIX "tagging-count"
68 #define RGW_SYS_PARAM_PREFIX "rgwx-"
70 #define RGW_ATTR_ACL RGW_ATTR_PREFIX "acl"
71 #define RGW_ATTR_RATELIMIT RGW_ATTR_PREFIX "ratelimit"
72 #define RGW_ATTR_LC RGW_ATTR_PREFIX "lc"
73 #define RGW_ATTR_CORS RGW_ATTR_PREFIX "cors"
74 #define RGW_ATTR_ETAG RGW_ATTR_PREFIX "etag"
75 #define RGW_ATTR_BUCKETS RGW_ATTR_PREFIX "buckets"
76 #define RGW_ATTR_META_PREFIX RGW_ATTR_PREFIX RGW_AMZ_META_PREFIX
77 #define RGW_ATTR_CONTENT_TYPE RGW_ATTR_PREFIX "content_type"
78 #define RGW_ATTR_CACHE_CONTROL RGW_ATTR_PREFIX "cache_control"
79 #define RGW_ATTR_CONTENT_DISP RGW_ATTR_PREFIX "content_disposition"
80 #define RGW_ATTR_CONTENT_ENC RGW_ATTR_PREFIX "content_encoding"
81 #define RGW_ATTR_CONTENT_LANG RGW_ATTR_PREFIX "content_language"
82 #define RGW_ATTR_EXPIRES RGW_ATTR_PREFIX "expires"
83 #define RGW_ATTR_DELETE_AT RGW_ATTR_PREFIX "delete_at"
84 #define RGW_ATTR_ID_TAG RGW_ATTR_PREFIX "idtag"
85 #define RGW_ATTR_TAIL_TAG RGW_ATTR_PREFIX "tail_tag"
86 #define RGW_ATTR_SHADOW_OBJ RGW_ATTR_PREFIX "shadow_name"
87 #define RGW_ATTR_MANIFEST RGW_ATTR_PREFIX "manifest"
88 #define RGW_ATTR_USER_MANIFEST RGW_ATTR_PREFIX "user_manifest"
89 #define RGW_ATTR_AMZ_WEBSITE_REDIRECT_LOCATION RGW_ATTR_PREFIX RGW_AMZ_WEBSITE_REDIRECT_LOCATION
90 #define RGW_ATTR_SLO_MANIFEST RGW_ATTR_PREFIX "slo_manifest"
91 /* Information whether an object is SLO or not must be exposed to
92 * user through custom HTTP header named X-Static-Large-Object. */
93 #define RGW_ATTR_SLO_UINDICATOR RGW_ATTR_META_PREFIX "static-large-object"
94 #define RGW_ATTR_X_ROBOTS_TAG RGW_ATTR_PREFIX "x-robots-tag"
95 #define RGW_ATTR_STORAGE_CLASS RGW_ATTR_PREFIX "storage_class"
98 #define RGW_ATTR_OBJECT_LOCK RGW_ATTR_PREFIX "object-lock"
99 #define RGW_ATTR_OBJECT_RETENTION RGW_ATTR_PREFIX "object-retention"
100 #define RGW_ATTR_OBJECT_LEGAL_HOLD RGW_ATTR_PREFIX "object-legal-hold"
103 #define RGW_ATTR_PG_VER RGW_ATTR_PREFIX "pg_ver"
104 #define RGW_ATTR_SOURCE_ZONE RGW_ATTR_PREFIX "source_zone"
105 #define RGW_ATTR_TAGS RGW_ATTR_PREFIX RGW_AMZ_PREFIX "tagging"
107 #define RGW_ATTR_TEMPURL_KEY1 RGW_ATTR_META_PREFIX "temp-url-key"
108 #define RGW_ATTR_TEMPURL_KEY2 RGW_ATTR_META_PREFIX "temp-url-key-2"
110 /* Account/container quota of the Swift API. */
111 #define RGW_ATTR_QUOTA_NOBJS RGW_ATTR_META_PREFIX "quota-count"
112 #define RGW_ATTR_QUOTA_MSIZE RGW_ATTR_META_PREFIX "quota-bytes"
114 /* Static Web Site of Swift API. */
115 #define RGW_ATTR_WEB_INDEX RGW_ATTR_META_PREFIX "web-index"
116 #define RGW_ATTR_WEB_ERROR RGW_ATTR_META_PREFIX "web-error"
117 #define RGW_ATTR_WEB_LISTINGS RGW_ATTR_META_PREFIX "web-listings"
118 #define RGW_ATTR_WEB_LIST_CSS RGW_ATTR_META_PREFIX "web-listings-css"
119 #define RGW_ATTR_SUBDIR_MARKER RGW_ATTR_META_PREFIX "web-directory-type"
121 #define RGW_ATTR_OLH_PREFIX RGW_ATTR_PREFIX "olh."
123 #define RGW_ATTR_OLH_INFO RGW_ATTR_OLH_PREFIX "info"
124 #define RGW_ATTR_OLH_VER RGW_ATTR_OLH_PREFIX "ver"
125 #define RGW_ATTR_OLH_ID_TAG RGW_ATTR_OLH_PREFIX "idtag"
126 #define RGW_ATTR_OLH_PENDING_PREFIX RGW_ATTR_OLH_PREFIX "pending."
128 #define RGW_ATTR_COMPRESSION RGW_ATTR_PREFIX "compression"
130 #define RGW_ATTR_APPEND_PART_NUM RGW_ATTR_PREFIX "append_part_num"
133 #define RGW_ATTR_IAM_POLICY RGW_ATTR_PREFIX "iam-policy"
134 #define RGW_ATTR_USER_POLICY RGW_ATTR_PREFIX "user-policy"
135 #define RGW_ATTR_PUBLIC_ACCESS RGW_ATTR_PREFIX "public-access"
137 /* RGW File Attributes */
138 #define RGW_ATTR_UNIX_KEY1 RGW_ATTR_PREFIX "unix-key1"
139 #define RGW_ATTR_UNIX1 RGW_ATTR_PREFIX "unix1"
141 #define RGW_ATTR_CRYPT_PREFIX RGW_ATTR_PREFIX "crypt."
142 #define RGW_ATTR_CRYPT_MODE RGW_ATTR_CRYPT_PREFIX "mode"
143 #define RGW_ATTR_CRYPT_KEYMD5 RGW_ATTR_CRYPT_PREFIX "keymd5"
144 #define RGW_ATTR_CRYPT_KEYID RGW_ATTR_CRYPT_PREFIX "keyid"
145 #define RGW_ATTR_CRYPT_KEYSEL RGW_ATTR_CRYPT_PREFIX "keysel"
146 #define RGW_ATTR_CRYPT_CONTEXT RGW_ATTR_CRYPT_PREFIX "context"
147 #define RGW_ATTR_CRYPT_DATAKEY RGW_ATTR_CRYPT_PREFIX "datakey"
149 /* SSE-S3 Encryption Attributes */
150 #define RGW_ATTR_BUCKET_ENCRYPTION_PREFIX RGW_ATTR_PREFIX "sse-s3."
151 #define RGW_ATTR_BUCKET_ENCRYPTION_POLICY RGW_ATTR_BUCKET_ENCRYPTION_PREFIX "policy"
152 #define RGW_ATTR_BUCKET_ENCRYPTION_KEY_ID RGW_ATTR_BUCKET_ENCRYPTION_PREFIX "key-id"
154 #define RGW_ATTR_TRACE RGW_ATTR_PREFIX "trace"
156 #define RGW_FORMAT_PLAIN 0
157 #define RGW_FORMAT_XML 1
158 #define RGW_FORMAT_JSON 2
159 #define RGW_FORMAT_HTML 3
161 #define RGW_CAP_READ 0x1
162 #define RGW_CAP_WRITE 0x2
163 #define RGW_CAP_ALL (RGW_CAP_READ | RGW_CAP_WRITE)
165 #define RGW_REST_SWIFT 0x1
166 #define RGW_REST_SWIFT_AUTH 0x2
167 #define RGW_REST_S3 0x4
168 #define RGW_REST_WEBSITE 0x8
169 #define RGW_REST_STS 0x10
170 #define RGW_REST_IAM 0x20
172 #define RGW_SUSPENDED_USER_AUID (uint64_t)-2
174 #define RGW_OP_TYPE_READ 0x01
175 #define RGW_OP_TYPE_WRITE 0x02
176 #define RGW_OP_TYPE_DELETE 0x04
178 #define RGW_OP_TYPE_MODIFY (RGW_OP_TYPE_WRITE | RGW_OP_TYPE_DELETE)
179 #define RGW_OP_TYPE_ALL (RGW_OP_TYPE_READ | RGW_OP_TYPE_WRITE | RGW_OP_TYPE_DELETE)
181 #define RGW_DEFAULT_MAX_BUCKETS 1000
183 #define RGW_DEFER_TO_BUCKET_ACLS_RECURSE 1
184 #define RGW_DEFER_TO_BUCKET_ACLS_FULL_CONTROL 2
186 #define STATUS_CREATED 1900
187 #define STATUS_ACCEPTED 1901
188 #define STATUS_NO_CONTENT 1902
189 #define STATUS_PARTIAL_CONTENT 1903
190 #define STATUS_REDIRECT 1904
191 #define STATUS_NO_APPLY 1905
192 #define STATUS_APPLIED 1906
194 #define ERR_INVALID_BUCKET_NAME 2000
195 #define ERR_INVALID_OBJECT_NAME 2001
196 #define ERR_NO_SUCH_BUCKET 2002
197 #define ERR_METHOD_NOT_ALLOWED 2003
198 #define ERR_INVALID_DIGEST 2004
199 #define ERR_BAD_DIGEST 2005
200 #define ERR_UNRESOLVABLE_EMAIL 2006
201 #define ERR_INVALID_PART 2007
202 #define ERR_INVALID_PART_ORDER 2008
203 #define ERR_NO_SUCH_UPLOAD 2009
204 #define ERR_REQUEST_TIMEOUT 2010
205 #define ERR_LENGTH_REQUIRED 2011
206 #define ERR_REQUEST_TIME_SKEWED 2012
207 #define ERR_BUCKET_EXISTS 2013
208 #define ERR_BAD_URL 2014
209 #define ERR_PRECONDITION_FAILED 2015
210 #define ERR_NOT_MODIFIED 2016
211 #define ERR_INVALID_UTF8 2017
212 #define ERR_UNPROCESSABLE_ENTITY 2018
213 #define ERR_TOO_LARGE 2019
214 #define ERR_TOO_MANY_BUCKETS 2020
215 #define ERR_INVALID_REQUEST 2021
216 #define ERR_TOO_SMALL 2022
217 #define ERR_NOT_FOUND 2023
218 #define ERR_PERMANENT_REDIRECT 2024
219 #define ERR_LOCKED 2025
220 #define ERR_QUOTA_EXCEEDED 2026
221 #define ERR_SIGNATURE_NO_MATCH 2027
222 #define ERR_INVALID_ACCESS_KEY 2028
223 #define ERR_MALFORMED_XML 2029
224 #define ERR_USER_EXIST 2030
225 #define ERR_NOT_SLO_MANIFEST 2031
226 #define ERR_EMAIL_EXIST 2032
227 #define ERR_KEY_EXIST 2033
228 #define ERR_INVALID_SECRET_KEY 2034
229 #define ERR_INVALID_KEY_TYPE 2035
230 #define ERR_INVALID_CAP 2036
231 #define ERR_INVALID_TENANT_NAME 2037
232 #define ERR_WEBSITE_REDIRECT 2038
233 #define ERR_NO_SUCH_WEBSITE_CONFIGURATION 2039
234 #define ERR_AMZ_CONTENT_SHA256_MISMATCH 2040
235 #define ERR_NO_SUCH_LC 2041
236 #define ERR_NO_SUCH_USER 2042
237 #define ERR_NO_SUCH_SUBUSER 2043
238 #define ERR_MFA_REQUIRED 2044
239 #define ERR_NO_SUCH_CORS_CONFIGURATION 2045
240 #define ERR_NO_SUCH_OBJECT_LOCK_CONFIGURATION 2046
241 #define ERR_INVALID_RETENTION_PERIOD 2047
242 #define ERR_NO_SUCH_BUCKET_ENCRYPTION_CONFIGURATION 2048
243 #define ERR_USER_SUSPENDED 2100
244 #define ERR_INTERNAL_ERROR 2200
245 #define ERR_NOT_IMPLEMENTED 2201
246 #define ERR_SERVICE_UNAVAILABLE 2202
247 #define ERR_ROLE_EXISTS 2203
248 #define ERR_MALFORMED_DOC 2204
249 #define ERR_NO_ROLE_FOUND 2205
250 #define ERR_DELETE_CONFLICT 2206
251 #define ERR_NO_SUCH_BUCKET_POLICY 2207
252 #define ERR_INVALID_LOCATION_CONSTRAINT 2208
253 #define ERR_TAG_CONFLICT 2209
254 #define ERR_INVALID_TAG 2210
255 #define ERR_ZERO_IN_URL 2211
256 #define ERR_MALFORMED_ACL_ERROR 2212
257 #define ERR_ZONEGROUP_DEFAULT_PLACEMENT_MISCONFIGURATION 2213
258 #define ERR_INVALID_ENCRYPTION_ALGORITHM 2214
259 #define ERR_INVALID_CORS_RULES_ERROR 2215
260 #define ERR_NO_CORS_FOUND 2216
261 #define ERR_INVALID_WEBSITE_ROUTING_RULES_ERROR 2217
262 #define ERR_RATE_LIMITED 2218
263 #define ERR_POSITION_NOT_EQUAL_TO_LENGTH 2219
264 #define ERR_OBJECT_NOT_APPENDABLE 2220
265 #define ERR_INVALID_BUCKET_STATE 2221
266 #define ERR_INVALID_OBJECT_STATE 2222
268 #define ERR_BUSY_RESHARDING 2300
269 #define ERR_NO_SUCH_ENTITY 2301
270 #define ERR_LIMIT_EXCEEDED 2302
273 #define ERR_PACKED_POLICY_TOO_LARGE 2400
274 #define ERR_INVALID_IDENTITY_TOKEN 2401
276 #define ERR_NO_SUCH_TAG_SET 2402
279 #define UINT32_MAX (0xffffffffu)
284 typedef void *RGWAccessHandle
;
286 enum RGWIntentEvent
{
296 /** Store error returns for output at a different point in the program */
300 bool is_clear() const;
302 friend std::ostream
& operator<<(std::ostream
& oss
, const rgw_err
&err
);
306 std::string err_code
;
311 /* Helper class used for RGWHTTPArgs parsing */
314 const std::string str
;
318 explicit NameVal(const std::string
& nv
) : str(nv
) {}
322 std::string
& get_name() { return name
; }
323 std::string
& get_val() { return val
; }
326 /** Stores the XML arguments associated with the HTTP request in req_state*/
328 std::string str
, empty_str
;
329 std::map
<std::string
, std::string
> val_map
;
330 std::map
<std::string
, std::string
> sys_val_map
;
331 std::map
<std::string
, std::string
> sub_resources
;
332 bool has_resp_modifier
= false;
333 bool admin_subresource_added
= false;
335 RGWHTTPArgs() = default;
336 explicit RGWHTTPArgs(const std::string
& s
, const DoutPrefixProvider
*dpp
) {
341 /** Set the arguments; as received */
342 void set(const std::string
& s
) {
343 has_resp_modifier
= false;
345 sub_resources
.clear();
348 /** parse the received arguments */
349 int parse(const DoutPrefixProvider
*dpp
);
350 void append(const std::string
& name
, const std::string
& val
);
351 /** Get the value for a specific argument parameter */
352 const std::string
& get(const std::string
& name
, bool *exists
= NULL
) const;
353 boost::optional
<const std::string
&>
354 get_optional(const std::string
& name
) const;
355 int get_bool(const std::string
& name
, bool *val
, bool *exists
) const;
356 int get_bool(const char *name
, bool *val
, bool *exists
) const;
357 void get_bool(const char *name
, bool *val
, bool def_val
) const;
358 int get_int(const char *name
, int *val
, int def_val
) const;
360 /** Get the value for specific system argument parameter */
361 std::string
sys_get(const std::string
& name
, bool *exists
= nullptr) const;
363 /** see if a parameter is contained in this RGWHTTPArgs */
364 bool exists(const char *name
) const {
365 return (val_map
.find(name
) != std::end(val_map
));
367 bool sub_resource_exists(const char *name
) const {
368 return (sub_resources
.find(name
) != std::end(sub_resources
));
370 bool exist_obj_excl_sub_resource() const {
371 const char* const obj_sub_resource
[] = {"append", "torrent", "uploadId",
372 "partNumber", "versionId"};
373 for (unsigned i
= 0; i
!= std::size(obj_sub_resource
); i
++) {
374 if (sub_resource_exists(obj_sub_resource
[i
])) return true;
379 std::map
<std::string
, std::string
>& get_params() {
382 const std::map
<std::string
, std::string
>& get_params() const {
385 std::map
<std::string
, std::string
>& get_sys_params() {
388 const std::map
<std::string
, std::string
>& get_sys_params() const {
391 const std::map
<std::string
, std::string
>& get_sub_resources() const {
392 return sub_resources
;
394 unsigned get_num_params() const {
395 return val_map
.size();
397 bool has_response_modifier() const {
398 return has_resp_modifier
;
400 void set_system() { /* make all system params visible */
401 std::map
<std::string
, std::string
>::iterator iter
;
402 for (iter
= sys_val_map
.begin(); iter
!= sys_val_map
.end(); ++iter
) {
403 val_map
[iter
->first
] = iter
->second
;
406 const std::string
& get_str() {
411 const char *rgw_conf_get(const std::map
<std::string
, std::string
, ltstr_nocase
>& conf_map
, const char *name
, const char *def_val
);
412 int rgw_conf_get_int(const std::map
<std::string
, std::string
, ltstr_nocase
>& conf_map
, const char *name
, int def_val
);
413 bool rgw_conf_get_bool(const std::map
<std::string
, std::string
, ltstr_nocase
>& conf_map
, const char *name
, bool def_val
);
420 int enable_usage_log
;
421 uint8_t defer_to_bucket_acls
;
422 void init(CephContext
*cct
);
427 defer_to_bucket_acls(0) {
432 std::map
<std::string
, std::string
, ltstr_nocase
> env_map
;
435 void init(CephContext
*cct
);
436 void init(CephContext
*cct
, char **envp
);
437 void set(std::string name
, std::string val
);
438 const char *get(const char *name
, const char *def_val
= nullptr) const;
439 int get_int(const char *name
, int def_val
= 0) const;
440 bool get_bool(const char *name
, bool def_val
= 0);
441 size_t get_size(const char *name
, size_t def_val
= 0) const;
442 bool exists(const char *name
) const;
443 bool exists_prefix(const char *prefix
) const;
444 void remove(const char *name
);
445 const std::map
<std::string
, std::string
, ltstr_nocase
>& get_map() const { return env_map
; }
446 int get_enable_ops_log() const {
447 return conf
.enable_ops_log
;
450 int get_enable_usage_log() const {
451 return conf
.enable_usage_log
;
454 int get_defer_to_bucket_acls() const {
455 return conf
.defer_to_bucket_acls
;
459 // return true if the connection is secure. this either means that the
460 // connection arrived via ssl, or was forwarded as https by a trusted proxy
461 bool rgw_transport_is_secure(CephContext
*cct
, const RGWEnv
& env
);
474 class RGWAccessControlPolicy
;
477 struct RGWAccessKey
{
478 std::string id
; // AccessKey
479 std::string key
; // SecretKey
483 RGWAccessKey(std::string _id
, std::string _key
)
484 : id(std::move(_id
)), key(std::move(_key
)) {}
486 void encode(bufferlist
& bl
) const {
487 ENCODE_START(2, 2, bl
);
494 void decode(bufferlist::const_iterator
& bl
) {
495 DECODE_START_LEGACY_COMPAT_LEN_32(2, 2, 2, bl
);
501 void dump(Formatter
*f
) const;
502 void dump_plain(Formatter
*f
) const;
503 void dump(Formatter
*f
, const std::string
& user
, bool swift
) const;
504 static void generate_test_instances(std::list
<RGWAccessKey
*>& o
);
506 void decode_json(JSONObj
*obj
);
507 void decode_json(JSONObj
*obj
, bool swift
);
509 WRITE_CLASS_ENCODER(RGWAccessKey
)
515 RGWSubUser() : perm_mask(0) {}
516 void encode(bufferlist
& bl
) const {
517 ENCODE_START(2, 2, bl
);
519 encode(perm_mask
, bl
);
523 void decode(bufferlist::const_iterator
& bl
) {
524 DECODE_START_LEGACY_COMPAT_LEN_32(2, 2, 2, bl
);
526 decode(perm_mask
, bl
);
529 void dump(Formatter
*f
) const;
530 void dump(Formatter
*f
, const std::string
& user
) const;
531 static void generate_test_instances(std::list
<RGWSubUser
*>& o
);
533 void decode_json(JSONObj
*obj
);
535 WRITE_CLASS_ENCODER(RGWSubUser
)
539 std::map
<std::string
, uint32_t> caps
;
541 int get_cap(const std::string
& cap
, std::string
& type
, uint32_t *perm
);
542 int add_cap(const std::string
& cap
);
543 int remove_cap(const std::string
& cap
);
545 static int parse_cap_perm(const std::string
& str
, uint32_t *perm
);
546 int add_from_string(const std::string
& str
);
547 int remove_from_string(const std::string
& str
);
549 void encode(bufferlist
& bl
) const {
550 ENCODE_START(1, 1, bl
);
554 void decode(bufferlist::const_iterator
& bl
) {
559 int check_cap(const std::string
& cap
, uint32_t perm
) const;
560 bool is_valid_cap_type(const std::string
& tp
);
561 void dump(Formatter
*f
) const;
562 void dump(Formatter
*f
, const char *name
) const;
564 void decode_json(JSONObj
*obj
);
566 WRITE_CLASS_ENCODER(RGWUserCaps
)
568 void encode_json(const char *name
, const obj_version
& v
, Formatter
*f
);
569 void encode_json(const char *name
, const RGWUserCaps
& val
, Formatter
*f
);
571 void decode_json_obj(obj_version
& v
, JSONObj
*obj
);
585 static std::string RGW_STORAGE_CLASS_STANDARD
= "STANDARD";
587 struct rgw_placement_rule
{
589 std::string storage_class
;
591 rgw_placement_rule() {}
592 rgw_placement_rule(const std::string
& _n
, const std::string
& _sc
) : name(_n
), storage_class(_sc
) {}
593 rgw_placement_rule(const rgw_placement_rule
& _r
, const std::string
& _sc
) : name(_r
.name
) {
597 storage_class
= _r
.storage_class
;
602 return name
.empty() && storage_class
.empty();
605 void inherit_from(const rgw_placement_rule
& r
) {
609 if (storage_class
.empty()) {
610 storage_class
= r
.storage_class
;
616 storage_class
.clear();
619 void init(const std::string
& n
, const std::string
& c
) {
624 static const std::string
& get_canonical_storage_class(const std::string
& storage_class
) {
625 if (storage_class
.empty()) {
626 return RGW_STORAGE_CLASS_STANDARD
;
628 return storage_class
;
631 const std::string
& get_storage_class() const {
632 return get_canonical_storage_class(storage_class
);
635 int compare(const rgw_placement_rule
& r
) const {
636 int c
= name
.compare(r
.name
);
640 return get_storage_class().compare(r
.get_storage_class());
643 bool operator==(const rgw_placement_rule
& r
) const {
644 return (name
== r
.name
&&
645 get_storage_class() == r
.get_storage_class());
648 bool operator!=(const rgw_placement_rule
& r
) const {
649 return !(*this == r
);
652 void encode(bufferlist
& bl
) const {
653 /* no ENCODE_START/END due to backward compatibility */
654 std::string s
= to_str();
658 void decode(bufferlist::const_iterator
& bl
) {
664 std::string
to_str() const {
665 if (standard_storage_class()) {
668 return to_str_explicit();
671 std::string
to_str_explicit() const {
672 return name
+ "/" + storage_class
;
675 void from_str(const std::string
& s
) {
676 size_t pos
= s
.find("/");
677 if (pos
== std::string::npos
) {
679 storage_class
.clear();
682 name
= s
.substr(0, pos
);
683 storage_class
= s
.substr(pos
+ 1);
686 bool standard_storage_class() const {
687 return storage_class
.empty() || storage_class
== RGW_STORAGE_CLASS_STANDARD
;
690 WRITE_CLASS_ENCODER(rgw_placement_rule
)
692 void encode_json(const char *name
, const rgw_placement_rule
& val
, ceph::Formatter
*f
);
693 void decode_json_obj(rgw_placement_rule
& v
, JSONObj
*obj
);
695 inline std::ostream
& operator<<(std::ostream
& out
, const rgw_placement_rule
& rule
) {
696 return out
<< rule
.to_str();
700 struct RGWRateLimitInfo
{
701 int64_t max_write_ops
;
702 int64_t max_read_ops
;
703 int64_t max_write_bytes
;
704 int64_t max_read_bytes
;
705 bool enabled
= false;
707 : max_write_ops(0), max_read_ops(0), max_write_bytes(0), max_read_bytes(0) {}
709 void encode(bufferlist
& bl
) const {
710 ENCODE_START(1, 1, bl
);
711 encode(max_write_ops
, bl
);
712 encode(max_read_ops
, bl
);
713 encode(max_write_bytes
, bl
);
714 encode(max_read_bytes
, bl
);
718 void decode(bufferlist::const_iterator
& bl
) {
720 decode(max_write_ops
,bl
);
721 decode(max_read_ops
, bl
);
722 decode(max_write_bytes
,bl
);
723 decode(max_read_bytes
, bl
);
728 void dump(Formatter
*f
) const;
730 void decode_json(JSONObj
*obj
);
733 WRITE_CLASS_ENCODER(RGWRateLimitInfo
)
738 std::string display_name
;
739 std::string user_email
;
740 std::map
<std::string
, RGWAccessKey
> access_keys
;
741 std::map
<std::string
, RGWAccessKey
> swift_keys
;
742 std::map
<std::string
, RGWSubUser
> subusers
;
749 rgw_placement_rule default_placement
;
750 std::list
<std::string
> placement_tags
;
751 RGWQuotaInfo bucket_quota
;
752 std::map
<int, std::string
> temp_url_keys
;
753 RGWQuotaInfo user_quota
;
755 std::set
<std::string
> mfa_ids
;
756 std::string assumed_role_arn
;
760 max_buckets(RGW_DEFAULT_MAX_BUCKETS
),
761 op_mask(RGW_OP_TYPE_ALL
),
767 RGWAccessKey
* get_key(const std::string
& access_key
) {
768 if (access_keys
.empty())
771 auto k
= access_keys
.find(access_key
);
772 if (k
== access_keys
.end())
778 void encode(bufferlist
& bl
) const {
779 ENCODE_START(22, 9, bl
);
780 encode((uint64_t)0, bl
); // old auid
781 std::string access_key
;
782 std::string secret_key
;
783 if (!access_keys
.empty()) {
784 std::map
<std::string
, RGWAccessKey
>::const_iterator iter
= access_keys
.begin();
785 const RGWAccessKey
& k
= iter
->second
;
789 encode(access_key
, bl
);
790 encode(secret_key
, bl
);
791 encode(display_name
, bl
);
792 encode(user_email
, bl
);
793 std::string swift_name
;
794 std::string swift_key
;
795 if (!swift_keys
.empty()) {
796 std::map
<std::string
, RGWAccessKey
>::const_iterator iter
= swift_keys
.begin();
797 const RGWAccessKey
& k
= iter
->second
;
801 encode(swift_name
, bl
);
802 encode(swift_key
, bl
);
803 encode(user_id
.id
, bl
);
804 encode(access_keys
, bl
);
805 encode(subusers
, bl
);
806 encode(suspended
, bl
);
807 encode(swift_keys
, bl
);
808 encode(max_buckets
, bl
);
812 encode(default_placement
, bl
);
813 encode(placement_tags
, bl
);
814 encode(bucket_quota
, bl
);
815 encode(temp_url_keys
, bl
);
816 encode(user_quota
, bl
);
817 encode(user_id
.tenant
, bl
);
821 encode(assumed_role_arn
, bl
);
822 encode(user_id
.ns
, bl
);
825 void decode(bufferlist::const_iterator
& bl
) {
826 DECODE_START_LEGACY_COMPAT_LEN_32(22, 9, 9, bl
);
829 decode(old_auid
, bl
);
831 std::string access_key
;
832 std::string secret_key
;
833 decode(access_key
, bl
);
834 decode(secret_key
, bl
);
839 access_keys
[access_key
] = k
;
841 decode(display_name
, bl
);
842 decode(user_email
, bl
);
843 /* We populate swift_keys map later nowadays, but we have to decode. */
844 std::string swift_name
;
845 std::string swift_key
;
846 if (struct_v
>= 3) decode(swift_name
, bl
);
847 if (struct_v
>= 4) decode(swift_key
, bl
);
849 decode(user_id
.id
, bl
);
851 user_id
.id
= access_key
;
853 decode(access_keys
, bl
);
854 decode(subusers
, bl
);
858 decode(suspended
, bl
);
861 decode(swift_keys
, bl
);
863 if (struct_v
>= 10) {
864 decode(max_buckets
, bl
);
866 max_buckets
= RGW_DEFAULT_MAX_BUCKETS
;
868 if (struct_v
>= 11) {
871 if (struct_v
>= 12) {
874 op_mask
= RGW_OP_TYPE_ALL
;
876 if (struct_v
>= 13) {
878 decode(default_placement
, bl
);
879 decode(placement_tags
, bl
); /* tags of allowed placement rules */
881 if (struct_v
>= 14) {
882 decode(bucket_quota
, bl
);
884 if (struct_v
>= 15) {
885 decode(temp_url_keys
, bl
);
887 if (struct_v
>= 16) {
888 decode(user_quota
, bl
);
890 if (struct_v
>= 17) {
891 decode(user_id
.tenant
, bl
);
893 user_id
.tenant
.clear();
895 if (struct_v
>= 18) {
898 if (struct_v
>= 19) {
901 if (struct_v
>= 20) {
904 if (struct_v
>= 21) {
905 decode(assumed_role_arn
, bl
);
907 if (struct_v
>= 22) {
908 decode(user_id
.ns
, bl
);
914 void dump(Formatter
*f
) const;
915 static void generate_test_instances(std::list
<RGWUserInfo
*>& o
);
917 void decode_json(JSONObj
*obj
);
919 WRITE_CLASS_ENCODER(RGWUserInfo
)
927 rgw_raw_obj(const rgw_pool
& _pool
, const std::string
& _oid
) {
930 rgw_raw_obj(const rgw_pool
& _pool
, const std::string
& _oid
, const std::string
& _loc
) : loc(_loc
) {
934 void init(const rgw_pool
& _pool
, const std::string
& _oid
) {
943 void encode(bufferlist
& bl
) const {
944 ENCODE_START(6, 6, bl
);
951 void decode_from_rgw_obj(bufferlist::const_iterator
& bl
);
953 void decode(bufferlist::const_iterator
& bl
) {
954 unsigned ofs
= bl
.get_off();
958 * this object was encoded as rgw_obj, prior to rgw_raw_obj been split out of it,
959 * let's decode it as rgw_obj and convert it
962 decode_from_rgw_obj(bl
);
971 bool operator<(const rgw_raw_obj
& o
) const {
972 int r
= pool
.compare(o
.pool
);
974 r
= oid
.compare(o
.oid
);
976 r
= loc
.compare(o
.loc
);
982 bool operator==(const rgw_raw_obj
& o
) const {
983 return (pool
== o
.pool
&& oid
== o
.oid
&& loc
== o
.loc
);
986 void dump(Formatter
*f
) const;
987 void decode_json(JSONObj
*obj
);
989 WRITE_CLASS_ENCODER(rgw_raw_obj
)
991 inline std::ostream
& operator<<(std::ostream
& out
, const rgw_raw_obj
& o
) {
992 out
<< o
.pool
<< ":" << o
.oid
;
996 struct rgw_bucket_placement
{
997 rgw_placement_rule placement_rule
;
1000 void dump(Formatter
*f
) const;
1003 struct RGWObjVersionTracker
{
1004 obj_version read_version
;
1005 obj_version write_version
;
1007 obj_version
*version_for_read() {
1008 return &read_version
;
1011 obj_version
*version_for_write() {
1012 if (write_version
.ver
== 0)
1015 return &write_version
;
1018 obj_version
*version_for_check() {
1019 if (read_version
.ver
== 0)
1022 return &read_version
;
1025 void prepare_op_for_read(librados::ObjectReadOperation
*op
);
1026 void prepare_op_for_write(librados::ObjectWriteOperation
*op
);
1031 read_version
= obj_version();
1032 write_version
= obj_version();
1035 void generate_new_write_ver(CephContext
*cct
);
1038 inline std::ostream
& operator<<(std::ostream
& out
, const obj_version
&v
)
1040 out
<< v
.tag
<< ":" << v
.ver
;
1044 inline std::ostream
& operator<<(std::ostream
& out
, const RGWObjVersionTracker
&ot
)
1046 out
<< "{r=" << ot
.read_version
<< ",w=" << ot
.write_version
<< "}";
1050 enum RGWBucketFlags
{
1051 BUCKET_SUSPENDED
= 0x1,
1052 BUCKET_VERSIONED
= 0x2,
1053 BUCKET_VERSIONS_SUSPENDED
= 0x4,
1054 BUCKET_DATASYNC_DISABLED
= 0X8,
1055 BUCKET_MFA_ENABLED
= 0X10,
1056 BUCKET_OBJ_LOCK_ENABLED
= 0X20,
1061 struct RGWBucketInfo
{
1065 std::string zonegroup
;
1066 ceph::real_time creation_time
;
1067 rgw_placement_rule placement_rule
;
1068 bool has_instance_obj
{false};
1069 RGWObjVersionTracker objv_tracker
; /* we don't need to serialize this, for runtime tracking */
1072 // layout of bucket index objects
1073 rgw::BucketLayout layout
;
1075 // Represents the number of bucket index object shards:
1076 // - value of 0 indicates there is no sharding (this is by default
1077 // before this feature is implemented).
1078 // - value of UINT32_T::MAX indicates this is a blind bucket.
1080 // Represents the shard number for blind bucket.
1081 const static uint32_t NUM_SHARDS_BLIND_BUCKET
;
1083 bool requester_pays
{false};
1085 bool has_website
{false};
1086 RGWBucketWebsiteConf website_conf
;
1088 bool swift_versioning
{false};
1089 std::string swift_ver_location
;
1091 std::map
<std::string
, uint32_t> mdsearch_config
;
1094 cls_rgw_reshard_status reshard_status
{cls_rgw_reshard_status::NOT_RESHARDING
};
1095 std::string new_bucket_instance_id
;
1097 RGWObjectLock obj_lock
;
1099 std::optional
<rgw_sync_policy_info
> sync_policy
;
1101 void encode(bufferlist
& bl
) const;
1102 void decode(bufferlist::const_iterator
& bl
);
1104 void dump(Formatter
*f
) const;
1105 static void generate_test_instances(std::list
<RGWBucketInfo
*>& o
);
1107 void decode_json(JSONObj
*obj
);
1109 bool versioned() const { return (flags
& BUCKET_VERSIONED
) != 0; }
1110 int versioning_status() const { return flags
& (BUCKET_VERSIONED
| BUCKET_VERSIONS_SUSPENDED
| BUCKET_MFA_ENABLED
); }
1111 bool versioning_enabled() const { return (versioning_status() & (BUCKET_VERSIONED
| BUCKET_VERSIONS_SUSPENDED
)) == BUCKET_VERSIONED
; }
1112 bool mfa_enabled() const { return (versioning_status() & BUCKET_MFA_ENABLED
) != 0; }
1113 bool datasync_flag_enabled() const { return (flags
& BUCKET_DATASYNC_DISABLED
) == 0; }
1114 bool obj_lock_enabled() const { return (flags
& BUCKET_OBJ_LOCK_ENABLED
) != 0; }
1116 bool has_swift_versioning() const {
1117 /* A bucket may be versioned through one mechanism only. */
1118 return swift_versioning
&& !versioned();
1121 void set_sync_policy(rgw_sync_policy_info
&& policy
);
1123 bool empty_sync_policy() const;
1128 WRITE_CLASS_ENCODER(RGWBucketInfo
)
1130 struct RGWBucketEntryPoint
1134 ceph::real_time creation_time
;
1137 bool has_bucket_info
;
1138 RGWBucketInfo old_bucket_info
;
1140 RGWBucketEntryPoint() : linked(false), has_bucket_info(false) {}
1142 void encode(bufferlist
& bl
) const {
1143 ENCODE_START(10, 8, bl
);
1145 encode(owner
.id
, bl
);
1147 uint64_t ctime
= (uint64_t)real_clock::to_time_t(creation_time
);
1150 encode(creation_time
, bl
);
1153 void decode(bufferlist::const_iterator
& bl
) {
1154 auto orig_iter
= bl
;
1155 DECODE_START_LEGACY_COMPAT_LEN_32(10, 4, 4, bl
);
1157 /* ouch, old entry, contains the bucket info itself */
1158 old_bucket_info
.decode(orig_iter
);
1159 has_bucket_info
= true;
1162 has_bucket_info
= false;
1164 decode(owner
.id
, bl
);
1168 if (struct_v
< 10) {
1169 creation_time
= real_clock::from_time_t((time_t)ctime
);
1171 if (struct_v
>= 9) {
1174 if (struct_v
>= 10) {
1175 decode(creation_time
, bl
);
1180 void dump(Formatter
*f
) const;
1181 void decode_json(JSONObj
*obj
);
1182 static void generate_test_instances(std::list
<RGWBucketEntryPoint
*>& o
);
1184 WRITE_CLASS_ENCODER(RGWBucketEntryPoint
)
1186 struct RGWStorageStats
1188 RGWObjCategory category
;
1190 uint64_t size_rounded
;
1191 uint64_t num_objects
;
1192 uint64_t size_utilized
{0}; //< size after compression, encryption
1193 bool dump_utilized
; // whether dump should include utilized values
1195 RGWStorageStats(bool _dump_utilized
=true)
1196 : category(RGWObjCategory::None
),
1200 dump_utilized(_dump_utilized
)
1203 void dump(Formatter
*f
) const;
1204 }; // RGWStorageStats
1208 /* Namespaced forward declarations. */
1212 class AWSBrowserUploadAbstractor
;
1222 using meta_map_t
= boost::container::flat_map
<std::string
, std::string
>;
1227 meta_map_t x_meta_map
;
1228 meta_map_t crypt_attribute_map
;
1232 std::string script_uri
;
1233 std::string request_uri
;
1234 std::string request_uri_aws4
;
1235 std::string effective_uri
;
1236 std::string request_params
;
1238 std::string storage_class
;
1240 req_info(CephContext
*cct
, const RGWEnv
*env
);
1241 void rebuild_from(req_info
& src
);
1242 void init_meta_info(const DoutPrefixProvider
*dpp
, bool *found_bad_meta
);
1245 typedef cls_rgw_obj_key rgw_obj_index_key
;
1247 struct rgw_obj_key
{
1249 std::string instance
;
1253 // cppcheck-suppress noExplicitConstructor
1254 rgw_obj_key(const std::string
& n
) : name(n
) {}
1255 rgw_obj_key(const std::string
& n
, const std::string
& i
) : name(n
), instance(i
) {}
1256 rgw_obj_key(const std::string
& n
, const std::string
& i
, const std::string
& _ns
) : name(n
), instance(i
), ns(_ns
) {}
1258 rgw_obj_key(const rgw_obj_index_key
& k
) {
1259 parse_index_key(k
.name
, &name
, &ns
);
1260 instance
= k
.instance
;
1263 static void parse_index_key(const std::string
& key
, std::string
*name
, std::string
*ns
) {
1264 if (key
[0] != '_') {
1269 if (key
[1] == '_') {
1270 *name
= key
.substr(1);
1274 ssize_t pos
= key
.find('_', 1);
1276 /* shouldn't happen, just use key */
1282 *name
= key
.substr(pos
+ 1);
1283 *ns
= key
.substr(1, pos
-1);
1286 void set(const std::string
& n
) {
1292 void set(const std::string
& n
, const std::string
& i
) {
1298 void set(const std::string
& n
, const std::string
& i
, const std::string
& _ns
) {
1304 bool set(const rgw_obj_index_key
& index_key
) {
1305 if (!parse_raw_oid(index_key
.name
, this)) {
1308 instance
= index_key
.instance
;
1312 void set_instance(const std::string
& i
) {
1316 const std::string
& get_instance() const {
1320 void set_ns(const std::string
& _ns
) {
1324 const std::string
& get_ns() const {
1328 std::string
get_index_key_name() const {
1330 if (name
.size() < 1 || name
[0] != '_') {
1333 return std::string("_") + name
;
1336 char buf
[ns
.size() + 16];
1337 snprintf(buf
, sizeof(buf
), "_%s_", ns
.c_str());
1338 return std::string(buf
) + name
;
1341 void get_index_key(rgw_obj_index_key
*key
) const {
1342 key
->name
= get_index_key_name();
1343 key
->instance
= instance
;
1346 std::string
get_loc() const {
1348 * For backward compatibility. Older versions used to have object locator on all objects,
1349 * however, the name was the effective object locator. This had the same effect as not
1350 * having object locator at all for most objects but the ones that started with underscore as
1351 * these were escaped.
1353 if (name
[0] == '_' && ns
.empty()) {
1360 bool empty() const {
1361 return name
.empty();
1364 bool have_null_instance() const {
1365 return instance
== "null";
1368 bool have_instance() const {
1369 return !instance
.empty();
1372 bool need_to_encode_instance() const {
1373 return have_instance() && !have_null_instance();
1376 std::string
get_oid() const {
1377 if (ns
.empty() && !need_to_encode_instance()) {
1378 if (name
.size() < 1 || name
[0] != '_') {
1381 return std::string("_") + name
;
1384 std::string oid
= "_";
1386 if (need_to_encode_instance()) {
1387 oid
.append(std::string(":") + instance
);
1394 bool operator==(const rgw_obj_key
& k
) const {
1395 return (name
.compare(k
.name
) == 0) &&
1396 (instance
.compare(k
.instance
) == 0);
1399 bool operator<(const rgw_obj_key
& k
) const {
1400 int r
= name
.compare(k
.name
);
1402 r
= instance
.compare(k
.instance
);
1407 bool operator<=(const rgw_obj_key
& k
) const {
1408 return !(k
< *this);
1411 static void parse_ns_field(std::string
& ns
, std::string
& instance
) {
1412 int pos
= ns
.find(':');
1414 instance
= ns
.substr(pos
+ 1);
1415 ns
= ns
.substr(0, pos
);
1421 // takes an oid and parses out the namespace (ns), name, and
1423 static bool parse_raw_oid(const std::string
& oid
, rgw_obj_key
*key
) {
1424 key
->instance
.clear();
1426 if (oid
[0] != '_') {
1431 if (oid
.size() >= 2 && oid
[1] == '_') {
1432 key
->name
= oid
.substr(1);
1436 if (oid
.size() < 3) // for namespace, min size would be 3: _x_
1439 size_t pos
= oid
.find('_', 2); // oid must match ^_[^_].+$
1440 if (pos
== std::string::npos
)
1443 key
->ns
= oid
.substr(1, pos
- 1);
1444 parse_ns_field(key
->ns
, key
->instance
);
1446 key
->name
= oid
.substr(pos
+ 1);
1451 * Translate a namespace-mangled object name to the user-facing name
1452 * existing in the given namespace.
1454 * If the object is part of the given namespace, it returns true
1455 * and cuts down the name to the unmangled version. If it is not
1456 * part of the given namespace, it returns false.
1458 static bool oid_to_key_in_ns(const std::string
& oid
, rgw_obj_key
*key
, const std::string
& ns
) {
1459 bool ret
= parse_raw_oid(oid
, key
);
1464 return (ns
== key
->ns
);
1468 * Given a mangled object name and an empty namespace std::string, this
1469 * function extracts the namespace into the std::string and sets the object
1470 * name to be the unmangled version.
1472 * It returns true after successfully doing so, or
1473 * false if it fails.
1475 static bool strip_namespace_from_name(std::string
& name
, std::string
& ns
, std::string
& instance
) {
1478 if (name
[0] != '_') {
1482 size_t pos
= name
.find('_', 1);
1483 if (pos
== std::string::npos
) {
1487 if (name
[1] == '_') {
1488 name
= name
.substr(1);
1492 size_t period_pos
= name
.find('.');
1493 if (period_pos
< pos
) {
1497 ns
= name
.substr(1, pos
-1);
1498 name
= name
.substr(pos
+1, std::string::npos
);
1500 parse_ns_field(ns
, instance
);
1504 void encode(bufferlist
& bl
) const {
1505 ENCODE_START(2, 1, bl
);
1507 encode(instance
, bl
);
1511 void decode(bufferlist::const_iterator
& bl
) {
1512 DECODE_START(2, bl
);
1514 decode(instance
, bl
);
1515 if (struct_v
>= 2) {
1520 void dump(Formatter
*f
) const;
1521 void decode_json(JSONObj
*obj
);
1523 std::string
to_str() const {
1524 if (instance
.empty()) {
1527 char buf
[name
.size() + instance
.size() + 16];
1528 snprintf(buf
, sizeof(buf
), "%s[%s]", name
.c_str(), instance
.c_str());
1532 WRITE_CLASS_ENCODER(rgw_obj_key
)
1534 inline std::ostream
& operator<<(std::ostream
& out
, const rgw_obj_key
&o
) {
1535 return out
<< o
.to_str();
1538 struct req_init_state
{
1539 /* Keeps [[tenant]:]bucket until we parse the token. */
1540 std::string url_bucket
;
1541 std::string src_bucket
;
1544 #include "rgw_auth.h"
1547 class RGWSysObjectCtx
;
1549 /** Store all the state necessary to complete and respond to an HTTP request*/
1550 struct req_state
: DoutPrefixProvider
{
1552 rgw::io::BasicClient
*cio
{nullptr};
1553 http_op op
{OP_UNKNOWN
};
1554 RGWOpType op_type
{};
1555 std::shared_ptr
<RateLimiter
> ratelimit_data
;
1556 RGWRateLimitInfo user_ratelimit
;
1557 RGWRateLimitInfo bucket_ratelimit
;
1558 std::string ratelimit_bucket_marker
;
1559 std::string ratelimit_user_name
;
1560 bool content_started
{false};
1562 ceph::Formatter
*formatter
{nullptr};
1563 std::string decoded_uri
;
1564 std::string relative_uri
;
1565 const char *length
{nullptr};
1566 int64_t content_length
{0};
1567 std::map
<std::string
, std::string
> generic_attrs
;
1569 bool expect_cont
{false};
1570 uint64_t obj_size
{0};
1571 bool enable_ops_log
;
1572 bool enable_usage_log
;
1573 uint8_t defer_to_bucket_acls
;
1574 uint32_t perm_mask
{0};
1576 /* Set once when url_bucket is parsed and not violated thereafter. */
1577 std::string account_name
;
1579 std::string bucket_tenant
;
1580 std::string bucket_name
;
1582 /* bucket is only created in rgw_build_bucket_policies() and should never be
1584 std::unique_ptr
<rgw::sal::Bucket
> bucket
;
1585 std::unique_ptr
<rgw::sal::Object
> object
;
1586 std::string src_tenant_name
;
1587 std::string src_bucket_name
;
1588 std::unique_ptr
<rgw::sal::Object
> src_object
;
1589 ACLOwner bucket_owner
;
1592 std::string zonegroup_name
;
1593 std::string zonegroup_endpoint
;
1594 std::string bucket_instance_id
;
1595 int bucket_instance_shard_id
{-1};
1596 std::string redirect_zone_endpoint
;
1598 std::string redirect
;
1600 real_time bucket_mtime
;
1601 std::map
<std::string
, ceph::bufferlist
> bucket_attrs
;
1602 bool bucket_exists
{false};
1603 rgw_placement_rule dest_placement
;
1605 bool has_bad_meta
{false};
1607 std::unique_ptr
<rgw::sal::User
> user
;
1610 /* TODO(rzarzynski): switch out to the static_ptr for both members. */
1612 /* Object having the knowledge about an authenticated identity and allowing
1613 * to apply it during the authorization phase (verify_permission() methods
1614 * of a given RGWOp). Thus, it bounds authentication and authorization steps
1615 * through a well-defined interface. For more details, see rgw_auth.h. */
1616 std::unique_ptr
<rgw::auth::Identity
> identity
;
1618 std::shared_ptr
<rgw::auth::Completer
> completer
;
1620 /* A container for credentials of the S3's browser upload. It's necessary
1621 * because: 1) the ::authenticate() method of auth engines and strategies
1622 * take req_state only; 2) auth strategies live much longer than RGWOps -
1623 * there is no way to pass additional data dependencies through ctors. */
1626 friend class RGWPostObj_ObjStore_S3
;
1628 friend class rgw::auth::s3::AWSBrowserUploadAbstractor
;
1629 friend class rgw::auth::s3::STSEngine
;
1631 std::string access_key
;
1632 std::string signature
;
1633 std::string x_amz_algorithm
;
1634 std::string x_amz_credential
;
1635 std::string x_amz_date
;
1636 std::string x_amz_security_token
;
1637 ceph::bufferlist encoded_policy
;
1641 std::unique_ptr
<RGWAccessControlPolicy
> user_acl
;
1642 std::unique_ptr
<RGWAccessControlPolicy
> bucket_acl
;
1643 std::unique_ptr
<RGWAccessControlPolicy
> object_acl
;
1645 rgw::IAM::Environment env
;
1646 boost::optional
<rgw::IAM::Policy
> iam_policy
;
1647 boost::optional
<PublicAccessBlockConfiguration
> bucket_access_conf
;
1648 std::vector
<rgw::IAM::Policy
> iam_user_policies
;
1650 /* Is the request made by an user marked as a system one?
1651 * Being system user means we also have the admin status. */
1652 bool system_request
{false};
1654 std::string canned_acl
;
1655 bool has_acl_header
{false};
1656 bool local_source
{false}; /* source is local */
1660 /* Content-Disposition override for TempURL of Swift API. */
1662 std::string override
;
1663 std::string fallback
;
1666 std::string host_id
;
1669 req_init_state init_state
;
1671 using Clock
= ceph::coarse_real_clock
;
1672 Clock::time_point time
;
1674 Clock::duration
time_elapsed() const { return Clock::now() - time
; }
1676 RGWObjectCtx
*obj_ctx
{nullptr};
1677 std::string dialect
;
1679 std::string trans_id
;
1684 bool mfa_verified
{false};
1686 /// optional coroutine context
1687 optional_yield yield
{null_yield
};
1689 //token claims from STS token for ops log (can be used for Keystone token also)
1690 std::vector
<std::string
> token_claims
;
1692 std::vector
<rgw::IAM::Policy
> session_policies
;
1696 //Principal tags that come in as part of AssumeRoleWithWebIdentity
1697 std::vector
<std::pair
<std::string
, std::string
>> principal_tags
;
1699 req_state(CephContext
* _cct
, RGWEnv
* e
, uint64_t id
);
1703 void set_user(std::unique_ptr
<rgw::sal::User
>& u
) { user
.swap(u
); }
1704 bool is_err() const { return err
.is_err(); }
1706 // implements DoutPrefixProvider
1707 std::ostream
& gen_prefix(std::ostream
& out
) const override
;
1708 CephContext
* get_cct() const override
{ return cct
; }
1709 unsigned get_subsys() const override
{ return ceph_subsys_rgw
; }
1712 void set_req_state_err(struct req_state
*, int);
1713 void set_req_state_err(struct req_state
*, int, const std::string
&);
1714 void set_req_state_err(struct rgw_err
&, int, const int);
1715 void dump(struct req_state
*);
1717 /** Store basic data on bucket */
1718 struct RGWBucketEnt
{
1721 size_t size_rounded
;
1722 ceph::real_time creation_time
;
1725 /* The placement_rule is necessary to calculate per-storage-policy statics
1726 * of the Swift API. Although the info available in RGWBucketInfo, we need
1727 * to duplicate it here to not affect the performance of buckets listing. */
1728 rgw_placement_rule placement_rule
;
1735 RGWBucketEnt(const RGWBucketEnt
&) = default;
1736 RGWBucketEnt(RGWBucketEnt
&&) = default;
1737 explicit RGWBucketEnt(const rgw_user
& u
, cls_user_bucket_entry
&& e
)
1738 : bucket(u
, std::move(e
.bucket
)),
1740 size_rounded(e
.size_rounded
),
1741 creation_time(e
.creation_time
),
1745 RGWBucketEnt
& operator=(const RGWBucketEnt
&) = default;
1747 void convert(cls_user_bucket_entry
*b
) const {
1748 bucket
.convert(&b
->bucket
);
1750 b
->size_rounded
= size_rounded
;
1751 b
->creation_time
= creation_time
;
1755 void encode(bufferlist
& bl
) const {
1756 ENCODE_START(7, 5, bl
);
1758 __u32 mt
= ceph::real_clock::to_time_t(creation_time
);
1759 std::string empty_str
; // originally had the bucket name here, but we encode bucket later
1760 encode(empty_str
, bl
);
1767 encode(creation_time
, bl
);
1768 encode(placement_rule
, bl
);
1771 void decode(bufferlist::const_iterator
& bl
) {
1772 DECODE_START_LEGACY_COMPAT_LEN(7, 5, 5, bl
);
1775 std::string empty_str
; // backward compatibility
1776 decode(empty_str
, bl
);
1781 creation_time
= ceph::real_clock::from_time_t(mt
);
1791 decode(creation_time
, bl
);
1793 decode(placement_rule
, bl
);
1796 void dump(Formatter
*f
) const;
1797 static void generate_test_instances(std::list
<RGWBucketEnt
*>& o
);
1799 WRITE_CLASS_ENCODER(RGWBucketEnt
)
1805 bool in_extra_data
{false}; /* in-memory only member, does not serialize */
1807 // Represents the hash index source for this object once it is set (non-empty)
1808 std::string index_hash_source
;
1811 rgw_obj(const rgw_bucket
& b
, const std::string
& name
) : bucket(b
), key(name
) {}
1812 rgw_obj(const rgw_bucket
& b
, const rgw_obj_key
& k
) : bucket(b
), key(k
) {}
1813 rgw_obj(const rgw_bucket
& b
, const rgw_obj_index_key
& k
) : bucket(b
), key(k
) {}
1815 void init(const rgw_bucket
& b
, const std::string
& name
) {
1819 void init(const rgw_bucket
& b
, const std::string
& name
, const std::string
& i
, const std::string
& n
) {
1821 key
.set(name
, i
, n
);
1823 void init_ns(const rgw_bucket
& b
, const std::string
& name
, const std::string
& n
) {
1826 key
.instance
.clear();
1830 bool empty() const {
1834 void set_key(const rgw_obj_key
& k
) {
1838 std::string
get_oid() const {
1839 return key
.get_oid();
1842 const std::string
& get_hash_object() const {
1843 return index_hash_source
.empty() ? key
.name
: index_hash_source
;
1846 void set_in_extra_data(bool val
) {
1847 in_extra_data
= val
;
1850 bool is_in_extra_data() const {
1851 return in_extra_data
;
1854 void encode(bufferlist
& bl
) const {
1855 ENCODE_START(6, 6, bl
);
1858 encode(key
.name
, bl
);
1859 encode(key
.instance
, bl
);
1860 // encode(placement_id, bl);
1863 void decode(bufferlist::const_iterator
& bl
) {
1864 DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl
);
1867 decode(bucket
.name
, bl
); /* bucket.name */
1868 decode(s
, bl
); /* loc */
1870 decode(key
.name
, bl
);
1874 decode(key
.instance
, bl
);
1875 if (key
.ns
.empty() && key
.instance
.empty()) {
1876 if (key
.name
[0] == '_') {
1877 key
.name
= key
.name
.substr(1);
1880 if (struct_v
>= 5) {
1881 decode(key
.name
, bl
);
1883 ssize_t pos
= key
.name
.find('_', 1);
1885 throw buffer::malformed_input();
1887 key
.name
= key
.name
.substr(pos
+ 1);
1893 decode(key
.name
, bl
);
1894 decode(key
.instance
, bl
);
1895 // decode(placement_id, bl);
1899 void dump(Formatter
*f
) const;
1900 static void generate_test_instances(std::list
<rgw_obj
*>& o
);
1902 bool operator==(const rgw_obj
& o
) const {
1903 return (key
== o
.key
) &&
1904 (bucket
== o
.bucket
);
1906 bool operator<(const rgw_obj
& o
) const {
1907 int r
= key
.name
.compare(o
.key
.name
);
1909 r
= bucket
.bucket_id
.compare(o
.bucket
.bucket_id
); /* not comparing bucket.name, if bucket_id is equal so will be bucket.name */
1911 r
= key
.ns
.compare(o
.key
.ns
);
1913 r
= key
.instance
.compare(o
.key
.instance
);
1921 const rgw_pool
& get_explicit_data_pool() {
1922 if (!in_extra_data
|| bucket
.explicit_placement
.data_extra_pool
.empty()) {
1923 return bucket
.explicit_placement
.data_pool
;
1925 return bucket
.explicit_placement
.data_extra_pool
;
1928 WRITE_CLASS_ENCODER(rgw_obj
)
1930 struct rgw_cache_entry_info
{
1931 std::string cache_locator
;
1934 rgw_cache_entry_info() : gen(0) {}
1937 inline std::ostream
& operator<<(std::ostream
& out
, const rgw_obj
&o
) {
1938 return out
<< o
.bucket
.name
<< ":" << o
.get_oid();
1941 struct multipart_upload_info
1943 rgw_placement_rule dest_placement
;
1945 void encode(bufferlist
& bl
) const {
1946 ENCODE_START(1, 1, bl
);
1947 encode(dest_placement
, bl
);
1951 void decode(bufferlist::const_iterator
& bl
) {
1952 DECODE_START(1, bl
);
1953 decode(dest_placement
, bl
);
1957 WRITE_CLASS_ENCODER(multipart_upload_info
)
1959 static inline void buf_to_hex(const unsigned char* const buf
,
1964 for (size_t i
= 0; i
< len
; i
++) {
1965 ::sprintf(&str
[i
*2], "%02x", static_cast<int>(buf
[i
]));
1969 template<size_t N
> static inline std::array
<char, N
* 2 + 1>
1970 buf_to_hex(const std::array
<unsigned char, N
>& buf
)
1972 static_assert(N
> 0, "The input array must be at least one element long");
1974 std::array
<char, N
* 2 + 1> hex_dest
;
1975 buf_to_hex(buf
.data(), N
, hex_dest
.data());
1979 static inline int hexdigit(char c
)
1981 if (c
>= '0' && c
<= '9')
1984 if (c
>= 'A' && c
<= 'F')
1985 return c
- 'A' + 0xa;
1989 static inline int hex_to_buf(const char *hex
, char *buf
, int len
)
1992 const char *p
= hex
;
1997 int d
= hexdigit(*p
);
2014 static inline int rgw_str_to_bool(const char *s
, int def_val
)
2019 return (strcasecmp(s
, "true") == 0 ||
2020 strcasecmp(s
, "on") == 0 ||
2021 strcasecmp(s
, "yes") == 0 ||
2022 strcasecmp(s
, "1") == 0);
2025 static inline void append_rand_alpha(CephContext
*cct
, const std::string
& src
, std::string
& dest
, int len
)
2029 gen_rand_alphanumeric(cct
, buf
, len
);
2034 static inline uint64_t rgw_rounded_kb(uint64_t bytes
)
2036 return (bytes
+ 1023) / 1024;
2039 static inline uint64_t rgw_rounded_objsize(uint64_t bytes
)
2041 return ((bytes
+ 4095) & ~4095);
2044 static inline uint64_t rgw_rounded_objsize_kb(uint64_t bytes
)
2046 return ((bytes
+ 4095) & ~4095) / 1024;
2049 /* implement combining step, S3 header canonicalization; k is a
2050 * valid header and in lc form */
2051 void rgw_add_amz_meta_header(
2052 meta_map_t
& x_meta_map
,
2053 const std::string
& k
,
2054 const std::string
& v
);
2056 enum rgw_set_action_if_set
{
2057 DISCARD
=0, OVERWRITE
, APPEND
2060 bool rgw_set_amz_meta_header(
2061 meta_map_t
& x_meta_map
,
2062 const std::string
& k
,
2063 const std::string
& v
, rgw_set_action_if_set f
);
2065 extern std::string
rgw_string_unquote(const std::string
& s
);
2066 extern void parse_csv_string(const std::string
& ival
, std::vector
<std::string
>& ovals
);
2067 extern int parse_key_value(std::string
& in_str
, std::string
& key
, std::string
& val
);
2068 extern int parse_key_value(std::string
& in_str
, const char *delim
, std::string
& key
, std::string
& val
);
2070 extern boost::optional
<std::pair
<std::string_view
,std::string_view
>>
2071 parse_key_value(const std::string_view
& in_str
,
2072 const std::string_view
& delim
);
2073 extern boost::optional
<std::pair
<std::string_view
,std::string_view
>>
2074 parse_key_value(const std::string_view
& in_str
);
2078 extern int parse_time(const char *time_str
, real_time
*time
);
2079 extern bool parse_rfc2616(const char *s
, struct tm
*t
);
2080 extern bool parse_iso8601(const char *s
, struct tm
*t
, uint32_t *pns
= NULL
, bool extended_format
= true);
2081 extern std::string
rgw_trim_whitespace(const std::string
& src
);
2082 extern std::string_view
rgw_trim_whitespace(const std::string_view
& src
);
2083 extern std::string
rgw_trim_quotes(const std::string
& val
);
2085 extern void rgw_to_iso8601(const real_time
& t
, char *dest
, int buf_size
);
2086 extern void rgw_to_iso8601(const real_time
& t
, std::string
*dest
);
2087 extern std::string
rgw_to_asctime(const utime_t
& t
);
2089 struct perm_state_base
{
2091 const rgw::IAM::Environment
& env
;
2092 rgw::auth::Identity
*identity
;
2093 const RGWBucketInfo bucket_info
;
2095 bool defer_to_bucket_acls
;
2096 boost::optional
<PublicAccessBlockConfiguration
> bucket_access_conf
;
2098 perm_state_base(CephContext
*_cct
,
2099 const rgw::IAM::Environment
& _env
,
2100 rgw::auth::Identity
*_identity
,
2101 const RGWBucketInfo
& _bucket_info
,
2103 bool _defer_to_bucket_acls
,
2104 boost::optional
<PublicAccessBlockConfiguration
> _bucket_acess_conf
= boost::none
) :
2107 identity(_identity
),
2108 bucket_info(_bucket_info
),
2109 perm_mask(_perm_mask
),
2110 defer_to_bucket_acls(_defer_to_bucket_acls
),
2111 bucket_access_conf(_bucket_acess_conf
)
2114 virtual ~perm_state_base() {}
2116 virtual const char *get_referer() const = 0;
2117 virtual std::optional
<bool> get_request_payer() const = 0; /*
2118 * empty state means that request_payer param was not passed in
2123 struct perm_state
: public perm_state_base
{
2124 const char *referer
;
2127 perm_state(CephContext
*_cct
,
2128 const rgw::IAM::Environment
& _env
,
2129 rgw::auth::Identity
*_identity
,
2130 const RGWBucketInfo
& _bucket_info
,
2132 bool _defer_to_bucket_acls
,
2133 const char *_referer
,
2134 bool _request_payer
) : perm_state_base(_cct
,
2139 _defer_to_bucket_acls
),
2141 request_payer(_request_payer
) {}
2143 const char *get_referer() const override
{
2147 std::optional
<bool> get_request_payer() const override
{
2148 return request_payer
;
2152 /** Check if the req_state's user has the necessary permissions
2153 * to do the requested action */
2154 bool verify_bucket_permission_no_policy(
2155 const DoutPrefixProvider
* dpp
,
2156 struct perm_state_base
* const s
,
2157 RGWAccessControlPolicy
* const user_acl
,
2158 RGWAccessControlPolicy
* const bucket_acl
,
2161 bool verify_user_permission_no_policy(const DoutPrefixProvider
* dpp
,
2162 struct perm_state_base
* const s
,
2163 RGWAccessControlPolicy
* const user_acl
,
2166 bool verify_object_permission_no_policy(const DoutPrefixProvider
* dpp
,
2167 struct perm_state_base
* const s
,
2168 RGWAccessControlPolicy
* const user_acl
,
2169 RGWAccessControlPolicy
* const bucket_acl
,
2170 RGWAccessControlPolicy
* const object_acl
,
2173 /** Check if the req_state's user has the necessary permissions
2174 * to do the requested action */
2175 rgw::IAM::Effect
eval_identity_or_session_policies(const std::vector
<rgw::IAM::Policy
>& user_policies
,
2176 const rgw::IAM::Environment
& env
,
2178 const rgw::ARN
& arn
);
2179 bool verify_user_permission(const DoutPrefixProvider
* dpp
,
2180 struct req_state
* const s
,
2181 RGWAccessControlPolicy
* const user_acl
,
2182 const std::vector
<rgw::IAM::Policy
>& user_policies
,
2183 const std::vector
<rgw::IAM::Policy
>& session_policies
,
2184 const rgw::ARN
& res
,
2186 bool verify_user_permission_no_policy(const DoutPrefixProvider
* dpp
,
2187 struct req_state
* const s
,
2188 RGWAccessControlPolicy
* const user_acl
,
2190 bool verify_user_permission(const DoutPrefixProvider
* dpp
,
2191 struct req_state
* const s
,
2192 const rgw::ARN
& res
,
2194 bool verify_user_permission_no_policy(const DoutPrefixProvider
* dpp
,
2195 struct req_state
* const s
,
2197 bool verify_bucket_permission(
2198 const DoutPrefixProvider
* dpp
,
2199 struct req_state
* const s
,
2200 const rgw_bucket
& bucket
,
2201 RGWAccessControlPolicy
* const user_acl
,
2202 RGWAccessControlPolicy
* const bucket_acl
,
2203 const boost::optional
<rgw::IAM::Policy
>& bucket_policy
,
2204 const std::vector
<rgw::IAM::Policy
>& identity_policies
,
2205 const std::vector
<rgw::IAM::Policy
>& session_policies
,
2207 bool verify_bucket_permission(const DoutPrefixProvider
* dpp
, struct req_state
* const s
, const uint64_t op
);
2208 bool verify_bucket_permission_no_policy(
2209 const DoutPrefixProvider
* dpp
,
2210 struct req_state
* const s
,
2211 RGWAccessControlPolicy
* const user_acl
,
2212 RGWAccessControlPolicy
* const bucket_acl
,
2214 bool verify_bucket_permission_no_policy(const DoutPrefixProvider
* dpp
,
2215 struct req_state
* const s
,
2217 int verify_bucket_owner_or_policy(struct req_state
* const s
,
2219 extern bool verify_object_permission(
2220 const DoutPrefixProvider
* dpp
,
2221 struct req_state
* const s
,
2223 RGWAccessControlPolicy
* const user_acl
,
2224 RGWAccessControlPolicy
* const bucket_acl
,
2225 RGWAccessControlPolicy
* const object_acl
,
2226 const boost::optional
<rgw::IAM::Policy
>& bucket_policy
,
2227 const std::vector
<rgw::IAM::Policy
>& identity_policies
,
2228 const std::vector
<rgw::IAM::Policy
>& session_policies
,
2230 extern bool verify_object_permission(const DoutPrefixProvider
* dpp
, struct req_state
*s
, uint64_t op
);
2231 extern bool verify_object_permission_no_policy(
2232 const DoutPrefixProvider
* dpp
,
2233 struct req_state
* const s
,
2234 RGWAccessControlPolicy
* const user_acl
,
2235 RGWAccessControlPolicy
* const bucket_acl
,
2236 RGWAccessControlPolicy
* const object_acl
,
2238 extern bool verify_object_permission_no_policy(const DoutPrefixProvider
* dpp
, struct req_state
*s
,
2240 extern int verify_object_lock(
2241 const DoutPrefixProvider
* dpp
,
2242 const rgw::sal::Attrs
& attrs
,
2243 const bool bypass_perm
,
2244 const bool bypass_governance_mode
);
2246 /** Convert an input URL into a sane object name
2247 * by converting %-escaped std::strings into characters, etc*/
2248 extern void rgw_uri_escape_char(char c
, std::string
& dst
);
2249 extern std::string
url_decode(const std::string_view
& src_str
,
2250 bool in_query
= false);
2251 extern void url_encode(const std::string
& src
, std::string
& dst
,
2252 bool encode_slash
= true);
2253 extern std::string
url_encode(const std::string
& src
, bool encode_slash
= true);
2254 extern std::string
url_remove_prefix(const std::string
& url
); // Removes hhtp, https and www from url
2255 /* destination should be CEPH_CRYPTO_HMACSHA1_DIGESTSIZE bytes long */
2256 extern void calc_hmac_sha1(const char *key
, int key_len
,
2257 const char *msg
, int msg_len
, char *dest
);
2259 static inline sha1_digest_t
2260 calc_hmac_sha1(const std::string_view
& key
, const std::string_view
& msg
) {
2262 calc_hmac_sha1(key
.data(), key
.size(), msg
.data(), msg
.size(),
2263 reinterpret_cast<char*>(dest
.v
));
2267 /* destination should be CEPH_CRYPTO_HMACSHA256_DIGESTSIZE bytes long */
2268 extern void calc_hmac_sha256(const char *key
, int key_len
,
2269 const char *msg
, int msg_len
,
2272 static inline sha256_digest_t
2273 calc_hmac_sha256(const char *key
, const int key_len
,
2274 const char *msg
, const int msg_len
) {
2275 sha256_digest_t dest
;
2276 calc_hmac_sha256(key
, key_len
, msg
, msg_len
,
2277 reinterpret_cast<char*>(dest
.v
));
2281 static inline sha256_digest_t
2282 calc_hmac_sha256(const std::string_view
& key
, const std::string_view
& msg
) {
2283 sha256_digest_t dest
;
2284 calc_hmac_sha256(key
.data(), key
.size(),
2285 msg
.data(), msg
.size(),
2286 reinterpret_cast<char*>(dest
.v
));
2290 static inline sha256_digest_t
2291 calc_hmac_sha256(const sha256_digest_t
&key
,
2292 const std::string_view
& msg
) {
2293 sha256_digest_t dest
;
2294 calc_hmac_sha256(reinterpret_cast<const char*>(key
.v
), sha256_digest_t::SIZE
,
2295 msg
.data(), msg
.size(),
2296 reinterpret_cast<char*>(dest
.v
));
2300 static inline sha256_digest_t
2301 calc_hmac_sha256(const std::vector
<unsigned char>& key
,
2302 const std::string_view
& msg
) {
2303 sha256_digest_t dest
;
2304 calc_hmac_sha256(reinterpret_cast<const char*>(key
.data()), key
.size(),
2305 msg
.data(), msg
.size(),
2306 reinterpret_cast<char*>(dest
.v
));
2310 template<size_t KeyLenN
>
2311 static inline sha256_digest_t
2312 calc_hmac_sha256(const std::array
<unsigned char, KeyLenN
>& key
,
2313 const std::string_view
& msg
) {
2314 sha256_digest_t dest
;
2315 calc_hmac_sha256(reinterpret_cast<const char*>(key
.data()), key
.size(),
2316 msg
.data(), msg
.size(),
2317 reinterpret_cast<char*>(dest
.v
));
2321 extern sha256_digest_t
calc_hash_sha256(const std::string_view
& msg
);
2323 extern ceph::crypto::SHA256
* calc_hash_sha256_open_stream();
2324 extern void calc_hash_sha256_update_stream(ceph::crypto::SHA256
* hash
,
2327 extern std::string
calc_hash_sha256_close_stream(ceph::crypto::SHA256
** phash
);
2328 extern std::string
calc_hash_sha256_restart_stream(ceph::crypto::SHA256
** phash
);
2330 extern int rgw_parse_op_type_list(const std::string
& str
, uint32_t *perm
);
2332 static constexpr uint32_t MATCH_POLICY_ACTION
= 0x01;
2333 static constexpr uint32_t MATCH_POLICY_RESOURCE
= 0x02;
2334 static constexpr uint32_t MATCH_POLICY_ARN
= 0x04;
2335 static constexpr uint32_t MATCH_POLICY_STRING
= 0x08;
2337 extern bool match_policy(std::string_view pattern
, std::string_view input
,
2340 extern std::string
camelcase_dash_http_attr(const std::string
& orig
);
2341 extern std::string
lowercase_dash_http_attr(const std::string
& orig
);
2343 void rgw_setup_saved_curl_handles();
2344 void rgw_release_all_curl_handles();
2346 static inline void rgw_escape_str(const std::string
& s
, char esc_char
,
2347 char special_char
, std::string
*dest
)
2349 const char *src
= s
.c_str();
2350 char dest_buf
[s
.size() * 2 + 1];
2351 char *destp
= dest_buf
;
2353 for (size_t i
= 0; i
< s
.size(); i
++) {
2355 if (c
== esc_char
|| c
== special_char
) {
2356 *destp
++ = esc_char
;
2364 static inline ssize_t
rgw_unescape_str(const std::string
& s
, ssize_t ofs
,
2365 char esc_char
, char special_char
,
2368 const char *src
= s
.c_str();
2369 char dest_buf
[s
.size() + 1];
2370 char *destp
= dest_buf
;
2375 for (size_t i
= ofs
; i
< s
.size(); i
++) {
2377 if (!esc
&& c
== esc_char
) {
2381 if (!esc
&& c
== special_char
) {
2384 return (ssize_t
)i
+ 1;
2391 return std::string::npos
;
2394 static inline std::string
rgw_bl_str(ceph::buffer::list
& raw
)
2396 size_t len
= raw
.length();
2397 std::string
s(raw
.c_str(), len
);
2398 while (len
&& !s
[len
- 1]) {
2405 template <typename T
>
2406 int decode_bl(bufferlist
& bl
, T
& t
)
2408 auto iter
= bl
.cbegin();
2411 } catch (buffer::error
& err
) {