mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0031-v2v-rhv-upload-plugin-Remove-unneeded-auth.patch

d0ea73
From a3e99c84e1aed2fc275be00292f86414c8d4432a Mon Sep 17 00:00:00 2001
d0ea73
From: Nir Soffer <nirsof@gmail.com>
d0ea73
Date: Fri, 29 Jun 2018 17:41:10 +0300
d0ea73
Subject: [PATCH] v2v: rhv-upload-plugin: Remove unneeded auth
d0ea73
d0ea73
Old imageio proxy was using Authorization header for GET and PUT
d0ea73
requests. Remove unneeded authorization when sending OPTIONS request.
d0ea73
d0ea73
Remove unneeded duplicated comments about authorization for old
d0ea73
imageio, and replace them with a comment when we set needs_auth.
d0ea73
d0ea73
(cherry picked from commit d5f36bacf9bb6d4d244184551792989906f60896)
d0ea73
---
d0ea73
 v2v/rhv-upload-plugin.py | 12 +++++-------
d0ea73
 1 file changed, 5 insertions(+), 7 deletions(-)
d0ea73
d0ea73
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
d0ea73
index 8805e3552..f404bd758 100644
d0ea73
--- a/v2v/rhv-upload-plugin.py
d0ea73
+++ b/v2v/rhv-upload-plugin.py
d0ea73
@@ -191,16 +191,17 @@ def open(readonly):
d0ea73
     )
d0ea73
 
d0ea73
     # The first request is to fetch the features of the server.
d0ea73
+
d0ea73
+    # Authentication was needed only for GET and PUT requests when
d0ea73
+    # communicating with old imageio-proxy.
d0ea73
     needs_auth = not params['rhv_direct']
d0ea73
+
d0ea73
     can_flush = False
d0ea73
     can_trim = False
d0ea73
     can_zero = False
d0ea73
     unix_socket = None
d0ea73
 
d0ea73
-    http.putrequest("OPTIONS", destination_url.path)
d0ea73
-    http.putheader("Authorization", transfer.signed_ticket)
d0ea73
-    http.endheaders()
d0ea73
-
d0ea73
+    http.request("OPTIONS", destination_url.path)
d0ea73
     r = http.getresponse()
d0ea73
     data = r.read()
d0ea73
 
d0ea73
@@ -298,7 +299,6 @@ def pread(h, count, offset):
d0ea73
     transfer = h['transfer']
d0ea73
 
d0ea73
     headers = {"Range", "bytes=%d-%d" % (offset, offset+count-1)}
d0ea73
-    # Authorization is only needed for old imageio.
d0ea73
     if h['needs_auth']:
d0ea73
         headers["Authorization"] = transfer.signed_ticket
d0ea73
 
d0ea73
@@ -321,7 +321,6 @@ def pwrite(h, buf, offset):
d0ea73
     h['highestwrite'] = max(h['highestwrite'], offset+count)
d0ea73
 
d0ea73
     http.putrequest("PUT", h['path'] + "?flush=n")
d0ea73
-    # Authorization is only needed for old imageio.
d0ea73
     if h['needs_auth']:
d0ea73
         http.putheader("Authorization", transfer.signed_ticket)
d0ea73
     # The oVirt server only uses the first part of the range, and the
d0ea73
@@ -378,7 +377,6 @@ def emulate_zero(h, count, offset):
d0ea73
     # After that we must emulate them with writes.
d0ea73
     if offset+count < h['highestwrite']:
d0ea73
         http.putrequest("PUT", h['path'])
d0ea73
-        # Authorization is only needed for old imageio.
d0ea73
         if h['needs_auth']:
d0ea73
             http.putheader("Authorization", transfer.signed_ticket)
d0ea73
         http.putheader("Content-Range",
d0ea73
-- 
6b9fda
2.21.0
d0ea73