Skip to content

Commit

Permalink
Fix WCOW COPY --from failure in multistage builds on Windows
Browse files Browse the repository at this point in the history
Fixes: moby#5193

Signed-off-by: Billy Owire <[email protected]>
  • Loading branch information
Billy Owire committed Sep 2, 2024
1 parent 894bcb3 commit 49d7e7f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cache/contenthash/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"crypto/sha256"
"github.com/Microsoft/go-winio"
"io"
"os"
"path"
Expand Down Expand Up @@ -1034,7 +1035,7 @@ func (cc *cacheContext) scanPath(ctx context.Context, m *mount, p string, follow
scanPath = resolvedPath
}

err = filepath.Walk(scanPath, func(itemPath string, fi os.FileInfo, err error) error {
walkFn := func(itemPath string, fi os.FileInfo, err error) error {
if scanCounterEnable {
scanCounter.Add(1)
}
Expand Down Expand Up @@ -1073,7 +1074,13 @@ func (cc *cacheContext) scanPath(ctx context.Context, m *mount, p string, follow
txn.Insert(k, cr)
}
return nil
}

privileges := []string{winio.SeBackupPrivilege}
err = winio.RunWithPrivileges(privileges, func() error {
return filepath.Walk(scanPath, walkFn)
})

if err != nil {
return err
}
Expand Down

0 comments on commit 49d7e7f

Please sign in to comment.