Skip to content

Commit 2692fa1

Browse files
skip "do not retry when permissions denied" test if running as root
we can not take away read permissions for root, so the test would fail.
1 parent 0fa44e4 commit 2692fa1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/borg/testsuite/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from ..xattr import get_all
2020
from ..platform import get_flags
21+
from ..platformflags import is_win32
2122
from ..helpers import umount
2223
from ..helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
2324
from .. import platform
@@ -66,6 +67,14 @@ def unopened_tempfile():
6667
yield os.path.join(tempdir, "file")
6768

6869

70+
def is_root():
71+
"""return True if running with high privileges, like as root"""
72+
if is_win32:
73+
return False # TODO
74+
else:
75+
return os.getuid() == 0
76+
77+
6978
@functools.lru_cache
7079
def are_symlinks_supported():
7180
with unopened_tempfile() as filepath:

src/borg/testsuite/archiver/create_cmd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
is_utime_fully_supported,
2626
is_birthtime_fully_supported,
2727
same_ts_ns,
28+
is_root,
2829
)
2930
from . import (
3031
ArchiverTestCaseBase,
@@ -219,6 +220,7 @@ def test_create_erroneous_file(self):
219220
assert "input/file2" in out
220221
assert "input/file3" in out
221222

223+
@pytest.mark.skipif(is_root(), reason="test must not be run as (fake)root")
222224
def test_create_no_permission_file(self):
223225
file_path = os.path.join(self.input_path, "file")
224226
self.create_regular_file(file_path + "1", size=1000)
@@ -228,6 +230,7 @@ def test_create_no_permission_file(self):
228230
if is_win32:
229231
subprocess.run(["icacls.exe", file_path + "2", "/deny", "everyone:(R)"])
230232
else:
233+
# note: this will NOT take away read permissions for root
231234
os.chmod(file_path + "2", 0o000)
232235
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
233236
flist = "".join(f"input/file{n}\n" for n in range(1, 4))

0 commit comments

Comments
 (0)