searx: Set file permissions while creating file

To avoid race conditions.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2018-02-26 18:46:35 +05:30
parent 7e60db76c4
commit 0e9d10bff5
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -152,6 +152,9 @@ def gunzip(gzip_file, output_file):
with gzip.open(gzip_file, 'rb') as file_handle:
contents = file_handle.read()
with open(output_file, 'wb') as file_handle:
def opener(path, flags):
return os.open(path, flags, mode=0o644)
with open(output_file, 'wb', opener=opener) as file_handle:
file_handle.write(contents)
os.chmod(output_file, 0o644)