From 7634f0755c98f25228e3904ed760089c3b199c5d Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 9 Oct 2024 14:32:21 -0700 Subject: [PATCH] os: handle umask comparing execute mode in verifyCopyFS Fixes #69788 Change-Id: I43cc4c0dc3c8aa2474cba26c84714d00828de08e Reviewed-on: https://go-review.googlesource.com/c/go/+/619176 Auto-Submit: Ian Lance Taylor Reviewed-by: Michael Pratt Reviewed-by: Ian Lance Taylor TryBot-Bypass: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- src/os/os_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/os/os_test.go b/src/os/os_test.go index 122dfb5a66..e7d8e55094 100644 --- a/src/os/os_test.go +++ b/src/os/os_test.go @@ -3383,6 +3383,7 @@ func verifyCopyFS(t *testing.T, originFS, copiedFS fs.FS) error { if err != nil { return fmt.Errorf("stat file %q failed: %v", f.Name(), err) } + wantFileRWMode := wantFileRWStat.Mode() return fs.WalkDir(originFS, ".", func(path string, d fs.DirEntry, err error) error { if d.IsDir() { @@ -3437,13 +3438,14 @@ func verifyCopyFS(t *testing.T, originFS, copiedFS fs.FS) error { } // check whether the execute permission is inherited from original FS - if copiedStat.Mode()&0111 != fStat.Mode()&0111 { + + if copiedStat.Mode()&0111&wantFileRWMode != fStat.Mode()&0111&wantFileRWMode { return fmt.Errorf("file %q execute mode is %v, want %v", path, copiedStat.Mode()&0111, fStat.Mode()&0111) } rwMode := copiedStat.Mode() &^ 0111 // unset the executable permission from file mode - if rwMode != wantFileRWStat.Mode() { + if rwMode != wantFileRWMode { return fmt.Errorf("file %q rw mode is %v, want %v", path, rwMode, wantFileRWStat.Mode()) } -- 2.48.1