diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-11-07 07:29:36 -0800 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-11-07 07:29:36 -0800 |
commit | 112fdf7824dd9222ee9e274529c367acba5b9983 (patch) | |
tree | d133a56ed2f3e1f0acd535a56bc01151ae7d05e2 | |
parent | 28f647b85716911d2b96c547cd2ac2035c00b192 (diff) | |
download | python-112fdf7824dd9222ee9e274529c367acba5b9983.tar.gz python-112fdf7824dd9222ee9e274529c367acba5b9983.tar.bz2 python-112fdf7824dd9222ee9e274529c367acba5b9983.zip |
pypirc-secure.diff
# HG changeset patch
# User Philip Jenvey <pjenvey@underboss.org>
# Date 1322701507 28800
# Branch 2.7
# Node ID e7c20a8476a0e2ca18f8040864cbc400818d8f24
# Parent 3ecddf168f1f554a17a047384fe0b02f2d688277
create the .pypirc securely
-rw-r--r-- | Lib/distutils/config.py | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py index afa403f..645c223 100644 --- a/Lib/distutils/config.py +++ b/Lib/distutils/config.py @@ -42,16 +42,8 @@ class PyPIRCCommand(Command): 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, 0600) - except OSError: - # should do something better here - pass + with os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0600), 'w') as fp: + fp.write(DEFAULT_PYPIRC % (username, password)) def _read_pypirc(self): """Reads the .pypirc file.""" |