Skip to content

Commit 2a32b21

Browse files
[test] handle ModeIrregular in getFilePerm for Go 1.23
1 parent b9f6013 commit 2a32b21

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/images/agnhost/mounttest/mt_utils_windows.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ func getFilePerm(path string) (os.FileMode, error) {
7777
// NOTE(claudiub): Symlinks have different permissions which might not match the target's.
7878
// We want to evaluate the permissions of the target's not the symlink's.
7979
info, err := os.Lstat(path)
80-
if err == nil && info.Mode()&os.ModeSymlink != 0 {
81-
evaluated, err := filepath.EvalSymlinks(path)
82-
if err != nil {
83-
return 0, err
80+
if err == nil {
81+
// go1.23 behavior change: https://github.com/golang/go/issues/63703#issuecomment-2535941458
82+
if info.Mode()&os.ModeSymlink != 0 || info.Mode()&os.ModeIrregular != 0 {
83+
evaluated, err := filepath.EvalSymlinks(path)
84+
if err != nil {
85+
return 0, err
86+
}
87+
path = evaluated
8488
}
85-
path = evaluated
8689
}
8790

8891
cmd := exec.Command("powershell.exe", "-NonInteractive", "./filePermissions.ps1",

0 commit comments

Comments
 (0)