I am developing a Windows backup application (mixed Go / C++) that needs to backup files from the disk.
My application
- runs as a user in the "Backup Operators" group, and also with "Back up files and directories" explicitly enabled in
secpol.msc
- calls
OpenProcessToken()
andAdjustTokenPrivileges()
to grantSeBackupPrivilege
for the whole process, successfully - takes a VSS snapshot of the disk, successfully
walks over all files in the VSS snapshot, and then tries to back them up as follows:
CreateFile( path, GENERIC_READ, FILE_SHARE_READ, NULL, // SecurityAttributes OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_SEQUENTIAL_SCAN NULL // TemplateFile );
Calls
BackupRead()
to read file streams.
This normally works fine, and I can successfully read files for which my user account would normally be denied read access to (e.g. C:\Windows\System32\config\systemprofile
).
But despite this, some "stubborn" files still give an error, from CreateFile
: 0x5 ERROR_ACCESS_DENIED
("Access is Denied").
I know the "stubborn" files aren't reparse points.
The files exist on a local, internally-attached, SATA, NTFS disk drive - not a network drive or anything exotic.
The "stubborn" files are all files, not directories.
They are a range of file-types (docx, fla, swf, .DS_Store, ...).
There's no special security software installed other than an Antivirus program.
A competititor's backup software is able to back up these files without error.
Why could this possibly be happening?