File python-3.2.3rc2-pypirc-secure.patch of Package python3
# HG changeset patch
# User Philip Jenvey <pjenvey@underboss.org>
# Date 1322701507 28800
# Branch 2.7
# Node ID e7c20a8476a0e2ca18f8040864cbc400818d8f24
# Parent 3ecddf168f1f554a17a047384fe0b02f2d688277
create the .pypirc securely
Index: Python-3.2.3rc2/Lib/distutils/config.py
===================================================================
--- Python-3.2.3rc2.orig/Lib/distutils/config.py 2012-03-18 07:36:03.000000000 +0100
+++ Python-3.2.3rc2/Lib/distutils/config.py 2012-03-29 16:39:59.000000000 +0200
@@ -43,16 +43,8 @@
def _store_pypirc(self, username, password):
"""Creates a default .pypirc file."""
rc = self._get_rc_file()
- f = open(rc, 'w')
- try:
- f.write(DEFAULT_PYPIRC % (username, password))
- finally:
- f.close()
- try:
- os.chmod(rc, 0o600)
- except OSError:
- # should do something better here
- pass
+ with os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as fp:
+ fp.write(DEFAULT_PYPIRC % (username, password))
def _read_pypirc(self):
"""Reads the .pypirc file."""