]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix SignatureDoesNotMatch when use ipv6 address in s3 client 30778/head
authoryuliyang <yuliyang@cmss.chinamobile.com>
Tue, 8 Oct 2019 05:30:08 +0000 (13:30 +0800)
committeryuliyang <yuliyang@cmss.chinamobile.com>
Tue, 8 Oct 2019 07:32:37 +0000 (15:32 +0800)
fix: https://tracker.ceph.com/issues/42218

Signed-off-by: yuliyang <yuliyang@cmss.chinamobile.com>
src/rgw/rgw_rest.cc
src/rgw/rgw_rest_s3.h

index a8fe2de62c85501227eeee844bfd93f0a43b5f0a..1378dfc43b559f7d0abecfa614fd6792baa1516f 100644 (file)
@@ -2032,9 +2032,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 97bd1db3ff0a7bba9b27cb57b45b21ff0af280bd..f48f34f39ca5c79060a8659633bb5049ecd6af84 100644 (file)
@@ -727,6 +727,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) {