From 01bf8977e79b1fc2b95625c44f4c963e74365c97 Mon Sep 17 00:00:00 2001 From: crazycatz00 Date: Wed, 18 Jun 2025 20:32:59 -0400 Subject: [PATCH] fs: Use backup privileges when reading extended attributes for files too. --- internal/fs/file_windows.go | 5 +---- internal/fs/node_windows_test.go | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/internal/fs/file_windows.go b/internal/fs/file_windows.go index f1ff733fa..2aa050d2c 100644 --- a/internal/fs/file_windows.go +++ b/internal/fs/file_windows.go @@ -123,10 +123,7 @@ func openHandleForEA(nodeType data.NodeType, path string, writeAccess bool) (han } switch nodeType { - case data.NodeTypeFile: - utf16Path := windows.StringToUTF16Ptr(path) - handle, err = windows.CreateFile(utf16Path, uint32(fileAccess), 0, nil, windows.OPEN_EXISTING, windows.FILE_ATTRIBUTE_NORMAL, 0) - case data.NodeTypeDir: + case data.NodeTypeFile, data.NodeTypeDir: utf16Path := windows.StringToUTF16Ptr(path) handle, err = windows.CreateFile(utf16Path, uint32(fileAccess), 0, nil, windows.OPEN_EXISTING, windows.FILE_ATTRIBUTE_NORMAL|windows.FILE_FLAG_BACKUP_SEMANTICS, 0) default: diff --git a/internal/fs/node_windows_test.go b/internal/fs/node_windows_test.go index 426a074d5..fcfa3ed37 100644 --- a/internal/fs/node_windows_test.go +++ b/internal/fs/node_windows_test.go @@ -302,9 +302,7 @@ func TestRestoreExtendedAttributes(t *testing.T) { var handle windows.Handle var err error utf16Path := windows.StringToUTF16Ptr(testPath) - if node.Type == data.NodeTypeFile { - handle, err = windows.CreateFile(utf16Path, windows.FILE_READ_EA, 0, nil, windows.OPEN_EXISTING, windows.FILE_ATTRIBUTE_NORMAL, 0) - } else if node.Type == data.NodeTypeDir { + if node.Type == data.NodeTypeFile || node.Type == data.NodeTypeDir { handle, err = windows.CreateFile(utf16Path, windows.FILE_READ_EA, 0, nil, windows.OPEN_EXISTING, windows.FILE_ATTRIBUTE_NORMAL|windows.FILE_FLAG_BACKUP_SEMANTICS, 0) } test.OK(t, errors.Wrapf(err, "Error opening file/directory for: %s", testPath))