From b778ec014208bcd11f2739344fea762712568ad5 Mon Sep 17 00:00:00 2001 From: Charles Hamilton <52973156+chamilton-ccn@users.noreply.github.com> Date: Fri, 7 Jun 2024 08:26:30 -0400 Subject: [PATCH] windows: make rclone work with SeBackupPrivilege and/or SeRestorePrivilege On Windows, this change includes the `FILE_FLAG_BACKUP_SEMANTICS` in all calls to `CreateFile`. Adding this flag allows is useful when rclone is running within a security context that has `SeBackupPrivilege` and/or `SeRestorePrivilege` token privileges enabled. Without this flag, rclone cannot properly leverage special security groups such as Backup Operators who possess the these privileges. See: https://forum.rclone.org/t/rclone-sebackupprivilege-file-flag-backup-semantics/45339 See: https://github.com/rclone/rclone/pull/7877. --- lib/file/file_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/file/file_windows.go b/lib/file/file_windows.go index 7840f98e1..cefd4f2f6 100644 --- a/lib/file/file_windows.go +++ b/lib/file/file_windows.go @@ -61,7 +61,7 @@ func OpenFile(path string, mode int, perm os.FileMode) (*os.File, error) { default: createmode = syscall.OPEN_EXISTING } - h, e := syscall.CreateFile(pathp, access, sharemode, nil, createmode, syscall.FILE_ATTRIBUTE_NORMAL, 0) + h, e := syscall.CreateFile(pathp, access, sharemode, nil, createmode, syscall.FILE_ATTRIBUTE_NORMAL|syscall.FILE_FLAG_BACKUP_SEMANTICS, 0) if e != nil { return nil, e }