Update tar to use PAXRecords instead of Xattrs
@@ -82,6 +82,8 @@ const (
// whiteoutOpaqueDir file means directory has been made opaque - meaning
// readdir calls to this directory do not follow to lower layers.
whiteoutOpaqueDir = whiteoutMetaPrefix + ".opq"
+
+ paxSchilyXattr = "SCHILY.xattrs."
)
// Apply applies a tar stream of an OCI style diff tar.
@@ -388,9 +390,10 @@ func (cw *changeWriter) HandleChange(k fs.ChangeKind, p string, f os.FileInfo, e
if capability, err := getxattr(source, "security.capability"); err != nil {
return errors.Wrap(err, "failed to get capabilities xattr")
} else if capability != nil {
- hdr.Xattrs = map[string]string{
- "security.capability": string(capability),
+ if hdr.PAXRecords == nil {
+ hdr.PAXRecords = map[string]string{}
}
+ hdr.PAXRecords[paxSchilyXattr+"security.capability"] = string(capability)
}
if err := cw.tw.WriteHeader(hdr); err != nil {
@@ -509,7 +512,9 @@ func createTarFile(ctx context.Context, path, extractDir string, hdr *tar.Header
}
}
- for key, value := range hdr.Xattrs {
+ for key, value := range hdr.PAXRecords {
+ if strings.HasPrefix(key, paxSchilyXattr) {
+ key = key[len(paxSchilyXattr):]
if err := setxattr(path, key, value); err != nil {
if errors.Cause(err) == syscall.ENOTSUP {
log.G(ctx).WithError(err).Warnf("ignored xattr %s in archive", key)
@@ -518,6 +523,7 @@ func createTarFile(ctx context.Context, path, extractDir string, hdr *tar.Header
return err
}
}
+ }
// There is no LChmod, so ignore mode for symlink. Also, this
// must happen after chown, as that can modify the file mode
