1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #18947 -- Don't make uploaded files executeable by default.

Thanks to Lauri Tirkkonen for the patch.
This commit is contained in:
Florian Apolloner
2012-09-05 18:05:28 +03:00
parent c2c8d4044e
commit e8c6aff3bf
3 changed files with 22 additions and 5 deletions

View File

@@ -192,7 +192,10 @@ class FileSystemStorage(Storage):
else:
# This fun binary flag incantation makes os.open throw an
# OSError if the file already exists before we open it.
fd = os.open(full_path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, 'O_BINARY', 0))
flags = (os.O_WRONLY | os.O_CREAT | os.O_EXCL |
getattr(os, 'O_BINARY', 0))
# The current umask value is masked out by os.open!
fd = os.open(full_path, flags, 0o666)
try:
locks.lock(fd, locks.LOCK_EX)
_file = None