X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Frgw%2Frgw_common.h;h=25e5b24ad8170dde5731188b187993f92a26c72b;hb=39ae355f72b1d71f2212a99f2bd9f6c1e0d35528;hp=48115804fc9a3d0e5f8793b8dda14647734317f6;hpb=adb31ebba1b9f736f0a7e05b9be808af79cfce80;p=ceph.git diff --git a/ceph/src/rgw/rgw_common.h b/ceph/src/rgw/rgw_common.h index 48115804f..25e5b24ad 100644 --- a/ceph/src/rgw/rgw_common.h +++ b/ceph/src/rgw/rgw_common.h @@ -14,16 +14,17 @@ * */ -#ifndef CEPH_RGW_COMMON_H -#define CEPH_RGW_COMMON_H +#pragma once #include - -#include +#include +#include +#include #include "common/ceph_crypto.h" #include "common/random_string.h" #include "rgw_acl.h" +#include "rgw_bucket_layout.h" #include "rgw_cors.h" #include "rgw_iam_policy.h" #include "rgw_quota.h" @@ -32,19 +33,24 @@ #include "rgw_website.h" #include "rgw_object_lock.h" #include "rgw_tag.h" +#include "rgw_op_type.h" #include "rgw_sync_policy.h" #include "cls/version/cls_version_types.h" #include "cls/user/cls_user_types.h" #include "cls/rgw/cls_rgw_types.h" #include "include/rados/librados.hpp" #include "rgw_public_access.h" +#include "common/tracer.h" namespace ceph { class Formatter; } namespace rgw::sal { - class RGWUser; + class User; + class Bucket; + class Object; + using Attrs = std::map; } using ceph::crypto::MD5; @@ -62,6 +68,7 @@ using ceph::crypto::MD5; #define RGW_SYS_PARAM_PREFIX "rgwx-" #define RGW_ATTR_ACL RGW_ATTR_PREFIX "acl" +#define RGW_ATTR_RATELIMIT RGW_ATTR_PREFIX "ratelimit" #define RGW_ATTR_LC RGW_ATTR_PREFIX "lc" #define RGW_ATTR_CORS RGW_ATTR_PREFIX "cors" #define RGW_ATTR_ETAG RGW_ATTR_PREFIX "etag" @@ -136,7 +143,15 @@ using ceph::crypto::MD5; #define RGW_ATTR_CRYPT_KEYMD5 RGW_ATTR_CRYPT_PREFIX "keymd5" #define RGW_ATTR_CRYPT_KEYID RGW_ATTR_CRYPT_PREFIX "keyid" #define RGW_ATTR_CRYPT_KEYSEL RGW_ATTR_CRYPT_PREFIX "keysel" +#define RGW_ATTR_CRYPT_CONTEXT RGW_ATTR_CRYPT_PREFIX "context" +#define RGW_ATTR_CRYPT_DATAKEY RGW_ATTR_CRYPT_PREFIX "datakey" + +/* SSE-S3 Encryption Attributes */ +#define RGW_ATTR_BUCKET_ENCRYPTION_PREFIX RGW_ATTR_PREFIX "sse-s3." +#define RGW_ATTR_BUCKET_ENCRYPTION_POLICY RGW_ATTR_BUCKET_ENCRYPTION_PREFIX "policy" +#define RGW_ATTR_BUCKET_ENCRYPTION_KEY_ID RGW_ATTR_BUCKET_ENCRYPTION_PREFIX "key-id" +#define RGW_ATTR_TRACE RGW_ATTR_PREFIX "trace" #define RGW_FORMAT_PLAIN 0 #define RGW_FORMAT_XML 1 @@ -224,6 +239,7 @@ using ceph::crypto::MD5; #define ERR_NO_SUCH_CORS_CONFIGURATION 2045 #define ERR_NO_SUCH_OBJECT_LOCK_CONFIGURATION 2046 #define ERR_INVALID_RETENTION_PERIOD 2047 +#define ERR_NO_SUCH_BUCKET_ENCRYPTION_CONFIGURATION 2048 #define ERR_USER_SUSPENDED 2100 #define ERR_INTERNAL_ERROR 2200 #define ERR_NOT_IMPLEMENTED 2201 @@ -247,6 +263,7 @@ using ceph::crypto::MD5; #define ERR_POSITION_NOT_EQUAL_TO_LENGTH 2219 #define ERR_OBJECT_NOT_APPENDABLE 2220 #define ERR_INVALID_BUCKET_STATE 2221 +#define ERR_INVALID_OBJECT_STATE 2222 #define ERR_BUSY_RESHARDING 2300 #define ERR_NO_SUCH_ENTITY 2301 @@ -290,6 +307,7 @@ struct rgw_err { std::string message; }; + /* Helper class used for RGWHTTPArgs parsing */ class NameVal { @@ -315,9 +333,9 @@ class RGWHTTPArgs { bool admin_subresource_added = false; public: RGWHTTPArgs() = default; - explicit RGWHTTPArgs(const std::string& s) { + explicit RGWHTTPArgs(const std::string& s, const DoutPrefixProvider *dpp) { set(s); - parse(); + parse(dpp); } /** Set the arguments; as received */ @@ -328,16 +346,17 @@ class RGWHTTPArgs { str = s; } /** parse the received arguments */ - int parse(); - void append(const std::string& name, const string& val); + int parse(const DoutPrefixProvider *dpp); + void append(const std::string& name, const std::string& val); + void remove(const std::string& name); /** Get the value for a specific argument parameter */ - const string& get(const std::string& name, bool *exists = NULL) const; + const std::string& get(const std::string& name, bool *exists = NULL) const; boost::optional get_optional(const std::string& name) const; - int get_bool(const std::string& name, bool *val, bool *exists); - int get_bool(const char *name, bool *val, bool *exists); - void get_bool(const char *name, bool *val, bool def_val); - int get_int(const char *name, int *val, int def_val); + int get_bool(const std::string& name, bool *val, bool *exists) const; + int get_bool(const char *name, bool *val, bool *exists) const; + void get_bool(const char *name, bool *val, bool def_val) const; + int get_int(const char *name, int *val, int def_val) const; /** Get the value for specific system argument parameter */ std::string sys_get(const std::string& name, bool *exists = nullptr) const; @@ -349,9 +368,27 @@ class RGWHTTPArgs { bool sub_resource_exists(const char *name) const { return (sub_resources.find(name) != std::end(sub_resources)); } + bool exist_obj_excl_sub_resource() const { + const char* const obj_sub_resource[] = {"append", "torrent", "uploadId", + "partNumber", "versionId"}; + for (unsigned i = 0; i != std::size(obj_sub_resource); i++) { + if (sub_resource_exists(obj_sub_resource[i])) return true; + } + return false; + } + std::map& get_params() { return val_map; } + const std::map& get_params() const { + return val_map; + } + std::map& get_sys_params() { + return sys_val_map; + } + const std::map& get_sys_params() const { + return sys_val_map; + } const std::map& get_sub_resources() const { return sub_resources; } @@ -372,9 +409,9 @@ class RGWHTTPArgs { } }; // RGWHTTPArgs -const char *rgw_conf_get(const map& conf_map, const char *name, const char *def_val); -int rgw_conf_get_int(const map& conf_map, const char *name, int def_val); -bool rgw_conf_get_bool(const map& conf_map, const char *name, bool def_val); +const char *rgw_conf_get(const std::map& conf_map, const char *name, const char *def_val); +int rgw_conf_get_int(const std::map& conf_map, const char *name, int def_val); +bool rgw_conf_get_bool(const std::map& conf_map, const char *name, bool def_val); class RGWEnv; @@ -393,7 +430,7 @@ public: }; class RGWEnv { - std::map env_map; + std::map env_map; RGWConf conf; public: void init(CephContext *cct); @@ -406,7 +443,7 @@ public: bool exists(const char *name) const; bool exists_prefix(const char *prefix) const; void remove(const char *name); - const std::map& get_map() const { return env_map; } + const std::map& get_map() const { return env_map; } int get_enable_ops_log() const { return conf.enable_ops_log; } @@ -435,129 +472,13 @@ enum http_op { OP_UNKNOWN, }; -enum RGWOpType { - RGW_OP_UNKNOWN = 0, - RGW_OP_GET_OBJ, - RGW_OP_LIST_BUCKETS, - RGW_OP_STAT_ACCOUNT, - RGW_OP_LIST_BUCKET, - RGW_OP_GET_BUCKET_LOGGING, - RGW_OP_GET_BUCKET_LOCATION, - RGW_OP_GET_BUCKET_VERSIONING, - RGW_OP_SET_BUCKET_VERSIONING, - RGW_OP_GET_BUCKET_WEBSITE, - RGW_OP_SET_BUCKET_WEBSITE, - RGW_OP_STAT_BUCKET, - RGW_OP_CREATE_BUCKET, - RGW_OP_DELETE_BUCKET, - RGW_OP_PUT_OBJ, - RGW_OP_STAT_OBJ, - RGW_OP_POST_OBJ, - RGW_OP_PUT_METADATA_ACCOUNT, - RGW_OP_PUT_METADATA_BUCKET, - RGW_OP_PUT_METADATA_OBJECT, - RGW_OP_SET_TEMPURL, - RGW_OP_DELETE_OBJ, - RGW_OP_COPY_OBJ, - RGW_OP_GET_ACLS, - RGW_OP_PUT_ACLS, - RGW_OP_GET_CORS, - RGW_OP_PUT_CORS, - RGW_OP_DELETE_CORS, - RGW_OP_OPTIONS_CORS, - RGW_OP_GET_REQUEST_PAYMENT, - RGW_OP_SET_REQUEST_PAYMENT, - RGW_OP_INIT_MULTIPART, - RGW_OP_COMPLETE_MULTIPART, - RGW_OP_ABORT_MULTIPART, - RGW_OP_LIST_MULTIPART, - RGW_OP_LIST_BUCKET_MULTIPARTS, - RGW_OP_DELETE_MULTI_OBJ, - RGW_OP_BULK_DELETE, - RGW_OP_SET_ATTRS, - RGW_OP_GET_CROSS_DOMAIN_POLICY, - RGW_OP_GET_HEALTH_CHECK, - RGW_OP_GET_INFO, - RGW_OP_CREATE_ROLE, - RGW_OP_DELETE_ROLE, - RGW_OP_GET_ROLE, - RGW_OP_MODIFY_ROLE, - RGW_OP_LIST_ROLES, - RGW_OP_PUT_ROLE_POLICY, - RGW_OP_GET_ROLE_POLICY, - RGW_OP_LIST_ROLE_POLICIES, - RGW_OP_DELETE_ROLE_POLICY, - RGW_OP_PUT_BUCKET_POLICY, - RGW_OP_GET_BUCKET_POLICY, - RGW_OP_DELETE_BUCKET_POLICY, - RGW_OP_PUT_OBJ_TAGGING, - RGW_OP_GET_OBJ_TAGGING, - RGW_OP_DELETE_OBJ_TAGGING, - RGW_OP_PUT_LC, - RGW_OP_GET_LC, - RGW_OP_DELETE_LC, - RGW_OP_PUT_USER_POLICY, - RGW_OP_GET_USER_POLICY, - RGW_OP_LIST_USER_POLICIES, - RGW_OP_DELETE_USER_POLICY, - RGW_OP_PUT_BUCKET_OBJ_LOCK, - RGW_OP_GET_BUCKET_OBJ_LOCK, - RGW_OP_PUT_OBJ_RETENTION, - RGW_OP_GET_OBJ_RETENTION, - RGW_OP_PUT_OBJ_LEGAL_HOLD, - RGW_OP_GET_OBJ_LEGAL_HOLD, - /* rgw specific */ - RGW_OP_ADMIN_SET_METADATA, - RGW_OP_GET_OBJ_LAYOUT, - RGW_OP_BULK_UPLOAD, - RGW_OP_METADATA_SEARCH, - RGW_OP_CONFIG_BUCKET_META_SEARCH, - RGW_OP_GET_BUCKET_META_SEARCH, - RGW_OP_DEL_BUCKET_META_SEARCH, - /* sts specific*/ - RGW_STS_ASSUME_ROLE, - RGW_STS_GET_SESSION_TOKEN, - RGW_STS_ASSUME_ROLE_WEB_IDENTITY, - /* pubsub */ - RGW_OP_PUBSUB_TOPIC_CREATE, - RGW_OP_PUBSUB_TOPICS_LIST, - RGW_OP_PUBSUB_TOPIC_GET, - RGW_OP_PUBSUB_TOPIC_DELETE, - RGW_OP_PUBSUB_SUB_CREATE, - RGW_OP_PUBSUB_SUB_GET, - RGW_OP_PUBSUB_SUB_DELETE, - RGW_OP_PUBSUB_SUB_PULL, - RGW_OP_PUBSUB_SUB_ACK, - RGW_OP_PUBSUB_NOTIF_CREATE, - RGW_OP_PUBSUB_NOTIF_DELETE, - RGW_OP_PUBSUB_NOTIF_LIST, - RGW_OP_GET_BUCKET_TAGGING, - RGW_OP_PUT_BUCKET_TAGGING, - RGW_OP_DELETE_BUCKET_TAGGING, - RGW_OP_GET_BUCKET_REPLICATION, - RGW_OP_PUT_BUCKET_REPLICATION, - RGW_OP_DELETE_BUCKET_REPLICATION, - - /* public access */ - RGW_OP_GET_BUCKET_POLICY_STATUS, - RGW_OP_PUT_BUCKET_PUBLIC_ACCESS_BLOCK, - RGW_OP_GET_BUCKET_PUBLIC_ACCESS_BLOCK, - RGW_OP_DELETE_BUCKET_PUBLIC_ACCESS_BLOCK, - - /*OIDC provider specific*/ - RGW_OP_CREATE_OIDC_PROVIDER, - RGW_OP_DELETE_OIDC_PROVIDER, - RGW_OP_GET_OIDC_PROVIDER, - RGW_OP_LIST_OIDC_PROVIDERS, -}; - class RGWAccessControlPolicy; class JSONObj; struct RGWAccessKey { - string id; // AccessKey - string key; // SecretKey - string subuser; + std::string id; // AccessKey + std::string key; // SecretKey + std::string subuser; RGWAccessKey() {} RGWAccessKey(std::string _id, std::string _key) @@ -580,8 +501,8 @@ struct RGWAccessKey { } void dump(Formatter *f) const; void dump_plain(Formatter *f) const; - void dump(Formatter *f, const string& user, bool swift) const; - static void generate_test_instances(list& o); + void dump(Formatter *f, const std::string& user, bool swift) const; + static void generate_test_instances(std::list& o); void decode_json(JSONObj *obj); void decode_json(JSONObj *obj, bool swift); @@ -589,7 +510,7 @@ struct RGWAccessKey { WRITE_CLASS_ENCODER(RGWAccessKey) struct RGWSubUser { - string name; + std::string name; uint32_t perm_mask; RGWSubUser() : perm_mask(0) {} @@ -607,8 +528,8 @@ struct RGWSubUser { DECODE_FINISH(bl); } void dump(Formatter *f) const; - void dump(Formatter *f, const string& user) const; - static void generate_test_instances(list& o); + void dump(Formatter *f, const std::string& user) const; + static void generate_test_instances(std::list& o); void decode_json(JSONObj *obj); }; @@ -616,15 +537,15 @@ WRITE_CLASS_ENCODER(RGWSubUser) class RGWUserCaps { - map caps; + std::map caps; - int get_cap(const string& cap, string& type, uint32_t *perm); - int add_cap(const string& cap); - int remove_cap(const string& cap); + int get_cap(const std::string& cap, std::string& type, uint32_t *perm); + int add_cap(const std::string& cap); + int remove_cap(const std::string& cap); public: - static int parse_cap_perm(const string& str, uint32_t *perm); - int add_from_string(const string& str); - int remove_from_string(const string& str); + static int parse_cap_perm(const std::string& str, uint32_t *perm); + int add_from_string(const std::string& str); + int remove_from_string(const std::string& str); void encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); @@ -636,8 +557,8 @@ public: decode(caps, bl); DECODE_FINISH(bl); } - int check_cap(const string& cap, uint32_t perm) const; - bool is_valid_cap_type(const string& tp); + int check_cap(const std::string& cap, uint32_t perm) const; + bool is_valid_cap_type(const std::string& tp); void dump(Formatter *f) const; void dump(Formatter *f, const char *name) const; @@ -662,15 +583,15 @@ enum RGWIdentityType TYPE_WEB=5, }; -static string RGW_STORAGE_CLASS_STANDARD = "STANDARD"; +static std::string RGW_STORAGE_CLASS_STANDARD = "STANDARD"; struct rgw_placement_rule { std::string name; std::string storage_class; rgw_placement_rule() {} - rgw_placement_rule(const string& _n, const string& _sc) : name(_n), storage_class(_sc) {} - rgw_placement_rule(const rgw_placement_rule& _r, const string& _sc) : name(_r.name) { + rgw_placement_rule(const std::string& _n, const std::string& _sc) : name(_n), storage_class(_sc) {} + rgw_placement_rule(const rgw_placement_rule& _r, const std::string& _sc) : name(_r.name) { if (!_sc.empty()) { storage_class = _sc; } else { @@ -696,19 +617,19 @@ struct rgw_placement_rule { storage_class.clear(); } - void init(const string& n, const string& c) { + void init(const std::string& n, const std::string& c) { name = n; storage_class = c; } - static const string& get_canonical_storage_class(const string& storage_class) { + static const std::string& get_canonical_storage_class(const std::string& storage_class) { if (storage_class.empty()) { return RGW_STORAGE_CLASS_STANDARD; } return storage_class; } - const string& get_storage_class() const { + const std::string& get_storage_class() const { return get_canonical_storage_class(storage_class); } @@ -772,17 +693,54 @@ WRITE_CLASS_ENCODER(rgw_placement_rule) void encode_json(const char *name, const rgw_placement_rule& val, ceph::Formatter *f); void decode_json_obj(rgw_placement_rule& v, JSONObj *obj); -inline ostream& operator<<(ostream& out, const rgw_placement_rule& rule) { +inline std::ostream& operator<<(std::ostream& out, const rgw_placement_rule& rule) { return out << rule.to_str(); } + +class RateLimiter; +struct RGWRateLimitInfo { + int64_t max_write_ops; + int64_t max_read_ops; + int64_t max_write_bytes; + int64_t max_read_bytes; + bool enabled = false; + RGWRateLimitInfo() + : max_write_ops(0), max_read_ops(0), max_write_bytes(0), max_read_bytes(0) {} + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + encode(max_write_ops, bl); + encode(max_read_ops, bl); + encode(max_write_bytes, bl); + encode(max_read_bytes, bl); + encode(enabled, bl); + ENCODE_FINISH(bl); + } + void decode(bufferlist::const_iterator& bl) { + DECODE_START(1, bl); + decode(max_write_ops,bl); + decode(max_read_ops, bl); + decode(max_write_bytes,bl); + decode(max_read_bytes, bl); + decode(enabled, bl); + DECODE_FINISH(bl); + } + + void dump(Formatter *f) const; + + void decode_json(JSONObj *obj); + +}; +WRITE_CLASS_ENCODER(RGWRateLimitInfo) + struct RGWUserInfo { rgw_user user_id; - string display_name; - string user_email; - map access_keys; - map swift_keys; - map subusers; + std::string display_name; + std::string user_email; + std::map access_keys; + std::map swift_keys; + std::map subusers; __u8 suspended; int32_t max_buckets; uint32_t op_mask; @@ -790,13 +748,13 @@ struct RGWUserInfo __u8 admin; __u8 system; rgw_placement_rule default_placement; - list placement_tags; + std::list placement_tags; RGWQuotaInfo bucket_quota; - map temp_url_keys; + std::map temp_url_keys; RGWQuotaInfo user_quota; uint32_t type; - set mfa_ids; - string assumed_role_arn; + std::set mfa_ids; + std::string assumed_role_arn; RGWUserInfo() : suspended(0), @@ -807,7 +765,7 @@ struct RGWUserInfo type(TYPE_NONE) { } - RGWAccessKey* get_key(const string& access_key) { + RGWAccessKey* get_key(const std::string& access_key) { if (access_keys.empty()) return nullptr; @@ -819,12 +777,12 @@ struct RGWUserInfo } void encode(bufferlist& bl) const { - ENCODE_START(21, 9, bl); + ENCODE_START(22, 9, bl); encode((uint64_t)0, bl); // old auid - string access_key; - string secret_key; + std::string access_key; + std::string secret_key; if (!access_keys.empty()) { - map::const_iterator iter = access_keys.begin(); + std::map::const_iterator iter = access_keys.begin(); const RGWAccessKey& k = iter->second; access_key = k.id; secret_key = k.key; @@ -833,10 +791,10 @@ struct RGWUserInfo encode(secret_key, bl); encode(display_name, bl); encode(user_email, bl); - string swift_name; - string swift_key; + std::string swift_name; + std::string swift_key; if (!swift_keys.empty()) { - map::const_iterator iter = swift_keys.begin(); + std::map::const_iterator iter = swift_keys.begin(); const RGWAccessKey& k = iter->second; swift_name = k.id; swift_key = k.key; @@ -862,16 +820,17 @@ struct RGWUserInfo encode(type, bl); encode(mfa_ids, bl); encode(assumed_role_arn, bl); + encode(user_id.ns, bl); ENCODE_FINISH(bl); } void decode(bufferlist::const_iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN_32(21, 9, 9, bl); + DECODE_START_LEGACY_COMPAT_LEN_32(22, 9, 9, bl); if (struct_v >= 2) { uint64_t old_auid; decode(old_auid, bl); } - string access_key; - string secret_key; + std::string access_key; + std::string secret_key; decode(access_key, bl); decode(secret_key, bl); if (struct_v < 6) { @@ -883,8 +842,8 @@ struct RGWUserInfo decode(display_name, bl); decode(user_email, bl); /* We populate swift_keys map later nowadays, but we have to decode. */ - string swift_name; - string swift_key; + std::string swift_name; + std::string swift_key; if (struct_v >= 3) decode(swift_name, bl); if (struct_v >= 4) decode(swift_key, bl); if (struct_v >= 5) @@ -946,10 +905,15 @@ struct RGWUserInfo if (struct_v >= 21) { decode(assumed_role_arn, bl); } + if (struct_v >= 22) { + decode(user_id.ns, bl); + } else { + user_id.ns.clear(); + } DECODE_FINISH(bl); } void dump(Formatter *f) const; - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); void decode_json(JSONObj *obj); }; @@ -964,7 +928,7 @@ struct rgw_raw_obj { rgw_raw_obj(const rgw_pool& _pool, const std::string& _oid) { init(_pool, _oid); } - rgw_raw_obj(const rgw_pool& _pool, const std::string& _oid, const string& _loc) : loc(_loc) { + rgw_raw_obj(const rgw_pool& _pool, const std::string& _oid, const std::string& _loc) : loc(_loc) { init(_pool, _oid); } @@ -1025,7 +989,7 @@ struct rgw_raw_obj { }; WRITE_CLASS_ENCODER(rgw_raw_obj) -inline ostream& operator<<(ostream& out, const rgw_raw_obj& o) { +inline std::ostream& operator<<(std::ostream& out, const rgw_raw_obj& o) { out << o.pool << ":" << o.oid; return out; } @@ -1072,13 +1036,13 @@ struct RGWObjVersionTracker { void generate_new_write_ver(CephContext *cct); }; -inline ostream& operator<<(ostream& out, const obj_version &v) +inline std::ostream& operator<<(std::ostream& out, const obj_version &v) { out << v.tag << ":" << v.ver; return out; } -inline ostream& operator<<(ostream& out, const RGWObjVersionTracker &ot) +inline std::ostream& operator<<(std::ostream& out, const RGWObjVersionTracker &ot) { out << "{r=" << ot.read_version << ",w=" << ot.write_version << "}"; return out; @@ -1093,48 +1057,26 @@ enum RGWBucketFlags { BUCKET_OBJ_LOCK_ENABLED = 0X20, }; -enum RGWBucketIndexType { - RGWBIType_Normal = 0, - RGWBIType_Indexless = 1, -}; - -inline ostream& operator<<(ostream& out, const RGWBucketIndexType &index_type) -{ - switch (index_type) { - case RGWBIType_Normal: - return out << "Normal"; - case RGWBIType_Indexless: - return out << "Indexless"; - default: - return out << "Unknown"; - } -} - class RGWSI_Zone; struct RGWBucketInfo { - enum BIShardsHashType { - MOD = 0 - }; - rgw_bucket bucket; rgw_user owner; uint32_t flags{0}; - string zonegroup; + std::string zonegroup; ceph::real_time creation_time; rgw_placement_rule placement_rule; bool has_instance_obj{false}; RGWObjVersionTracker objv_tracker; /* we don't need to serialize this, for runtime tracking */ RGWQuotaInfo quota; + // layout of bucket index objects + rgw::BucketLayout layout; + // Represents the number of bucket index object shards: // - value of 0 indicates there is no sharding (this is by default // before this feature is implemented). // - value of UINT32_T::MAX indicates this is a blind bucket. - uint32_t num_shards{0}; - - // Represents the bucket index shard hash type. - uint8_t bucket_index_shard_hash_type{MOD}; // Represents the shard number for blind bucket. const static uint32_t NUM_SHARDS_BLIND_BUCKET; @@ -1144,16 +1086,14 @@ struct RGWBucketInfo { bool has_website{false}; RGWBucketWebsiteConf website_conf; - RGWBucketIndexType index_type = RGWBIType_Normal; - bool swift_versioning{false}; - string swift_ver_location; + std::string swift_ver_location; - map mdsearch_config; + std::map mdsearch_config; // resharding cls_rgw_reshard_status reshard_status{cls_rgw_reshard_status::NOT_RESHARDING}; - string new_bucket_instance_id; + std::string new_bucket_instance_id; RGWObjectLock obj_lock; @@ -1163,7 +1103,7 @@ struct RGWBucketInfo { void decode(bufferlist::const_iterator& bl); void dump(Formatter *f) const; - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); void decode_json(JSONObj *obj); @@ -1240,7 +1180,7 @@ struct RGWBucketEntryPoint void dump(Formatter *f) const; void decode_json(JSONObj *obj); - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(RGWBucketEntryPoint) @@ -1249,17 +1189,20 @@ struct RGWStorageStats RGWObjCategory category; uint64_t size; uint64_t size_rounded; - uint64_t size_utilized{0}; //< size after compression, encryption uint64_t num_objects; + uint64_t size_utilized{0}; //< size after compression, encryption + bool dump_utilized; // whether dump should include utilized values - RGWStorageStats() + RGWStorageStats(bool _dump_utilized=true) : category(RGWObjCategory::None), size(0), size_rounded(0), - num_objects(0) {} + num_objects(0), + dump_utilized(_dump_utilized) + {} void dump(Formatter *f) const; -}; +}; // RGWStorageStats class RGWEnv; @@ -1283,41 +1226,42 @@ struct req_info { const RGWEnv *env; RGWHTTPArgs args; meta_map_t x_meta_map; + meta_map_t crypt_attribute_map; - string host; + std::string host; const char *method; - string script_uri; - string request_uri; - string request_uri_aws4; - string effective_uri; - string request_params; - string domain; - string storage_class; + std::string script_uri; + std::string request_uri; + std::string request_uri_aws4; + std::string effective_uri; + std::string request_params; + std::string domain; + std::string storage_class; req_info(CephContext *cct, const RGWEnv *env); void rebuild_from(req_info& src); - void init_meta_info(bool *found_bad_meta); + void init_meta_info(const DoutPrefixProvider *dpp, bool *found_bad_meta); }; typedef cls_rgw_obj_key rgw_obj_index_key; struct rgw_obj_key { - string name; - string instance; - string ns; + std::string name; + std::string instance; + std::string ns; rgw_obj_key() {} // cppcheck-suppress noExplicitConstructor - rgw_obj_key(const string& n) : name(n) {} - rgw_obj_key(const string& n, const string& i) : name(n), instance(i) {} - rgw_obj_key(const string& n, const string& i, const string& _ns) : name(n), instance(i), ns(_ns) {} + rgw_obj_key(const std::string& n) : name(n) {} + rgw_obj_key(const std::string& n, const std::string& i) : name(n), instance(i) {} + rgw_obj_key(const std::string& n, const std::string& i, const std::string& _ns) : name(n), instance(i), ns(_ns) {} rgw_obj_key(const rgw_obj_index_key& k) { parse_index_key(k.name, &name, &ns); instance = k.instance; } - static void parse_index_key(const string& key, string *name, string *ns) { + static void parse_index_key(const std::string& key, std::string *name, std::string *ns) { if (key[0] != '_') { *name = key; ns->clear(); @@ -1340,19 +1284,19 @@ struct rgw_obj_key { *ns = key.substr(1, pos -1); } - void set(const string& n) { + void set(const std::string& n) { name = n; instance.clear(); ns.clear(); } - void set(const string& n, const string& i) { + void set(const std::string& n, const std::string& i) { name = n; instance = i; ns.clear(); } - void set(const string& n, const string& i, const string& _ns) { + void set(const std::string& n, const std::string& i, const std::string& _ns) { name = n; instance = i; ns = _ns; @@ -1366,11 +1310,11 @@ struct rgw_obj_key { return true; } - void set_instance(const string& i) { + void set_instance(const std::string& i) { instance = i; } - const string& get_instance() const { + const std::string& get_instance() const { return instance; } @@ -1382,17 +1326,17 @@ struct rgw_obj_key { return ns; } - string get_index_key_name() const { + std::string get_index_key_name() const { if (ns.empty()) { if (name.size() < 1 || name[0] != '_') { return name; } - return string("_") + name; + return std::string("_") + name; }; char buf[ns.size() + 16]; snprintf(buf, sizeof(buf), "_%s_", ns.c_str()); - return string(buf) + name; + return std::string(buf) + name; }; void get_index_key(rgw_obj_index_key *key) const { @@ -1400,7 +1344,7 @@ struct rgw_obj_key { key->instance = instance; } - string get_loc() const { + std::string get_loc() const { /* * For backward compatibility. Older versions used to have object locator on all objects, * however, the name was the effective object locator. This had the same effect as not @@ -1411,7 +1355,7 @@ struct rgw_obj_key { return name; } - return string(); + return {}; } bool empty() const { @@ -1430,18 +1374,18 @@ struct rgw_obj_key { return have_instance() && !have_null_instance(); } - string get_oid() const { + std::string get_oid() const { if (ns.empty() && !need_to_encode_instance()) { if (name.size() < 1 || name[0] != '_') { return name; } - return string("_") + name; + return std::string("_") + name; } - string oid = "_"; + std::string oid = "_"; oid.append(ns); if (need_to_encode_instance()) { - oid.append(string(":") + instance); + oid.append(std::string(":") + instance); } oid.append("_"); oid.append(name); @@ -1465,7 +1409,7 @@ struct rgw_obj_key { return !(k < *this); } - static void parse_ns_field(string& ns, string& instance) { + static void parse_ns_field(std::string& ns, std::string& instance) { int pos = ns.find(':'); if (pos >= 0) { instance = ns.substr(pos + 1); @@ -1477,7 +1421,7 @@ struct rgw_obj_key { // takes an oid and parses out the namespace (ns), name, and // instance - static bool parse_raw_oid(const string& oid, rgw_obj_key *key) { + static bool parse_raw_oid(const std::string& oid, rgw_obj_key *key) { key->instance.clear(); key->ns.clear(); if (oid[0] != '_') { @@ -1494,7 +1438,7 @@ struct rgw_obj_key { return false; size_t pos = oid.find('_', 2); // oid must match ^_[^_].+$ - if (pos == string::npos) + if (pos == std::string::npos) return false; key->ns = oid.substr(1, pos - 1); @@ -1512,7 +1456,7 @@ struct rgw_obj_key { * and cuts down the name to the unmangled version. If it is not * part of the given namespace, it returns false. */ - static bool oid_to_key_in_ns(const string& oid, rgw_obj_key *key, const string& ns) { + static bool oid_to_key_in_ns(const std::string& oid, rgw_obj_key *key, const std::string& ns) { bool ret = parse_raw_oid(oid, key); if (!ret) { return ret; @@ -1522,14 +1466,14 @@ struct rgw_obj_key { } /** - * Given a mangled object name and an empty namespace string, this - * function extracts the namespace into the string and sets the object + * Given a mangled object name and an empty namespace std::string, this + * function extracts the namespace into the std::string and sets the object * name to be the unmangled version. * * It returns true after successfully doing so, or * false if it fails. */ - static bool strip_namespace_from_name(string& name, string& ns, string& instance) { + static bool strip_namespace_from_name(std::string& name, std::string& ns, std::string& instance) { ns.clear(); instance.clear(); if (name[0] != '_') { @@ -1537,7 +1481,7 @@ struct rgw_obj_key { } size_t pos = name.find('_', 1); - if (pos == string::npos) { + if (pos == std::string::npos) { return false; } @@ -1552,7 +1496,7 @@ struct rgw_obj_key { } ns = name.substr(1, pos-1); - name = name.substr(pos+1, string::npos); + name = name.substr(pos+1, std::string::npos); parse_ns_field(ns, instance); return true; @@ -1577,7 +1521,7 @@ struct rgw_obj_key { void dump(Formatter *f) const; void decode_json(JSONObj *obj); - string to_str() const { + std::string to_str() const { if (instance.empty()) { return name; } @@ -1588,22 +1532,14 @@ struct rgw_obj_key { }; WRITE_CLASS_ENCODER(rgw_obj_key) -inline ostream& operator<<(ostream& out, const rgw_obj_key &o) { +inline std::ostream& operator<<(std::ostream& out, const rgw_obj_key &o) { return out << o.to_str(); } -inline ostream& operator<<(ostream& out, const rgw_obj_index_key &o) { - if (o.instance.empty()) { - return out << o.name; - } else { - return out << o.name << "[" << o.instance << "]"; - } -} - struct req_init_state { /* Keeps [[tenant]:]bucket until we parse the token. */ - string url_bucket; - string src_bucket; + std::string url_bucket; + std::string src_bucket; }; #include "rgw_auth.h" @@ -1617,14 +1553,19 @@ struct req_state : DoutPrefixProvider { rgw::io::BasicClient *cio{nullptr}; http_op op{OP_UNKNOWN}; RGWOpType op_type{}; + std::shared_ptr ratelimit_data; + RGWRateLimitInfo user_ratelimit; + RGWRateLimitInfo bucket_ratelimit; + std::string ratelimit_bucket_marker; + std::string ratelimit_user_name; bool content_started{false}; int format{0}; ceph::Formatter *formatter{nullptr}; - string decoded_uri; - string relative_uri; + std::string decoded_uri; + std::string relative_uri; const char *length{nullptr}; int64_t content_length{0}; - map generic_attrs; + std::map generic_attrs; rgw_err err; bool expect_cont{false}; uint64_t obj_size{0}; @@ -1634,29 +1575,29 @@ struct req_state : DoutPrefixProvider { uint32_t perm_mask{0}; /* Set once when url_bucket is parsed and not violated thereafter. */ - string account_name; - - string bucket_tenant; - string bucket_name; - - rgw_bucket bucket; - rgw_obj_key object; - string src_tenant_name; - string src_bucket_name; - rgw_obj_key src_object; + std::string account_name; + + std::string bucket_tenant; + std::string bucket_name; + + /* bucket is only created in rgw_build_bucket_policies() and should never be + * overwritten */ + std::unique_ptr bucket; + std::unique_ptr object; + std::string src_tenant_name; + std::string src_bucket_name; + std::unique_ptr src_object; ACLOwner bucket_owner; ACLOwner owner; - string zonegroup_name; - string zonegroup_endpoint; - string bucket_instance_id; + std::string zonegroup_name; + std::string zonegroup_endpoint; + std::string bucket_instance_id; int bucket_instance_shard_id{-1}; - string redirect_zone_endpoint; + std::string redirect_zone_endpoint; - string redirect; + std::string redirect; - RGWBucketInfo bucket_info; - obj_version bucket_ep_objv; real_time bucket_mtime; std::map bucket_attrs; bool bucket_exists{false}; @@ -1664,7 +1605,7 @@ struct req_state : DoutPrefixProvider { bool has_bad_meta{false}; - rgw::sal::RGWUser *user; + std::unique_ptr user; struct { /* TODO(rzarzynski): switch out to the static_ptr for both members. */ @@ -1705,13 +1646,13 @@ struct req_state : DoutPrefixProvider { rgw::IAM::Environment env; boost::optional iam_policy; boost::optional bucket_access_conf; - vector iam_user_policies; + std::vector iam_user_policies; /* Is the request made by an user marked as a system one? * Being system user means we also have the admin status. */ bool system_request{false}; - string canned_acl; + std::string canned_acl; bool has_acl_header{false}; bool local_source{false}; /* source is local */ @@ -1719,11 +1660,11 @@ struct req_state : DoutPrefixProvider { /* Content-Disposition override for TempURL of Swift API. */ struct { - string override; - string fallback; + std::string override; + std::string fallback; } content_disp; - string host_id; + std::string host_id; req_info info; req_init_state init_state; @@ -1734,10 +1675,9 @@ struct req_state : DoutPrefixProvider { Clock::duration time_elapsed() const { return Clock::now() - time; } RGWObjectCtx *obj_ctx{nullptr}; - RGWSysObjectCtx *sysobj_ctx{nullptr}; - string dialect; - string req_id; - string trans_id; + std::string dialect; + std::string req_id; + std::string trans_id; uint64_t id; RGWObjTags tagset; @@ -1748,11 +1688,20 @@ struct req_state : DoutPrefixProvider { optional_yield yield{null_yield}; //token claims from STS token for ops log (can be used for Keystone token also) - std::vector token_claims; + std::vector token_claims; + + std::vector session_policies; + + jspan trace; + + //Principal tags that come in as part of AssumeRoleWithWebIdentity + std::vector> principal_tags; - req_state(CephContext* _cct, RGWEnv* e, rgw::sal::RGWUser* u, uint64_t id); + req_state(CephContext* _cct, RGWEnv* e, uint64_t id); ~req_state(); + + void set_user(std::unique_ptr& u) { user.swap(u); } bool is_err() const { return err.is_err(); } // implements DoutPrefixProvider @@ -1762,7 +1711,7 @@ struct req_state : DoutPrefixProvider { }; void set_req_state_err(struct req_state*, int); -void set_req_state_err(struct req_state*, int, const string&); +void set_req_state_err(struct req_state*, int, const std::string&); void set_req_state_err(struct rgw_err&, int, const int); void dump(struct req_state*); @@ -1808,7 +1757,7 @@ struct RGWBucketEnt { ENCODE_START(7, 5, bl); uint64_t s = size; __u32 mt = ceph::real_clock::to_time_t(creation_time); - string empty_str; // originally had the bucket name here, but we encode bucket later + std::string empty_str; // originally had the bucket name here, but we encode bucket later encode(empty_str, bl); encode(s, bl); encode(mt, bl); @@ -1824,7 +1773,7 @@ struct RGWBucketEnt { DECODE_START_LEGACY_COMPAT_LEN(7, 5, 5, bl); __u32 mt; uint64_t s; - string empty_str; // backward compatibility + std::string empty_str; // backward compatibility decode(empty_str, bl); decode(s, bl); decode(mt, bl); @@ -1846,7 +1795,7 @@ struct RGWBucketEnt { DECODE_FINISH(bl); } void dump(Formatter *f) const; - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(RGWBucketEnt) @@ -1868,11 +1817,11 @@ struct rgw_obj { bucket = b; key.set(name); } - void init(const rgw_bucket& b, const std::string& name, const string& i, const string& n) { + void init(const rgw_bucket& b, const std::string& name, const std::string& i, const std::string& n) { bucket = b; key.set(name, i, n); } - void init_ns(const rgw_bucket& b, const std::string& name, const string& n) { + void init_ns(const rgw_bucket& b, const std::string& name, const std::string& n) { bucket = b; key.name = name; key.instance.clear(); @@ -1887,11 +1836,11 @@ struct rgw_obj { key = k; } - string get_oid() const { + std::string get_oid() const { return key.get_oid(); } - const string& get_hash_object() const { + const std::string& get_hash_object() const { return index_hash_source.empty() ? key.name : index_hash_source; } @@ -1915,7 +1864,7 @@ struct rgw_obj { void decode(bufferlist::const_iterator& bl) { DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl); if (struct_v < 6) { - string s; + std::string s; decode(bucket.name, bl); /* bucket.name */ decode(s, bl); /* loc */ decode(key.ns, bl); @@ -1934,7 +1883,7 @@ struct rgw_obj { } else { ssize_t pos = key.name.find('_', 1); if (pos < 0) { - throw buffer::error(); + throw buffer::malformed_input(); } key.name = key.name.substr(pos + 1); } @@ -1949,7 +1898,7 @@ struct rgw_obj { DECODE_FINISH(bl); } void dump(Formatter *f) const; - static void generate_test_instances(list& o); + static void generate_test_instances(std::list& o); bool operator==(const rgw_obj& o) const { return (key == o.key) && @@ -1980,16 +1929,34 @@ struct rgw_obj { WRITE_CLASS_ENCODER(rgw_obj) struct rgw_cache_entry_info { - string cache_locator; + std::string cache_locator; uint64_t gen; rgw_cache_entry_info() : gen(0) {} }; -inline ostream& operator<<(ostream& out, const rgw_obj &o) { +inline std::ostream& operator<<(std::ostream& out, const rgw_obj &o) { return out << o.bucket.name << ":" << o.get_oid(); } +struct multipart_upload_info +{ + rgw_placement_rule dest_placement; + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + encode(dest_placement, bl); + ENCODE_FINISH(bl); + } + + void decode(bufferlist::const_iterator& bl) { + DECODE_START(1, bl); + decode(dest_placement, bl); + DECODE_FINISH(bl); + } +}; +WRITE_CLASS_ENCODER(multipart_upload_info) + static inline void buf_to_hex(const unsigned char* const buf, const size_t len, char* const str) @@ -2056,7 +2023,7 @@ static inline int rgw_str_to_bool(const char *s, int def_val) strcasecmp(s, "1") == 0); } -static inline void append_rand_alpha(CephContext *cct, const string& src, string& dest, int len) +static inline void append_rand_alpha(CephContext *cct, const std::string& src, std::string& dest, int len) { dest = src; char buf[len + 1]; @@ -2065,22 +2032,6 @@ static inline void append_rand_alpha(CephContext *cct, const string& src, string dest.append(buf); } -static inline const char *rgw_obj_category_name(RGWObjCategory category) -{ - switch (category) { - case RGWObjCategory::None: - return "rgw.none"; - case RGWObjCategory::Main: - return "rgw.main"; - case RGWObjCategory::Shadow: - return "rgw.shadow"; - case RGWObjCategory::MultiMeta: - return "rgw.multimeta"; - } - - return "unknown"; -} - static inline uint64_t rgw_rounded_kb(uint64_t bytes) { return (bytes + 1023) / 1024; @@ -2103,35 +2054,44 @@ void rgw_add_amz_meta_header( const std::string& k, const std::string& v); -extern string rgw_string_unquote(const string& s); -extern void parse_csv_string(const string& ival, vector& ovals); -extern int parse_key_value(string& in_str, string& key, string& val); -extern int parse_key_value(string& in_str, const char *delim, string& key, string& val); +enum rgw_set_action_if_set { + DISCARD=0, OVERWRITE, APPEND +}; + +bool rgw_set_amz_meta_header( + meta_map_t& x_meta_map, + const std::string& k, + const std::string& v, rgw_set_action_if_set f); + +extern std::string rgw_string_unquote(const std::string& s); +extern void parse_csv_string(const std::string& ival, std::vector& ovals); +extern int parse_key_value(std::string& in_str, std::string& key, std::string& val); +extern int parse_key_value(std::string& in_str, const char *delim, std::string& key, std::string& val); -extern boost::optional> -parse_key_value(const boost::string_view& in_str, - const boost::string_view& delim); -extern boost::optional> -parse_key_value(const boost::string_view& in_str); +extern boost::optional> +parse_key_value(const std::string_view& in_str, + const std::string_view& delim); +extern boost::optional> +parse_key_value(const std::string_view& in_str); /** time parsing */ extern int parse_time(const char *time_str, real_time *time); extern bool parse_rfc2616(const char *s, struct tm *t); extern bool parse_iso8601(const char *s, struct tm *t, uint32_t *pns = NULL, bool extended_format = true); -extern string rgw_trim_whitespace(const string& src); -extern boost::string_view rgw_trim_whitespace(const boost::string_view& src); -extern string rgw_trim_quotes(const string& val); +extern std::string rgw_trim_whitespace(const std::string& src); +extern std::string_view rgw_trim_whitespace(const std::string_view& src); +extern std::string rgw_trim_quotes(const std::string& val); extern void rgw_to_iso8601(const real_time& t, char *dest, int buf_size); -extern void rgw_to_iso8601(const real_time& t, string *dest); +extern void rgw_to_iso8601(const real_time& t, std::string *dest); extern std::string rgw_to_asctime(const utime_t& t); struct perm_state_base { CephContext *cct; const rgw::IAM::Environment& env; rgw::auth::Identity *identity; - const RGWBucketInfo& bucket_info; + const RGWBucketInfo bucket_info; int perm_mask; bool defer_to_bucket_acls; boost::optional bucket_access_conf; @@ -2213,15 +2173,15 @@ bool verify_object_permission_no_policy(const DoutPrefixProvider* dpp, /** Check if the req_state's user has the necessary permissions * to do the requested action */ -rgw::IAM::Effect eval_user_policies(const vector& user_policies, +rgw::IAM::Effect eval_identity_or_session_policies(const std::vector& user_policies, const rgw::IAM::Environment& env, - boost::optional id, const uint64_t op, const rgw::ARN& arn); bool verify_user_permission(const DoutPrefixProvider* dpp, struct req_state * const s, RGWAccessControlPolicy * const user_acl, - const vector& user_policies, + const std::vector& user_policies, + const std::vector& session_policies, const rgw::ARN& res, const uint64_t op); bool verify_user_permission_no_policy(const DoutPrefixProvider* dpp, @@ -2242,7 +2202,8 @@ bool verify_bucket_permission( RGWAccessControlPolicy * const user_acl, RGWAccessControlPolicy * const bucket_acl, const boost::optional& bucket_policy, - const vector& user_policies, + const std::vector& identity_policies, + const std::vector& session_policies, const uint64_t op); bool verify_bucket_permission(const DoutPrefixProvider* dpp, struct req_state * const s, const uint64_t op); bool verify_bucket_permission_no_policy( @@ -2264,7 +2225,8 @@ extern bool verify_object_permission( RGWAccessControlPolicy * const bucket_acl, RGWAccessControlPolicy * const object_acl, const boost::optional& bucket_policy, - const vector& user_policies, + const std::vector& identity_policies, + const std::vector& session_policies, const uint64_t op); extern bool verify_object_permission(const DoutPrefixProvider* dpp, struct req_state *s, uint64_t op); extern bool verify_object_permission_no_policy( @@ -2276,12 +2238,18 @@ extern bool verify_object_permission_no_policy( int perm); extern bool verify_object_permission_no_policy(const DoutPrefixProvider* dpp, struct req_state *s, int perm); +extern int verify_object_lock( + const DoutPrefixProvider* dpp, + const rgw::sal::Attrs& attrs, + const bool bypass_perm, + const bool bypass_governance_mode); + /** Convert an input URL into a sane object name - * by converting %-escaped strings into characters, etc*/ -extern void rgw_uri_escape_char(char c, string& dst); -extern std::string url_decode(const boost::string_view& src_str, + * by converting %-escaped std::strings into characters, etc*/ +extern void rgw_uri_escape_char(char c, std::string& dst); +extern std::string url_decode(const std::string_view& src_str, bool in_query = false); -extern void url_encode(const std::string& src, string& dst, +extern void url_encode(const std::string& src, std::string& dst, bool encode_slash = true); extern std::string url_encode(const std::string& src, bool encode_slash = true); extern std::string url_remove_prefix(const std::string& url); // Removes hhtp, https and www from url @@ -2290,7 +2258,7 @@ extern void calc_hmac_sha1(const char *key, int key_len, const char *msg, int msg_len, char *dest); static inline sha1_digest_t -calc_hmac_sha1(const boost::string_view& key, const boost::string_view& msg) { +calc_hmac_sha1(const std::string_view& key, const std::string_view& msg) { sha1_digest_t dest; calc_hmac_sha1(key.data(), key.size(), msg.data(), msg.size(), reinterpret_cast(dest.v)); @@ -2312,7 +2280,7 @@ calc_hmac_sha256(const char *key, const int key_len, } static inline sha256_digest_t -calc_hmac_sha256(const boost::string_view& key, const boost::string_view& msg) { +calc_hmac_sha256(const std::string_view& key, const std::string_view& msg) { sha256_digest_t dest; calc_hmac_sha256(key.data(), key.size(), msg.data(), msg.size(), @@ -2322,7 +2290,7 @@ calc_hmac_sha256(const boost::string_view& key, const boost::string_view& msg) { static inline sha256_digest_t calc_hmac_sha256(const sha256_digest_t &key, - const boost::string_view& msg) { + const std::string_view& msg) { sha256_digest_t dest; calc_hmac_sha256(reinterpret_cast(key.v), sha256_digest_t::SIZE, msg.data(), msg.size(), @@ -2332,7 +2300,7 @@ calc_hmac_sha256(const sha256_digest_t &key, static inline sha256_digest_t calc_hmac_sha256(const std::vector& key, - const boost::string_view& msg) { + const std::string_view& msg) { sha256_digest_t dest; calc_hmac_sha256(reinterpret_cast(key.data()), key.size(), msg.data(), msg.size(), @@ -2343,7 +2311,7 @@ calc_hmac_sha256(const std::vector& key, template static inline sha256_digest_t calc_hmac_sha256(const std::array& key, - const boost::string_view& msg) { + const std::string_view& msg) { sha256_digest_t dest; calc_hmac_sha256(reinterpret_cast(key.data()), key.size(), msg.data(), msg.size(), @@ -2351,7 +2319,7 @@ calc_hmac_sha256(const std::array& key, return dest; } -extern sha256_digest_t calc_hash_sha256(const boost::string_view& msg); +extern sha256_digest_t calc_hash_sha256(const std::string_view& msg); extern ceph::crypto::SHA256* calc_hash_sha256_open_stream(); extern void calc_hash_sha256_update_stream(ceph::crypto::SHA256* hash, @@ -2360,24 +2328,24 @@ extern void calc_hash_sha256_update_stream(ceph::crypto::SHA256* hash, extern std::string calc_hash_sha256_close_stream(ceph::crypto::SHA256** phash); extern std::string calc_hash_sha256_restart_stream(ceph::crypto::SHA256** phash); -extern int rgw_parse_op_type_list(const string& str, uint32_t *perm); +extern int rgw_parse_op_type_list(const std::string& str, uint32_t *perm); static constexpr uint32_t MATCH_POLICY_ACTION = 0x01; static constexpr uint32_t MATCH_POLICY_RESOURCE = 0x02; static constexpr uint32_t MATCH_POLICY_ARN = 0x04; static constexpr uint32_t MATCH_POLICY_STRING = 0x08; -extern bool match_policy(boost::string_view pattern, boost::string_view input, +extern bool match_policy(std::string_view pattern, std::string_view input, uint32_t flag); -extern string camelcase_dash_http_attr(const string& orig); -extern string lowercase_dash_http_attr(const string& orig); +extern std::string camelcase_dash_http_attr(const std::string& orig); +extern std::string lowercase_dash_http_attr(const std::string& orig); void rgw_setup_saved_curl_handles(); void rgw_release_all_curl_handles(); -static inline void rgw_escape_str(const string& s, char esc_char, - char special_char, string *dest) +static inline void rgw_escape_str(const std::string& s, char esc_char, + char special_char, std::string *dest) { const char *src = s.c_str(); char dest_buf[s.size() * 2 + 1]; @@ -2394,9 +2362,9 @@ static inline void rgw_escape_str(const string& s, char esc_char, *dest = dest_buf; } -static inline ssize_t rgw_unescape_str(const string& s, ssize_t ofs, +static inline ssize_t rgw_unescape_str(const std::string& s, ssize_t ofs, char esc_char, char special_char, - string *dest) + std::string *dest) { const char *src = s.c_str(); char dest_buf[s.size() + 1]; @@ -2421,13 +2389,13 @@ static inline ssize_t rgw_unescape_str(const string& s, ssize_t ofs, } *destp = '\0'; *dest = dest_buf; - return string::npos; + return std::string::npos; } -static inline string rgw_bl_str(ceph::buffer::list& raw) +static inline std::string rgw_bl_str(ceph::buffer::list& raw) { size_t len = raw.length(); - string s(raw.c_str(), len); + std::string s(raw.c_str(), len); while (len && !s[len - 1]) { --len; s.resize(len); @@ -2446,5 +2414,3 @@ int decode_bl(bufferlist& bl, T& t) } return 0; } - -#endif