]> Cypherpunks repositories - gostls13.git/commitdiff
os: handle umask comparing execute mode in verifyCopyFS
authorIan Lance Taylor <iant@golang.org>
Wed, 9 Oct 2024 21:32:21 +0000 (14:32 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 9 Oct 2024 22:07:37 +0000 (22:07 +0000)
Fixes #69788

Change-Id: I43cc4c0dc3c8aa2474cba26c84714d00828de08e
Reviewed-on: https://go-review.googlesource.com/c/go/+/619176
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

src/os/os_test.go

index 122dfb5a66884fccb88b50fd5d7afa84cc619cf9..e7d8e55094488d7fa3bd95e0b1040979ab37ae67 100644 (file)
@@ -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())
                }