Merge pull request #4357 from ThomasWaldmann/xattr-tests

re-add the code that checks if we run under fakeroot, fixes #4291
This commit is contained in:
TW 2019-02-12 14:37:39 +01:00 committed by GitHub
commit de55d763a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,15 +2,41 @@
import errno
import os
import re
import subprocess
import sys
import tempfile
from distutils.version import LooseVersion
from .helpers import prepare_subprocess_env
from .logger import create_logger
logger = create_logger()
from .platform import listxattr, getxattr, setxattr, ENOATTR
XATTR_FAKEROOT = True # fakeroot with xattr support required (>= 1.20.2?)
# 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.
XATTR_FAKEROOT = False
if sys.platform.startswith('linux'):
LD_PRELOAD = os.environ.get('LD_PRELOAD', '')
preloads = re.split("[ :]", LD_PRELOAD)
for preload in preloads:
if preload.startswith("libfakeroot"):
env = prepare_subprocess_env(system=True)
fakeroot_output = subprocess.check_output(['fakeroot', '-v'], env=env)
fakeroot_version = LooseVersion(fakeroot_output.decode('ascii').split()[-1])
if fakeroot_version >= LooseVersion("1.20.2"):
# 1.20.2 has been confirmed to have xattr support
# 1.18.2 has been confirmed not to have xattr support
# Versions in-between are unknown
libc_name = preload
XATTR_FAKEROOT = True
break
def is_enabled(path=None):