Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/borg/testsuite/platform/freebsd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import tempfile

from ...platform import acl_get, acl_set
from .platform_test import skipif_not_freebsd, skipif_acls_not_working
from .platform_test import skipif_not_freebsd, skipif_fakeroot_detected, skipif_acls_not_working

# set module-level skips
pytestmark = [skipif_not_freebsd]
pytestmark = [skipif_not_freebsd, skipif_fakeroot_detected]


ACCESS_ACL = """\
Expand Down
10 changes: 9 additions & 1 deletion src/borg/testsuite/xattr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from ..platform.xattr import buffer, split_lstring
from ..xattr import is_enabled, getxattr, setxattr, listxattr
from ..xattr import is_enabled, getxattr, setxattr, listxattr, XATTR_FAKEROOT
from ..platformflags import is_linux


Expand Down Expand Up @@ -82,3 +82,11 @@ def test_getxattr_buffer_growth(tempfile_symlink):
)
def test_split_lstring(lstring, expected):
assert split_lstring(lstring) == expected


def test_xattr_fakeroot_flag():
"""XATTR_FAKEROOT must be False when not on Linux or when fakeroot is not active."""
if not is_linux:
assert XATTR_FAKEROOT is False
if "FAKEROOTKEY" not in os.environ:
assert XATTR_FAKEROOT is False
5 changes: 3 additions & 2 deletions src/borg/xattr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

# If we are running with fakeroot on Linux, then use the xattr functions of fakeroot. This is needed by
# the 'test_extract_capabilities' test, but also allows xattrs to work with fakeroot on Linux in normal use.
# TODO: Check whether fakeroot supports xattrs on all platforms supported below.
# TODO: If that's the case then we can make Borg fakeroot-xattr-compatible on these as well.
# Note: fakeroot xattr support is Linux-only. fakeroot only wraps the Linux-style setxattr/getxattr API,
# but FreeBSD/NetBSD use the extattr_* API instead, so fakeroot never intercepts xattr calls there.
# On macOS, fakeroot explicitly disables xattr wrapping due to prototype incompatibilities.
XATTR_FAKEROOT = False
if sys.platform.startswith("linux"):
LD_PRELOAD = os.environ.get("LD_PRELOAD", "")
Expand Down