summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMatthew McClintock <msm-oss@mcclintock.net>2016-12-16 03:32:42 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-20 15:22:51 +0000
commitaa15ff631c10228d31ab3655e4e6921088a7804b (patch)
tree09e31ac7a84b5ce761cdcc2330da6e64f7425201 /bitbake
parentfe7e75075e2d55a45ad2b81c9e493068a156d1dc (diff)
downloadpoky-aa15ff631c10228d31ab3655e4e6921088a7804b.tar.gz
bitbake: fetch2/wget: add Basic Auth from netrc to checkstatus()
fetch2/wget uses urllib to check the status of the mirrors, wget will use netrc to pass login and password information however checkstatus will skip that. This adds netrc login and password to checkstatus so both will work the same. (Bitbake rev: 873e33d0479e977520106b65d149ff1799195bf6) Signed-off-by: Matthew McClintock <msm-oss@mcclintock.net> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/wget.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index 6dfb27bd95..88349c9bf9 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -305,12 +305,24 @@ class Wget(FetchMethod):
305 r = urllib.request.Request(uri) 305 r = urllib.request.Request(uri)
306 r.get_method = lambda: "HEAD" 306 r.get_method = lambda: "HEAD"
307 307
308 if ud.user: 308 def add_basic_auth(login_str, request):
309 '''Adds Basic auth to http request, pass in login:password as string'''
309 import base64 310 import base64
310 encodeuser = base64.b64encode(ud.user.encode('utf-8')).decode("utf-8") 311 encodeuser = base64.b64encode(login_str.encode('utf-8')).decode("utf-8")
311 authheader = "Basic %s" % encodeuser 312 authheader = "Basic %s" % encodeuser
312 r.add_header("Authorization", authheader) 313 r.add_header("Authorization", authheader)
313 314
315 if ud.user:
316 add_basic_auth(ud.user, r)
317
318 try:
319 import netrc, urllib.parse
320 n = netrc.netrc()
321 login, unused, password = n.authenticators(urllib.parse.urlparse(uri).hostname)
322 add_basic_auth("%s:%s" % (login, password), r)
323 except (ImportError, IOError, netrc.NetrcParseError):
324 pass
325
314 opener.open(r) 326 opener.open(r)
315 except urllib.error.URLError as e: 327 except urllib.error.URLError as e:
316 if try_again: 328 if try_again: