Skip to content

Commit 8e12e11

Browse files
Merge pull request #6429 from nalind/ignore-user-overlay
copier: ignore user.overlay.* xattrs
2 parents a1783a8 + 4caee77 commit 8e12e11

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

copier/xattrs.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const (
2121

2222
var (
2323
relevantAttributes = []string{"security.capability", imaXattr, "user.*"} // the attributes that we preserve - we discard others
24+
irrelevantAttributes = []string{"user.overlay.*"} // the attributes that we discard, even from the relevantAttributes list
2425
initialXattrListSize = 64 * 1024
2526
initialXattrValueSize = 64 * 1024
2627
)
@@ -33,6 +34,13 @@ func isRelevantXattr(attribute string) bool {
3334
if err != nil || !matched {
3435
continue
3536
}
37+
for _, irrelevant := range irrelevantAttributes {
38+
matched, err := filepath.Match(irrelevant, attribute)
39+
if err != nil || !matched {
40+
continue
41+
}
42+
return false
43+
}
3644
return true
3745
}
3846
return false

copier/xattrs_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"testing"
1111

1212
"github.com/stretchr/testify/assert"
13+
"github.com/stretchr/testify/require"
1314
)
1415

1516
func init() {
@@ -18,6 +19,30 @@ func init() {
1819
initialXattrValueSize = 1
1920
}
2021

22+
func TestXattrIsRelevant(t *testing.T) {
23+
cases := []struct {
24+
xattrName string
25+
relevant bool
26+
}{
27+
{"user.a", true},
28+
{"user.b", true},
29+
{"security.foo", false},
30+
{imaXattr, true},
31+
{"security.capability", true},
32+
{"user.overlay.base", false},
33+
}
34+
for _, c := range cases {
35+
t.Run(c.xattrName, func(t *testing.T) {
36+
relevant := isRelevantXattr(c.xattrName)
37+
if c.relevant {
38+
require.True(t, relevant, "should be considered relevant and kept")
39+
} else {
40+
require.False(t, relevant, "should be considered irrelevant and discarded")
41+
}
42+
})
43+
}
44+
}
45+
2146
func TestXattrs(t *testing.T) {
2247
t.Parallel()
2348
if !xattrsSupported {

0 commit comments

Comments
 (0)