diff options
author | Jakob Borg <jakob@kastelo.net> | 2022-11-03 11:57:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 11:57:30 +0100 |
commit | bf1e418e4a06c9957bd754d2ebfc4819942b37fc (patch) | |
tree | 87c414286cfc0f6da4d32204073d8c948f5ea7e3 | |
parent | 922946683da4c4d331ee4baa2a60493117d767c6 (diff) | |
download | syncthing-bf1e418e4a06c9957bd754d2ebfc4819942b37fc.tar.gz syncthing-bf1e418e4a06c9957bd754d2ebfc4819942b37fc.zip |
lib/fs: Let xattr test avoid non-test attributes (fixes #8601) (#8628)
SELinux for example adds security.* attributes by default that we are
not allowed to touch, which causes the test to fail.
-rw-r--r-- | lib/fs/basicfs_test.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/fs/basicfs_test.go b/lib/fs/basicfs_test.go index 72a8e8ff2..a7c119255 100644 --- a/lib/fs/basicfs_test.go +++ b/lib/fs/basicfs_test.go @@ -591,12 +591,12 @@ func TestXattr(t *testing.T) { } // Set the xattrs, read them back and compare - if err := tfs.SetXattr("/test", attrs, noopXattrFilter{}); errors.Is(err, ErrXattrsNotSupported) || errors.Is(err, syscall.EOPNOTSUPP) { + if err := tfs.SetXattr("/test", attrs, testXattrFilter{}); errors.Is(err, ErrXattrsNotSupported) || errors.Is(err, syscall.EOPNOTSUPP) { t.Skip("xattrs not supported") } else if err != nil { t.Fatal(err) } - res, err := tfs.GetXattr("/test", noopXattrFilter{}) + res, err := tfs.GetXattr("/test", testXattrFilter{}) if err != nil { t.Fatal(err) } @@ -631,10 +631,10 @@ func TestXattr(t *testing.T) { sort.Slice(attrs, func(i, j int) bool { return attrs[i].Name < attrs[j].Name }) // Set the xattrs, read them back and compare - if err := tfs.SetXattr("/test", attrs, noopXattrFilter{}); err != nil { + if err := tfs.SetXattr("/test", attrs, testXattrFilter{}); err != nil { t.Fatal(err) } - res, err = tfs.GetXattr("/test", noopXattrFilter{}) + res, err = tfs.GetXattr("/test", testXattrFilter{}) if err != nil { t.Fatal(err) } @@ -666,8 +666,10 @@ func TestWalkInfiniteRecursion(t *testing.T) { testWalkInfiniteRecursion(t, FilesystemTypeBasic, dir) } -type noopXattrFilter struct{} +type testXattrFilter struct{} -func (noopXattrFilter) Permit(string) bool { return true } -func (noopXattrFilter) GetMaxSingleEntrySize() int { return 0 } -func (noopXattrFilter) GetMaxTotalSize() int { return 0 } +// Permit only xattrs generated by our test, avoiding issues with SELinux etc. +func (testXattrFilter) Permit(name string) bool { return strings.HasPrefix(name, "user.test-") } + +func (testXattrFilter) GetMaxSingleEntrySize() int { return 0 } +func (testXattrFilter) GetMaxTotalSize() int { return 0 } |