]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-135823: improve error message in `netrc` security checks (#135827)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Mon, 23 Jun 2025 10:49:27 +0000 (12:49 +0200)
committerGitHub <noreply@github.com>
Mon, 23 Jun 2025 10:49:27 +0000 (12:49 +0200)
Lib/netrc.py
Misc/NEWS.d/next/Library/2025-06-22-22-03-06.gh-issue-135823.iDBg97.rst [new file with mode: 0644]

index bd003e80a48081e079698d7c401e8dec56bcc263..2f502c1d53364f806619e112caf9ddf5800fea70 100644 (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"
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 (file)
index 0000000..5b9d89c
--- /dev/null
@@ -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.