]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix SignatureDoesNotMatch when use ipv6 address in s3 client 33267/head
authoryuliyang <yuliyang@cmss.chinamobile.com>
Tue, 8 Oct 2019 05:30:08 +0000 (13:30 +0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 13 Feb 2020 13:34:08 +0000 (14:34 +0100)
fix: https://tracker.ceph.com/issues/42218

Signed-off-by: yuliyang <yuliyang@cmss.chinamobile.com>
(cherry picked from commit 1039ed8f5173cac1e1d476e5b26911dccba0a203)

src/rgw/rgw_rest.cc
src/rgw/rgw_rest_s3.h

index d969b8f5102f5c5d5b9cdefaa478156044480b58..9a52af5d7bf59588aa4bd530e9204f2a696a4031 100644 (file)
@@ -2033,9 +2033,17 @@ int RGWREST::preprocess(struct req_state *s, rgw::io::BasicClient* cio)
   bool s3website_enabled = api_priority_s3website >= 0;
 
   if (info.host.size()) {
-    ssize_t pos = info.host.find(':');
-    if (pos >= 0) {
-      info.host = info.host.substr(0, pos);
+    ssize_t pos;
+    if (info.host.find('[') == 0) {
+      pos = info.host.find(']');
+      if (pos >=1) {
+        info.host = info.host.substr(1, pos-1);
+      }
+    } else {
+      pos = info.host.find(':');
+      if (pos >= 0) {
+        info.host = info.host.substr(0, pos);
+      }
     }
     ldout(s->cct, 10) << "host=" << info.host << dendl;
     string domain;
index 8031f9303e497f3b86ae5ab553591d5331accc4d..356d3f48ab6ea60e0f064ce89828d50f233b6dd1 100644 (file)
@@ -701,6 +701,10 @@ class RGWHandler_REST_Obj_S3Website;
 
 static inline bool looks_like_ip_address(const char *bucket)
 {
+  struct in6_addr a;
+  if (inet_pton(AF_INET6, bucket, static_cast<void*>(&a)) == 1) {
+    return true;
+  }
   int num_periods = 0;
   bool expect_period = false;
   for (const char *b = bucket; *b; ++b) {