Skip to content

Commit

Permalink
builder/dockerfile: ADD with best-effort xattrs
Browse files Browse the repository at this point in the history
Archives being unpacked by Dockerfiles may have been created on other
OSes with different conventions and semantics for xattrs, making them
impossible to apply when extracting. Restore the old best-effort xattr
behaviour users have come to depend on in the classic builder.

The (archive.Archiver).UntarPath function does not allow the options
passed to Untar to be customized. It also happens to be a trivial
wrapper around the Untar function. Inline the function body and add the
option.

Signed-off-by: Cory Snider <csnider@mirantis.com>
  • Loading branch information
corhere committed Feb 12, 2024
1 parent a60546b commit 5bcd2f6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion builder/dockerfile/copy.go
Expand Up @@ -459,7 +459,16 @@ func performCopyForInfo(dest copyInfo, source copyInfo, options copyFileOptions)
return copyDirectory(archiver, srcPath, destPath, options.identity)
}
if options.decompress && archive.IsArchivePath(srcPath) && !source.noDecompress {
return archiver.UntarPath(srcPath, destPath)
f, err := os.Open(srcPath)
if err != nil {
return err
}
defer f.Close()
options := &archive.TarOptions{
IDMap: archiver.IDMapping,
BestEffortXattrs: true,
}
return archiver.Untar(f, destPath, options)
}

destExistsAsDir, err := isExistingDirectory(destPath)
Expand Down

0 comments on commit 5bcd2f6

Please sign in to comment.