From 4c9bc96fb73987d20cb4df4800497904096ddecf Mon Sep 17 00:00:00 2001 From: Abogical Date: Tue, 21 Feb 2017 20:38:44 +0200 Subject: [PATCH 1/2] Print a warning for too big extended attributes --- src/borg/archive.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index f499f9233..c9b904623 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -621,7 +621,10 @@ Number of files: {0.stats.nfiles}'''.format( try: xattr.setxattr(fd or path, k, v, follow_symlinks=False) except OSError as e: - if e.errno not in (errno.ENOTSUP, errno.EACCES): + if e.errno == errno.E2BIG: + logger.warning('%s: Value or key of extended attribute %s is too big for this filesystem' % + (path, k.decode())) + elif e.errno not in (errno.ENOTSUP, errno.EACCES): # only raise if the errno is not on our ignore list: # ENOTSUP == xattrs not supported here # EACCES == permission denied to set this specific xattr From e487b8404caf2f073fbecff9be509851e11d5b12 Mon Sep 17 00:00:00 2001 From: Abogical Date: Wed, 22 Feb 2017 16:30:22 +0200 Subject: [PATCH 2/2] Add testsuite to test handling of too big xattr --- src/borg/testsuite/archiver.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index cce0c92ff..c62e12200 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -1029,6 +1029,21 @@ class ArchiverTestCase(ArchiverTestCaseBase): self.cmd('extract', self.repository_location + '::test') assert xattr.getxattr('input/file', 'security.capability') == capabilities + @pytest.mark.skipif(not xattr.XATTR_FAKEROOT, reason='xattr not supported on this system or on this version of' + 'fakeroot') + def test_extract_big_xattrs(self): + def patched_setxattr(*args, **kwargs): + raise OSError(errno.E2BIG, 'E2BIG') + self.create_regular_file('file') + xattr.setxattr('input/file', 'attribute', 'value') + self.cmd('init', self.repository_location, '-e' 'none') + self.cmd('create', self.repository_location + '::test', 'input') + with changedir('output'): + with patch.object(xattr, 'setxattr', patched_setxattr): + out = self.cmd('extract', self.repository_location + '::test', exit_code=EXIT_WARNING) + assert out == (os.path.abspath('input/file') + ': Value or key of extended attribute attribute is too big' + 'for this filesystem\n') + def test_path_normalization(self): self.cmd('init', '--encryption=repokey', self.repository_location) self.create_regular_file('dir1/dir2/file', size=1024 * 80)