10000 [release/1.2 backport] fix: SCHILY.xattrs should be SCHILY.xattr by thaJeztah · Pull Request #2953 · containerd/containerd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[release/1.2 backport] fix: SCHILY.xattrs should be SCHILY.xattr #2953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion archive/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const (
// readdir calls to this directory do not follow to lower layers.
whiteoutOpaqueDir = whiteoutMetaPrefix + ".opq"

paxSchilyXattr = "SCHILY.xattrs."
paxSchilyXattr = "SCHILY.xattr."
)

// Apply applies a tar stream of an OCI style diff tar.
Expand Down
46 changes: 46 additions & 0 deletions archive/tar_test.go
Original file line number Diff line number Diff line change
< EA7D /a> Expand Up @@ -22,6 +22,7 @@ import (
"archive/tar"
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"os"
Expand All @@ -33,6 +34,7 @@ import (
_ "crypto/sha256"

"github.com/containerd/containerd/archive/tartest"
"github.com/containerd/containerd/pkg/testutil"
"github.com/containerd/continuity/fs"
"github.com/containerd/continuity/fs/fstest"
"github.com/pkg/errors"
Expand Down Expand Up @@ -183,6 +185,50 @@ func TestSymlinks(t *testing.T) {
}
}

func TestTarWithXattr(t *testing.T) {
testutil.RequiresRoot(t)

fileXattrExist := func(f1, xattrKey, xattrValue string) func(string) error {
return func(root string) error {
values, err := getxattr(filepath.Join(root, f1), xattrKey)
if err != nil {
return err
}
if xattrValue != string(values) {
return fmt.Errorf("file xattrs expect to be %s, actually get %s", xattrValue, values)
}
return nil
}
}

tests := []struct {
name string
key string
value string
err error
}{
{
name: "WithXattrsUser",
key: "user.key",
value: "value",
},
{
// security related xattrs need root permission to test
name: "WithXattrSelinux",
key: "security.selinux",
value: "unconfined_u:object_r:default_t:s0\x00",
},
}
for _, at := range tests {
tc := tartest.TarContext{}.WithUIDGID(os.Getuid(), os.Getgid()).WithModTime(time.Now().UTC()).WithXattrs(map[string]string{
at.key: at.value,
})
w := tartest.TarAll(tc.File("/file", []byte{}, 0755))
validator := fileXattrExist("file", at.key, at.value)
t.Run(at.name, makeWriterToTarTest(w, nil, validator, at.err))
}
}

func TestBreakouts(t *testing.T) {
tc := tartest.TarContext{}.WithUIDGID(os.Getuid(), os.Getgid()).WithModTime(time.Now().UTC())
expected := "unbroken"
Expand Down
0