make xattr EPERM non-fatal in createTarFile
Signed-off-by: Ye Sijun <junnplus@gmail.com>
This commit is contained in:
parent
a43dfdf4c0
commit
68a55fe8bd
@ -120,6 +120,8 @@ const (
|
||||
whiteoutOpaqueDir = whiteoutMetaPrefix + ".opq"
|
||||
|
||||
paxSchilyXattr = "SCHILY.xattr."
|
||||
|
||||
userXattrPrefix = "user."
|
||||
)
|
||||
|
||||
// Apply applies a tar stream of an OCI style diff tar.
|
||||
@ -393,11 +395,19 @@ func createTarFile(ctx context.Context, path, extractDir string, hdr *tar.Header
|
||||
if strings.HasPrefix(key, paxSchilyXattr) {
|
||||
key = key[len(paxSchilyXattr):]
|
||||
if err := setxattr(path, key, value); err != nil {
|
||||
if errors.Is(err, syscall.EPERM) && strings.HasPrefix(key, userXattrPrefix) {
|
||||
// In the user.* namespace, only regular files and directories can have extended attributes.
|
||||
// See https://man7.org/linux/man-pages/man7/xattr.7.html for details.
|
||||
if fi, err := os.Lstat(path); err == nil && (!fi.Mode().IsRegular() && !fi.Mode().IsDir()) {
|
||||
log.G(ctx).WithError(err).Warnf("ignored xattr %s in archive", key)
|
||||
continue
|
||||
}
|
||||
}
|
||||
if errors.Is(err, syscall.ENOTSUP) {
|
||||
log.G(ctx).WithError(err).Warnf("ignored xattr %s in archive", key)
|
||||
continue
|
||||
}
|
||||
return err
|
||||
return fmt.Errorf("failed to setxattr %q for key %q: %w", path, key, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user