gh-135823: improve error message in netrc security checks (#135827)

This commit is contained in:
Bénédikt Tran 2025-06-23 12:49:27 +02:00 committed by GitHub
parent 6aa0826ed7
commit 396ca9a641
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -162,8 +162,8 @@ class netrc:
fowner = _getpwuid(prop.st_uid)
user = _getpwuid(current_user_id)
raise NetrcParseError(
(f"~/.netrc file owner ({fowner}, {user}) does not match"
" current user"))
f"~/.netrc file owner ({fowner}) does not match"
f" current user ({user})")
if (prop.st_mode & (stat.S_IRWXG | stat.S_IRWXO)):
raise NetrcParseError(
"~/.netrc access too permissive: access"

View file

@ -0,0 +1,3 @@
:mod:`netrc`: improve the error message when the security check for the
ownership of the default configuration file ``~/.netrc`` fails. Patch by
Bénédikt Tran.