mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-10 09:21:44 -04:00
Merge pull request #7482 from ThomasWaldmann/fix-retry-test
skip "do not retry when permissions denied" test if running as root
This commit is contained in:
commit
80c08abe45
2 changed files with 12 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ import unittest
|
|||
|
||||
from ..xattr import get_all
|
||||
from ..platform import get_flags
|
||||
from ..platformflags import is_win32
|
||||
from ..helpers import umount
|
||||
from ..helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
|
||||
from .. import platform
|
||||
|
|
@ -66,6 +67,14 @@ def unopened_tempfile():
|
|||
yield os.path.join(tempdir, "file")
|
||||
|
||||
|
||||
def is_root():
|
||||
"""return True if running with high privileges, like as root"""
|
||||
if is_win32:
|
||||
return False # TODO
|
||||
else:
|
||||
return os.getuid() == 0
|
||||
|
||||
|
||||
@functools.lru_cache
|
||||
def are_symlinks_supported():
|
||||
with unopened_tempfile() as filepath:
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ from .. import (
|
|||
is_utime_fully_supported,
|
||||
is_birthtime_fully_supported,
|
||||
same_ts_ns,
|
||||
is_root,
|
||||
)
|
||||
from . import (
|
||||
ArchiverTestCaseBase,
|
||||
|
|
@ -219,6 +220,7 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|||
assert "input/file2" in out
|
||||
assert "input/file3" in out
|
||||
|
||||
@pytest.mark.skipif(is_root(), reason="test must not be run as (fake)root")
|
||||
def test_create_no_permission_file(self):
|
||||
file_path = os.path.join(self.input_path, "file")
|
||||
self.create_regular_file(file_path + "1", size=1000)
|
||||
|
|
@ -228,6 +230,7 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|||
if is_win32:
|
||||
subprocess.run(["icacls.exe", file_path + "2", "/deny", "everyone:(R)"])
|
||||
else:
|
||||
# note: this will NOT take away read permissions for root
|
||||
os.chmod(file_path + "2", 0o000)
|
||||
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
||||
flist = "".join(f"input/file{n}\n" for n in range(1, 4))
|
||||
|
|
|
|||
Loading…
Reference in a new issue