From 2a32b2137236fa7a5ede1ec391f55323a3485020 Mon Sep 17 00:00:00 2001 From: mansikulkarni96 Date: Mon, 17 Feb 2025 16:39:58 -0500 Subject: [PATCH] [test] handle ModeIrregular in getFilePerm for Go 1.23 --- test/images/agnhost/mounttest/mt_utils_windows.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/images/agnhost/mounttest/mt_utils_windows.go b/test/images/agnhost/mounttest/mt_utils_windows.go index 2901c456e48..c533048bb4a 100644 --- a/test/images/agnhost/mounttest/mt_utils_windows.go +++ b/test/images/agnhost/mounttest/mt_utils_windows.go @@ -77,12 +77,15 @@ func getFilePerm(path string) (os.FileMode, error) { // NOTE(claudiub): Symlinks have different permissions which might not match the target's. // We want to evaluate the permissions of the target's not the symlink's. info, err := os.Lstat(path) - if err == nil && info.Mode()&os.ModeSymlink != 0 { - evaluated, err := filepath.EvalSymlinks(path) - if err != nil { - return 0, err + if err == nil { + // go1.23 behavior change: https://github.com/golang/go/issues/63703#issuecomment-2535941458 + if info.Mode()&os.ModeSymlink != 0 || info.Mode()&os.ModeIrregular != 0 { + evaluated, err := filepath.EvalSymlinks(path) + if err != nil { + return 0, err + } + path = evaluated } - path = evaluated } cmd := exec.Command("powershell.exe", "-NonInteractive", "./filePermissions.ps1",