From 5fe0c80377c709c6e6a3c9ec87729f7026bc0a0e Mon Sep 17 00:00:00 2001 From: Shreya Date: Mon, 14 Jun 2021 17:07:30 +0530 Subject: [PATCH] island: Can't use `with` with `os.open()`, use `os.close()` to close file descriptor --- monkey/monkey_island/cc/environment/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/environment/utils.py b/monkey/monkey_island/cc/environment/utils.py index 0a84e6aac..1fb998a5f 100644 --- a/monkey/monkey_island/cc/environment/utils.py +++ b/monkey/monkey_island/cc/environment/utils.py @@ -62,9 +62,7 @@ def _create_secure_file_linux(path: str): 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 - - with os.open(path, flags, mode) as x: # noqa: F841 - pass + os.close(os.open(path, flags, mode)) except Exception as ex: LOG.error(f'Could not create a file at "{path}": {str(ex)}')