Skip to contentSkip to conversation

fetch2/wget: handle username/password in uri

PATCH In review [email protected] 2 participants 2 messages Nov 29, 2022 – Jan 15, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/wget: handle username/password in uri

From: Kasper Revsbech <[email protected]>

In checkstatus() opener.open() is used to check if an artifact is available. The check fails if the uri contains username password in the format:
"username:password@hostname..". Moreover, the checkstatus function already uses the username from the "ud" object to craft a header, is username and password is provided.

This fix ensure the uri in the Requests object used does not contain username as password.

---
 lib/bb/fetch2/wget.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/fetch2/wget.py +2 -1
index 821afa5b..d9aaad6b 100644
@@ -341,7 +341,8 @@ class Wget(FetchMethod):
             opener = urllib.request.build_opener(*handlers)
 
             try:
-                uri = ud.url.split(";")[0]
+                uri_base = ud.url.split(";")[0]
+                uri = "{}://{}{}".format(urllib.parse.urlparse(uri_base).scheme, ud.host, ud.path)
                 r = urllib.request.Request(uri)
                 r.get_method = lambda: "HEAD"
                 # Some servers (FusionForge, as used on Alioth) require that the
Signature · 1 line
2.34.1
#1 lore raw
Quoted 21 lines · Kasper

From: Kasper Revsbech <[email protected]>

In checkstatus() opener.open() is used to check if an artifact is available. The check fails if the uri contains username password in the format:
"username:password@hostname..". Moreover, the checkstatus function already uses the username from the "ud" object to craft a header, is username and password is provided.

This fix ensure the uri in the Requests object used does not contain username as password.

---
 lib/bb/fetch2/wget.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/fetch2/wget.py +0 -0
index 821afa5b..d9aaad6b 100644

lib/bb/fetch2/wget.py class Wget(FetchMethod): · line 348

Quoted 9 lines
lib/bb/fetch2/wget.py +2 -1
@@ -341,7 +341,8 @@ class Wget(FetchMethod):
             opener = urllib.request.build_opener(*handlers)
 
             try:
-                uri = ud.url.split(";")[0]
+                uri_base = ud.url.split(";")[0]
+                uri = "{}://{}{}".format(urllib.parse.urlparse(uri_base).scheme, ud.host, ud.path)
                 r = urllib.request.Request(uri)
                 r.get_method = lambda: "HEAD"
                 # Some servers (FusionForge, as used on Alioth) require that the

Didn't this merge back in December?

https://git.yoctoproject.org/poky/commit/bitbake/lib/bb/fetch2?id=89ccf603d8119c34f5398dbd737e6a0b805234d3

Cheers,

Richard