aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/fetch2
diff options
context:
space:
mode:
authorStephano Cetola <stephano.cetola@linux.intel.com>2016-08-26 10:41:43 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-02 16:29:36 +0100
commitcea8113d14da9e12db80a5b6b5811a47a7dfdeef (patch)
treee2c9e37e598b1547edf44330257cda91c3d4199c /lib/bb/fetch2
parent107c47c4e6de6a596cf1aeca5c18dbc1c5b44dc4 (diff)
downloadbitbake-cea8113d14da9e12db80a5b6b5811a47a7dfdeef.tar.gz
wget: allow basic http auth for SSTATE_MIRRORS
If http basic auth creds were added to sstate mirrors like so: https://foo.com/sstate/PATH;user=foo:bar;downloadfilename=PATH The sstate mirror check would silently fail with 401 unauthorized. This patch allows both the check, and the wget download to succeed by checking for user credentials and if present adding the correct headers, or wget params as needed. [ YOCTO #9815 ] Signed-off-by: Stephano Cetola <stephano.cetola@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/fetch2')
-rw-r--r--lib/bb/fetch2/wget.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 6b60d9b16..ecb946aa8 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -108,6 +108,10 @@ class Wget(FetchMethod):
bb.utils.mkdirhier(os.path.dirname(dldir + os.sep + ud.localfile))
fetchcmd += " -O " + dldir + os.sep + ud.localfile
+ if ud.user:
+ up = ud.user.split(":")
+ fetchcmd += " --user=%s --password=%s --auth-no-challenge" % (up[0],up[1])
+
uri = ud.url.split(";")[0]
if os.path.exists(ud.localpath):
# file exists, but we didnt complete it.. trying again..
@@ -300,6 +304,13 @@ class Wget(FetchMethod):
uri = ud.url.split(";")[0]
r = urllib.request.Request(uri)
r.get_method = lambda: "HEAD"
+
+ if ud.user:
+ import base64
+ encodeuser = base64.b64encode(ud.user.encode('utf-8')).decode("utf-8")
+ authheader = "Basic %s" % encodeuser
+ r.add_header("Authorization", authheader)
+
opener.open(r)
except urllib.error.URLError as e:
if try_again: