From d7565fc515131d0c059217f6a6858f05fc77cd8c Mon Sep 17 00:00:00 2001 From: shreyamalviya Date: Tue, 15 Jun 2021 12:20:48 +0530 Subject: [PATCH] island: Use stat.S_IRWXU in place of 0o700 in cc/environment/utils.py --- monkey/monkey_island/cc/environment/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/environment/utils.py b/monkey/monkey_island/cc/environment/utils.py index a9b312092..94943106a 100644 --- a/monkey/monkey_island/cc/environment/utils.py +++ b/monkey/monkey_island/cc/environment/utils.py @@ -1,6 +1,7 @@ import logging import os import platform +import stat def is_windows_os() -> bool: @@ -29,7 +30,7 @@ def _create_secure_directory_linux(path: str): try: # Don't split directory creation and permission setting # because it will temporarily create an accessible directory which anyone can use. - os.mkdir(path, mode=0o700) + os.mkdir(path, mode=stat.S_IRWXU) except Exception as ex: LOG.error(f'Could not create a directory at "{path}": {str(ex)}') @@ -62,7 +63,7 @@ def _create_secure_file_linux(path: str): flags = ( os.O_RDWR | os.O_CREAT | os.O_EXCL ) # read/write, create new, throw error if file exists - mode = 0o700 # read/write/execute permissions to owner + mode = stat.S_IRWXU # read/write/execute permissions to owner os.close(os.open(path, flags, mode)) except Exception as ex: