diff --git a/pkg/lib/storage/layer.go b/pkg/lib/storage/layer.go index cd1ad02b..0cfc1ee7 100644 --- a/pkg/lib/storage/layer.go +++ b/pkg/lib/storage/layer.go @@ -165,9 +165,7 @@ func writeHeaderToTar(name string, fi os.FileInfo, tw *tar.Writer) error { return fmt.Errorf("failed to generate header for %s: %w", name, err) } header.Name = name - header.AccessTime = time.Time{} - header.ModTime = time.Time{} - header.ChangeTime = time.Time{} + sanitizeTarHeader(header) if err := tw.WriteHeader(header); err != nil { return fmt.Errorf("failed to write header: %w", err) } @@ -204,3 +202,13 @@ func removeTempFile(filepath string) { output.Errorf("Failed to clean up temporary file %s: %s", filepath, err) } } + +func sanitizeTarHeader(header *tar.Header) { + header.AccessTime = time.Time{} + header.ModTime = time.Time{} + header.ChangeTime = time.Time{} + header.Uid = 0 + header.Gid = 0 + header.Uname = "" + header.Gname = "" +}