mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Bug 3228: Explicitly supply the file mode to avoid creating executable files,
and add corresponding tests. Possible 2.5 backport candidate
This commit is contained in:
parent
0879250284
commit
70a6dbd46e
2 changed files with 30 additions and 3 deletions
|
@ -398,7 +398,8 @@ class Maildir(Mailbox):
|
|||
result = Maildir(path, factory=self._factory)
|
||||
maildirfolder_path = os.path.join(path, 'maildirfolder')
|
||||
if not os.path.exists(maildirfolder_path):
|
||||
os.close(os.open(maildirfolder_path, os.O_CREAT | os.O_WRONLY))
|
||||
os.close(os.open(maildirfolder_path, os.O_CREAT | os.O_WRONLY,
|
||||
0666))
|
||||
return result
|
||||
|
||||
def remove_folder(self, folder):
|
||||
|
@ -1900,7 +1901,7 @@ def _unlock_file(f):
|
|||
|
||||
def _create_carefully(path):
|
||||
"""Create a file if it doesn't exist and open for reading and writing."""
|
||||
fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR)
|
||||
fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR, 0666)
|
||||
try:
|
||||
return open(path, 'rb+')
|
||||
finally:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue