[Python-checkins] cpython (2.7): Create ~/.pypirc securely (#13512).
eric.araujo
python-checkins at python.org
Tue Jul 3 07:23:54 CEST 2012
http://hg.python.org/cpython/rev/f833e7ec4de1
changeset: 77927:f833e7ec4de1
branch: 2.7
user: Éric Araujo <merwok at netwok.org>
date: Tue Jul 03 01:23:46 2012 -0400
summary:
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.
files:
Lib/distutils/config.py | 2 +-
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
3 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py
--- a/Lib/distutils/config.py
+++ b/Lib/distutils/config.py
@@ -42,7 +42,7 @@
def _store_pypirc(self, username, password):
"""Creates a default .pypirc file."""
rc = self._get_rc_file()
- f = open(rc, 'w')
+ f = os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0600), 'w')
try:
f.write(DEFAULT_PYPIRC % (username, password))
finally:
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -412,6 +412,7 @@
Thomas Jarosch
Drew Jenkins
Flemming Kjær Jensen
+Philip Jenvey
Jiba
Orjan Johansen
Fredrik Johansson
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,6 +14,9 @@
longer raised due to a read system call returning EINTR from within these
methods.
+- Issue #13512: Create ~/.pypirc securely (CVE-2011-4944). Initial patch by
+ Philip Jenvey, tested by Mageia and Debian.
+
- Issue #7719: Make distutils ignore ``.nfs*`` files instead of choking later
on. Initial patch by SilentGhost and Jeff Ramnani.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list