cpython: e5c4eb6b8e05 (original) (raw)

Mercurial > cpython

changeset 85728:e5c4eb6b8e05 2.6

#14984: On POSIX, enforce permissions when reading default .netrc. Initial patch by Bruno Piguet. This is implemented as if a useful .netrc file could exist without passwords, which is possible in the general case; but in fact our netrc implementation does not support it. Fixing that issue will be an enhancement. [#14984]

R David Murray rdmurray@bitdance.com
date Mon, 16 Sep 2013 13:48:44 -0400
parents 8a6def3add5b
children 2e19c65d6688 1b673e0fd8f3
files Doc/library/netrc.rst Lib/netrc.py Lib/test/test_netrc.py Misc/NEWS
diffstat 4 files changed, 56 insertions(+), 2 deletions(-)[+] [-] Doc/library/netrc.rst 6 Lib/netrc.py 23 Lib/test/test_netrc.py 23 Misc/NEWS 6

line wrap: on

line diff

--- a/Doc/library/netrc.rst +++ b/Doc/library/netrc.rst @@ -21,6 +21,12 @@ the Unix :program:ftp program and othe no argument is given, the file :file:.netrc in the user's home directory will be read. Parse errors will raise :exc:NetrcParseError with diagnostic information including the file name, line number, and terminating token.

.. exception:: NetrcParseError

--- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -2,7 +2,7 @@

Module and documentation by Eric S. Raymond, 21 Dec 1998

-import os, shlex +import os, stat, shlex, pwd all = ["netrc", "NetrcParseError"] @@ -21,6 +21,7 @@ class NetrcParseError(Exception): class netrc: def init(self, file=None):

@@ -77,6 +78,26 @@ class netrc: elif tt == 'account': account = lexer.get_token() elif tt == 'password':

--- a/Lib/test/test_netrc.py +++ b/Lib/test/test_netrc.py @@ -32,7 +32,7 @@ class NetrcTestCase(unittest.TestCase): def tearDown (self): del self.netrc

def test_case_1(self): self.assert_(self.netrc.macros == {'macro1':['line1\n', 'line2\n'], @@ -41,6 +41,27 @@ class NetrcTestCase(unittest.TestCase): self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1')) self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2'))

+ def test_main(): test_support.run_unittest(NetrcTestCase)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -13,6 +13,12 @@ Core and Builtins Library ------- +- Issue #14984: On POSIX systems, when netrc is called without a filename