mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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.
This commit is contained in:
parent
9e06e37be0
commit
e5567ccc86
3 changed files with 5 additions and 1 deletions
|
@ -42,7 +42,7 @@ class PyPIRCCommand(Command):
|
|||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue