Skip to content

Commit

Permalink
Merge pull request #125 from AkihiroSuda/dev
Browse files Browse the repository at this point in the history
Skip setting xattrs when running as non-root
  • Loading branch information
AkihiroSuda authored Aug 16, 2024
2 parents 8163257 + 692e442 commit 2b45a09
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"slices"
"sort"
"strconv"
Expand Down Expand Up @@ -700,6 +701,21 @@ func (d *differ) loadLayer(ctx context.Context, node *EventTreeNode, inputIdx in
hdr.Name = strings.TrimPrefix(hdr.Name, "/")
hdr.Name = strings.TrimPrefix(hdr.Name, "./")
}
if os.Geteuid() != 0 && runtime.GOOS == "linux" {
//nolint:staticcheck // SA1019: hdr.Xattrs has been deprecated since Go 1.10: Use PAXRecords instead.
for k := range hdr.Xattrs {
if strings.HasPrefix(k, "security.") {
log.G(ctx).Debugf("Ignoring xattr %q", k)
delete(hdr.Xattrs, k)
}
}
for k := range hdr.PAXRecords {
if strings.HasPrefix(k, "SCHILY.xattr.security.") {
log.G(ctx).Debugf("Ignoring PAX record %q", k)
delete(hdr.PAXRecords, k)
}
}
}
res.entries++
ent := &TarEntry{
Index: i,
Expand Down

0 comments on commit 2b45a09

Please sign in to comment.