diff mbox series

fetch/wget: Fix netrc auth under pseudo

Message ID 20261203114622.2237041-1-frieder@fris.de
State New
Headers show
Series fetch/wget: Fix netrc auth under pseudo | expand

Commit Message

Frieder Schrempf Dec. 3, 2026, 11:46 a.m. UTC
From: Eberhard Stoll <eberhard.stoll@kontron.de>

checkstatus() calls netrc.netrc() without a path, so Python checks that
~/.netrc is owned by getuid(). Under pseudo getuid() is 0, the check
fails, the NetrcParseError is ignored and no auth is sent. Fakeroot
setscene tasks then get HTTP 401 from an authenticated sstate mirror
("No sstate archive obtainable"). Pass the path explicitly to skip the
owner and permission checks, which the wget binary doesn't do either.

Tested with an authenticated sstate mirror on Yocto 6.0: fakeroot
setscene tasks now fetch.

AI-Generated: Uses Claude Code
Signed-off-by: Eberhard Stoll <eberhard.stoll@kontron.de>
Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
 lib/bb/fetch/wget.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/fetch/wget.py b/lib/bb/fetch/wget.py
index 4db047f94..b2f440608 100644
--- a/lib/bb/fetch/wget.py
+++ b/lib/bb/fetch/wget.py
@@ -481,7 +481,10 @@  class Wget(FetchMethod):
 
                 try:
                     import netrc
-                    auth_data = netrc.netrc().authenticators(urllib.parse.urlparse(uri).hostname)
+                    # Explicit path: skip the owner check, which fails under
+                    # pseudo where getuid() is 0
+                    netrc_path = os.path.join(os.path.expanduser("~"), ".netrc")
+                    auth_data = netrc.netrc(netrc_path).authenticators(urllib.parse.urlparse(uri).hostname)
                     if auth_data:
                         login, _, password = auth_data
                         add_basic_auth("%s:%s" % (login, password), r)