]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_iam_policy.h
update sources to 12.2.2
[ceph.git] / ceph / src / rgw / rgw_iam_policy.h
index 4429a57430964976bacb0193681db03b4bfe9717..59117456e0cc4a11c59213e29f7f37fe8fc9146d 100644 (file)
 #include "rapidjson/error/error.h"
 #include "rapidjson/error/en.h"
 
-#include "fnmatch.h"
-
+#include "rgw_acl.h"
 #include "rgw_basic_types.h"
 #include "rgw_iam_policy_keywords.h"
-
-#include "include/assert.h" // razzin' frazzin' ...grrr.
+#include "rgw_string.h"
 
 class RGWRados;
 namespace rgw {
@@ -91,7 +89,13 @@ static constexpr std::uint64_t s3PutLifecycleConfiguration = 1ULL << 44;
 static constexpr std::uint64_t s3PutReplicationConfiguration = 1ULL << 45;
 static constexpr std::uint64_t s3GetReplicationConfiguration = 1ULL << 46;
 static constexpr std::uint64_t s3DeleteReplicationConfiguration = 1ULL << 47;
-static constexpr std::uint64_t s3Count = 48;
+static constexpr std::uint64_t s3GetObjectTagging = 1ULL << 48;
+static constexpr std::uint64_t s3PutObjectTagging = 1ULL << 49;
+static constexpr std::uint64_t s3DeleteObjectTagging = 1ULL << 50;
+static constexpr std::uint64_t s3GetObjectVersionTagging = 1ULL << 51;
+static constexpr std::uint64_t s3PutObjectVersionTagging = 1ULL << 52;
+static constexpr std::uint64_t s3DeleteObjectVersionTagging = 1ULL << 53;
+static constexpr std::uint64_t s3Count = 54;
 static constexpr std::uint64_t s3All = (1ULL << s3Count) - 1;
 
 namespace {
@@ -101,6 +105,8 @@ inline int op_to_perm(std::uint64_t op) {
   case s3GetObjectTorrent:
   case s3GetObjectVersion:
   case s3GetObjectVersionTorrent:
+  case s3GetObjectTagging:
+  case s3GetObjectVersionTagging:
   case s3ListAllMyBuckets:
   case s3ListBucket:
   case s3ListBucketMultiPartUploads:
@@ -114,6 +120,10 @@ inline int op_to_perm(std::uint64_t op) {
   case s3DeleteObject:
   case s3DeleteObjectVersion:
   case s3PutObject:
+  case s3PutObjectTagging:
+  case s3PutObjectVersionTagging:
+  case s3DeleteObjectTagging:
+  case s3DeleteObjectVersionTagging:
   case s3RestoreObject:
     return RGW_PERM_WRITE;
 
@@ -242,7 +252,6 @@ string to_string(const MaskedIP& m);
 inline bool operator ==(const MaskedIP& l, const MaskedIP& r) {
   auto shift = std::max((l.v6 ? 128 : 32) - l.prefix,
                        (r.v6 ? 128 : 32) - r.prefix);
-  ceph_assert(shift > 0);
   return (l.addr >> shift) == (r.addr >> shift);
 }
 
@@ -261,18 +270,8 @@ struct Condition {
   std::vector<std::string> vals;
 
   Condition() = default;
-  Condition(TokenID op, const char* s, std::size_t len) : op(op) {
-    static constexpr char ifexistr[] = "IfExists";
-    auto l = static_cast<const char*>(memmem(static_cast<const void*>(s), len,
-                                            static_cast<const void*>(ifexistr),
-                                            sizeof(ifexistr) -1));
-    if (l && ((l + sizeof(ifexistr) - 1 == (s + len)))) {
-      ifexists = true;
-      key.assign(s, static_cast<const char*>(l) - s);
-    } else {
-      key.assign(s, len);
-    }
-  }
+  Condition(TokenID op, const char* s, std::size_t len, bool ifexists)
+    : op(op), key(s, len), ifexists(ifexists) {}
 
   bool eval(const Environment& e) const;
 
@@ -320,7 +319,7 @@ struct Condition {
     try {
       double d = std::stod(s, &p);
       if (p == s.length()) {
-       return !((d == +0.0) || (d = -0.0) || std::isnan(d));
+       return !((d == +0.0) || (d == -0.0) || std::isnan(d));
       }
     } catch (const std::logic_error& e) {
       // Fallthrough
@@ -350,15 +349,19 @@ struct Condition {
   static boost::optional<MaskedIP> as_network(const std::string& s);
 
 
-  struct ci_equal_to : public std::binary_function<const std::string,
-                                                  const std::string,
-                                                  bool> {
+  struct ci_equal_to {
     bool operator ()(const std::string& s1,
                     const std::string& s2) const {
       return boost::iequals(s1, s2);
     }
   };
 
+  struct string_like {
+    bool operator ()(const std::string& input,
+                     const std::string& pattern) const {
+      return match_wildcards(pattern, input, 0);
+    }
+  };
 
   template<typename F>
   static bool orrible(F&& f, const std::string& c,