Treat unix sockets as regular files
This fix is similar to the fix in #1144; but was hit in a different code path. Signed-off-by: Alex Couture-Beil <alex@earthly.dev>v0.8
parent
4d1f260e84
commit
5382a2056e
|
@ -40,6 +40,9 @@ func NewFileHash(path string, fi os.FileInfo) (hash.Hash, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
|
func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
|
||||||
|
// Clear the socket bit since archive/tar.FileInfoHeader does not handle it
|
||||||
|
stat.Mode &^= uint32(os.ModeSocket)
|
||||||
|
|
||||||
fi := &statInfo{stat}
|
fi := &statInfo{stat}
|
||||||
hdr, err := tar.FileInfoHeader(fi, stat.Linkname)
|
hdr, err := tar.FileInfoHeader(fi, stat.Linkname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -113,6 +113,7 @@ func TestIntegration(t *testing.T) {
|
||||||
testCacheMountNoCache,
|
testCacheMountNoCache,
|
||||||
testExporterTargetExists,
|
testExporterTargetExists,
|
||||||
testTarExporterWithSocket,
|
testTarExporterWithSocket,
|
||||||
|
testTarExporterWithSocketCopy,
|
||||||
testTarExporterSymlink,
|
testTarExporterSymlink,
|
||||||
testMultipleRegistryCacheImportExport,
|
testMultipleRegistryCacheImportExport,
|
||||||
testSourceMap,
|
testSourceMap,
|
||||||
|
@ -1653,6 +1654,30 @@ func testTarExporterWithSocket(t *testing.T, sb integration.Sandbox) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testTarExporterWithSocketCopy(t *testing.T, sb integration.Sandbox) {
|
||||||
|
if os.Getenv("TEST_DOCKERD") == "1" {
|
||||||
|
t.Skip("tar exporter is temporarily broken on dockerd")
|
||||||
|
}
|
||||||
|
|
||||||
|
requiresLinux(t)
|
||||||
|
c, err := New(context.TODO(), sb.Address())
|
||||||
|
require.NoError(t, err)
|
||||||
|
defer c.Close()
|
||||||
|
|
||||||
|
alpine := llb.Image("docker.io/library/alpine:latest")
|
||||||
|
state := alpine.Run(llb.Args([]string{"sh", "-c", "nc -l -s local:/root/socket.sock & usleep 100000; kill %1"})).Root()
|
||||||
|
|
||||||
|
fa := llb.Copy(state, "/root", "/roo2", &llb.CopyInfo{})
|
||||||
|
|
||||||
|
scratchCopy := llb.Scratch().File(fa)
|
||||||
|
|
||||||
|
def, err := scratchCopy.Marshal(context.TODO())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
_, err = c.Solve(context.TODO(), def, SolveOpt{}, nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
// moby/buildkit#1418
|
// moby/buildkit#1418
|
||||||
func testTarExporterSymlink(t *testing.T, sb integration.Sandbox) {
|
func testTarExporterSymlink(t *testing.T, sb integration.Sandbox) {
|
||||||
requiresLinux(t)
|
requiresLinux(t)
|
||||||
|
|
Loading…
Reference in New Issue