diff options
author | Stephano Cetola <stephano.cetola@linux.intel.com> | 2016-08-26 10:41:43 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-09-02 18:09:49 +0100 |
commit | 46bad463ef99db9f237723614c5de01f89d5e54f (patch) | |
tree | aa7e8abf97323aea7dfc497abae995d3d4d69cb5 /bitbake/lib | |
parent | 3658f6d4770b9015561b33c1e24078b1713372e4 (diff) | |
download | poky-46bad463ef99db9f237723614c5de01f89d5e54f.tar.gz |
bitbake: 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 ]
(Bitbake rev: cea8113d14da9e12db80a5b6b5811a47a7dfdeef)
Signed-off-by: Stephano Cetola <stephano.cetola@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py index 6b60d9b16b..ecb946aa81 100644 --- a/bitbake/lib/bb/fetch2/wget.py +++ b/bitbake/lib/bb/fetch2/wget.py | |||
@@ -108,6 +108,10 @@ class Wget(FetchMethod): | |||
108 | bb.utils.mkdirhier(os.path.dirname(dldir + os.sep + ud.localfile)) | 108 | bb.utils.mkdirhier(os.path.dirname(dldir + os.sep + ud.localfile)) |
109 | fetchcmd += " -O " + dldir + os.sep + ud.localfile | 109 | fetchcmd += " -O " + dldir + os.sep + ud.localfile |
110 | 110 | ||
111 | if ud.user: | ||
112 | up = ud.user.split(":") | ||
113 | fetchcmd += " --user=%s --password=%s --auth-no-challenge" % (up[0],up[1]) | ||
114 | |||
111 | uri = ud.url.split(";")[0] | 115 | uri = ud.url.split(";")[0] |
112 | if os.path.exists(ud.localpath): | 116 | if os.path.exists(ud.localpath): |
113 | # file exists, but we didnt complete it.. trying again.. | 117 | # file exists, but we didnt complete it.. trying again.. |
@@ -300,6 +304,13 @@ class Wget(FetchMethod): | |||
300 | uri = ud.url.split(";")[0] | 304 | uri = ud.url.split(";")[0] |
301 | r = urllib.request.Request(uri) | 305 | r = urllib.request.Request(uri) |
302 | r.get_method = lambda: "HEAD" | 306 | r.get_method = lambda: "HEAD" |
307 | |||
308 | if ud.user: | ||
309 | import base64 | ||
310 | encodeuser = base64.b64encode(ud.user.encode('utf-8')).decode("utf-8") | ||
311 | authheader = "Basic %s" % encodeuser | ||
312 | r.add_header("Authorization", authheader) | ||
313 | |||
303 | opener.open(r) | 314 | opener.open(r) |
304 | except urllib.error.URLError as e: | 315 | except urllib.error.URLError as e: |
305 | if try_again: | 316 | if try_again: |