Rename security into filesystem

This commit is contained in:
Adrien Ferrand
2019-04-18 19:02:51 +02:00
parent 7bf79da076
commit 1d4f0980f8
8 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -40,4 +40,4 @@ del ourselves, std_os, std_sys
def open(*unused_args, **unused_kwargs): # pylint: disable=function-redefined
"""Method os.open() is forbidden"""
raise RuntimeError('Usage of os.open() is forbidden. ' # pragma: no cover
'Use certbot.compat.security.open() instead.')
'Use certbot.compat.filesystem.open() instead.')
+3 -3
View File
@@ -13,7 +13,7 @@ from acme.magic_typing import Optional # pylint: disable=unused-import, no-name
from certbot import errors
from certbot.compat import os
from certbot.compat import security
from certbot.compat import filesystem
logger = logging.getLogger(__name__)
@@ -132,7 +132,7 @@ class _UnixLockMechanism(_BaseLockMechanism):
"""Acquire the lock."""
while self._fd is None:
# Open the file
fd = security.open(self._path, os.O_CREAT | os.O_WRONLY, 0o600)
fd = filesystem.open(self._path, os.O_CREAT | os.O_WRONLY, 0o600)
try:
self._try_lock(fd)
if self._lock_success(fd):
@@ -224,7 +224,7 @@ class _WindowsLockMechanism(_BaseLockMechanism):
"""Acquire the lock"""
open_mode = os.O_RDWR | os.O_CREAT | os.O_TRUNC
fd = security.open(self._path, open_mode, 0o600)
fd = filesystem.open(self._path, open_mode, 0o600)
try:
msvcrt.locking(fd, msvcrt.LK_NBLCK, 1)
except (IOError, OSError) as err:
+2 -2
View File
@@ -6,7 +6,7 @@ from acme.magic_typing import Any, Dict # pylint: disable=unused-import, no-nam
from certbot import errors
from certbot.compat import os
from certbot.compat import security
from certbot.compat import filesystem
logger = logging.getLogger(__name__)
@@ -86,7 +86,7 @@ class PluginStorage(object):
logger.error(errmsg)
raise errors.PluginStorageError(errmsg)
try:
with os.fdopen(security.open(
with os.fdopen(filesystem.open(
self._storagepath,
os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
0o600), 'w') as fh:
+1 -1
View File
@@ -72,7 +72,7 @@ class PluginStorageTest(test_util.ConfigTestCase):
def test_save_errors_unable_to_write_file(self):
mock_open = mock.mock_open()
mock_open.side_effect = IOError
with mock.patch("certbot.compat.security.open", mock_open):
with mock.patch("certbot.compat.filesystem.open", mock_open):
with mock.patch("certbot.plugins.storage.logger.error") as mock_log:
self.plugin.storage._data = {"valid": "data"} # pylint: disable=protected-access
self.plugin.storage._initialized = True # pylint: disable=protected-access
+2 -2
View File
@@ -7,7 +7,7 @@ from acme.magic_typing import List # pylint: disable=unused-import, no-name-in-
from certbot import errors
from certbot.compat import os
from certbot.compat import security
from certbot.compat import filesystem
from certbot.tests import util
@@ -42,7 +42,7 @@ class ValidateHookTest(util.TempDirTestCase):
def test_not_executable(self):
file_path = os.path.join(self.tempdir, "foo")
# create a non-executable file
os.close(security.open(file_path, os.O_CREAT | os.O_WRONLY, 0o666))
os.close(filesystem.open(file_path, os.O_CREAT | os.O_WRONLY, 0o666))
# prevent unnecessary modifications to PATH
with mock.patch("certbot.hooks.plug_util.path_surgery"):
self.assertRaises(errors.HookCommandNotFound,
+1 -1
View File
@@ -285,7 +285,7 @@ class UniqueLineageNameTest(test_util.TempDirTestCase):
f.close()
def test_failure(self):
with mock.patch("certbot.compat.security.open", side_effect=OSError(errno.EIO)):
with mock.patch("certbot.compat.filesystem.open", side_effect=OSError(errno.EIO)):
self.assertRaises(OSError, self._call, "wow")
+2 -2
View File
@@ -23,7 +23,7 @@ from certbot import errors
from certbot import lock
from certbot.compat import misc
from certbot.compat import os
from certbot.compat import security
from certbot.compat import filesystem
logger = logging.getLogger(__name__)
@@ -220,7 +220,7 @@ def safe_open(path, mode="w", chmod=None):
if chmod is not None:
open_args = (chmod,)
fdopen_args = () # type: Union[Tuple[()], Tuple[int]]
fd = security.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR, *open_args)
fd = filesystem.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR, *open_args)
return os.fdopen(fd, mode, *fdopen_args)