From 0e9d10bff5c4c3a438a197b2646cce4fe06b21e3 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 26 Feb 2018 18:46:35 +0530 Subject: [PATCH] searx: Set file permissions while creating file To avoid race conditions. Signed-off-by: Sunil Mohan Adapa --- plinth/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plinth/utils.py b/plinth/utils.py index cc68178f7..ba4cb7994 100644 --- a/plinth/utils.py +++ b/plinth/utils.py @@ -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)