Skip to content

Commit e5567cc

Browse files
committed
Create ~/.pypirc securely (#13512).
There was a window between the write and the chmod where the user’s password would be exposed, depending on default permissions. Philip Jenvey’s patch fixes it.
1 parent 9e06e37 commit e5567cc

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/distutils/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _get_rc_file(self):
4242
def _store_pypirc(self, username, password):
4343
"""Creates a default .pypirc file."""
4444
rc = self._get_rc_file()
45-
f = open(rc, 'w')
45+
f = os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0600), 'w')
4646
try:
4747
f.write(DEFAULT_PYPIRC % (username, password))
4848
finally:

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ Bill Janssen
412412
Thomas Jarosch
413413
Drew Jenkins
414414
Flemming Kjær Jensen
415+
Philip Jenvey
415416
Jiba
416417
Orjan Johansen
417418
Fredrik Johansson

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Core and Builtins
1414
longer raised due to a read system call returning EINTR from within these
1515
methods.
1616

17+
- Issue #13512: Create ~/.pypirc securely (CVE-2011-4944). Initial patch by
18+
Philip Jenvey, tested by Mageia and Debian.
19+
1720
- Issue #7719: Make distutils ignore ``.nfs*`` files instead of choking later
1821
on. Initial patch by SilentGhost and Jeff Ramnani.
1922

0 commit comments

Comments
 (0)