diff --git a/src/borg/testsuite/platform/freebsd_test.py b/src/borg/testsuite/platform/freebsd_test.py index 8d313fd6e0..11a059daef 100644 --- a/src/borg/testsuite/platform/freebsd_test.py +++ b/src/borg/testsuite/platform/freebsd_test.py @@ -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 = """\ diff --git a/src/borg/testsuite/xattr_test.py b/src/borg/testsuite/xattr_test.py index d809aed7a9..f99aa961c2 100644 --- a/src/borg/testsuite/xattr_test.py +++ b/src/borg/testsuite/xattr_test.py @@ -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 @@ -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 diff --git a/src/borg/xattr.py b/src/borg/xattr.py index 18ac6abf38..776a946774 100644 --- a/src/borg/xattr.py +++ b/src/borg/xattr.py @@ -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", "")