From 396ca9a641429e59e09d3a3c28dc85623197797f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Mon, 23 Jun 2025 12:49:27 +0200 Subject: [PATCH] gh-135823: improve error message in `netrc` security checks (#135827) --- Lib/netrc.py | 4 ++-- .../Library/2025-06-22-22-03-06.gh-issue-135823.iDBg97.rst | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-06-22-22-03-06.gh-issue-135823.iDBg97.rst diff --git a/Lib/netrc.py b/Lib/netrc.py index bd003e80a48..2f502c1d533 100644 --- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -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" diff --git a/Misc/NEWS.d/next/Library/2025-06-22-22-03-06.gh-issue-135823.iDBg97.rst b/Misc/NEWS.d/next/Library/2025-06-22-22-03-06.gh-issue-135823.iDBg97.rst new file mode 100644 index 00000000000..5b9d89caae7 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-06-22-22-03-06.gh-issue-135823.iDBg97.rst @@ -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.