diff options
-rw-r--r-- | bitbake/lib/bb/fetch2/wget.py | 16 |
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: |