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: #5193

Signed-off-by: Billy Owire <billyowire@microsoft.com>
  • Loading branch information
Billy Owire committed Sep 3, 2024
1 parent b60d621 commit b77425f
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 b77425f

Please sign in to comment.