Use filesystem-supplied modes for checksumming content

The existing code was spuriously failing unit tests, because it was
stripping non-permission bits off the file mode.

On examination, the behaviour was inherited from similar code in
moby/moby, which was intended to affect the resulting filemodes inside
a Linux-based container built from Windows. However, this code path does
have that effect in BuildKit as we are only calculating checksums here.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
v0.8
Paul "TBBle" Hampson 2020-07-28 05:44:38 +10:00
parent 46995ec794
commit 6c824d68f1
4 changed files with 1 additions and 16 deletions

View File

@ -39,5 +39,5 @@ jobs:
- name: Unit test - name: Unit test
env: env:
SKIP_INTEGRATION_TESTS: 1 SKIP_INTEGRATION_TESTS: 1
run: go test -mod=vendor -v ./client/... ./frontend/dockerfile/... ./session/... ./source/... ./util/... run: go test -mod=vendor -v ./cache/... ./client/... ./frontend/dockerfile/... ./session/... ./source/... ./util/...
working-directory: src/github.com/moby/buildkit working-directory: src/github.com/moby/buildkit

View File

@ -49,7 +49,6 @@ func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
return nil, err return nil, err
} }
hdr.Name = "" // note: empty name is different from current has in docker build. Name is added on recursive directory scan instead hdr.Name = "" // note: empty name is different from current has in docker build. Name is added on recursive directory scan instead
hdr.Mode = int64(chmodWindowsTarEntry(os.FileMode(hdr.Mode)))
hdr.Devmajor = stat.Devmajor hdr.Devmajor = stat.Devmajor
hdr.Devminor = stat.Devminor hdr.Devminor = stat.Devminor

View File

@ -12,10 +12,6 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
func chmodWindowsTarEntry(perm os.FileMode) os.FileMode {
return perm
}
func setUnixOpt(path string, fi os.FileInfo, stat *fstypes.Stat) error { func setUnixOpt(path string, fi os.FileInfo, stat *fstypes.Stat) error {
s := fi.Sys().(*syscall.Stat_t) s := fi.Sys().(*syscall.Stat_t)

View File

@ -8,16 +8,6 @@ import (
fstypes "github.com/tonistiigi/fsutil/types" fstypes "github.com/tonistiigi/fsutil/types"
) )
// chmodWindowsTarEntry is used to adjust the file permissions used in tar
// header based on the platform the archival is done.
func chmodWindowsTarEntry(perm os.FileMode) os.FileMode {
perm &= 0755
// Add the x bit: make everything +x from windows
perm |= 0111
return perm
}
func setUnixOpt(path string, fi os.FileInfo, stat *fstypes.Stat) error { func setUnixOpt(path string, fi os.FileInfo, stat *fstypes.Stat) error {
return nil return nil
} }