diff --git a/src/globaleaks_eph_fs/__init__.py b/src/globaleaks_eph_fs/__init__.py index fea3e1c..ee44fe9 100644 --- a/src/globaleaks_eph_fs/__init__.py +++ b/src/globaleaks_eph_fs/__init__.py @@ -46,6 +46,7 @@ def open(self, flags, mode=0o660): """ with self.mutex: self.fd = os.open(self.filepath, os.O_RDWR | os.O_CREAT | os.O_APPEND, mode) + os.chmod(self.filepath, mode) return self def write(self, data): diff --git a/tests/test.py b/tests/test.py index 880e881..11358c2 100644 --- a/tests/test.py +++ b/tests/test.py @@ -167,20 +167,15 @@ def test_readdir(self): @patch("os.chmod") def test_chmod_success(self, mock_chmod): self.fs.create(TEST_PATH, 0o660) - self.fs.chmod(TEST_PATH, 0o644) - mock_chmod.assert_called_once_with(self.fs.files[TEST_PATH].filepath, 0o644) + mock_chmod.assert_called_with(self.fs.files[TEST_PATH].filepath, 0o660) + self.fs.chmod(TEST_PATH, 0o640) + mock_chmod.assert_called_with(self.fs.files[TEST_PATH].filepath, 0o640) def test_chmod_file_not_found(self): with self.assertRaises(FuseOSError) as context: self.fs.chmod("/nonexistent", 0o644) self.assertEqual(context.exception.errno, errno.ENOENT) - @patch("os.chmod", side_effect=PermissionError) - def test_chmod_permission_error(self, mock_chmod): - self.fs.create(TEST_PATH, 0o660) - with self.assertRaises(PermissionError): - self.fs.chmod(TEST_PATH, 0o644) - @patch("os.chown") def test_chown_success(self, mock_chown): self.fs.create(TEST_PATH, 0o660)