xattrs: linux does not allow user.* xattrs on symlinks

This commit is contained in:
Thomas Waldmann 2018-11-14 01:42:25 +01:00
parent 53971e8e79
commit 3d05a4b114
1 changed files with 8 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import pytest
from ..platform.xattr import buffer, split_lstring
from ..xattr import is_enabled, getxattr, setxattr, listxattr
from ..platformflags import is_linux
from . import BaseTestCase
@ -36,15 +37,19 @@ class XattrTestCase(BaseTestCase):
setxattr(tmp_fn, b'user.foo', b'bar')
setxattr(tmp_fd, b'user.bar', b'foo')
setxattr(tmp_fn, b'user.empty', b'')
setxattr(tmp_lfn, b'user.linkxattr', b'baz')
if not is_linux:
# linux does not allow setting user.* xattrs on symlinks
setxattr(tmp_lfn, b'user.linkxattr', b'baz')
self.assert_equal_se(listxattr(tmp_fn), [b'user.foo', b'user.bar', b'user.empty'])
self.assert_equal_se(listxattr(tmp_fd), [b'user.foo', b'user.bar', b'user.empty'])
self.assert_equal_se(listxattr(tmp_lfn, follow_symlinks=True), [b'user.foo', b'user.bar', b'user.empty'])
self.assert_equal_se(listxattr(tmp_lfn), [b'user.linkxattr'])
if not is_linux:
self.assert_equal_se(listxattr(tmp_lfn), [b'user.linkxattr'])
self.assert_equal(getxattr(tmp_fn, b'user.foo'), b'bar')
self.assert_equal(getxattr(tmp_fd, b'user.foo'), b'bar')
self.assert_equal(getxattr(tmp_lfn, b'user.foo', follow_symlinks=True), b'bar')
self.assert_equal(getxattr(tmp_lfn, b'user.linkxattr'), b'baz')
if not is_linux:
self.assert_equal(getxattr(tmp_lfn, b'user.linkxattr'), b'baz')
self.assert_equal(getxattr(tmp_fn, b'user.empty'), b'')
def test_listxattr_buffer_growth(self):