Enabling SE_BACKUP_NAME has no effect for cygwin programs.
The attached program demonstrates the issue.
It retrieves the attributes of a normally inaccessible file without and
with SE_BACKUP_NAME.
(The file should be present on XP with C:\ as system drive)
If compiled with "-mno-cygwin" and running as admin on XP Prof, the
second access succeeds as expected:
GetFileAttributes failed: 5
SeBackupPrivilege enabled!
GetFileAttributes = 0x0026
But if running as a cygwin program on 1.5.19, the result is:
GetFileAttributes failed: 5
SeBackupPrivilege enabled!
GetFileAttributes failed: 5
The privilege can be enabled, but has no effect - bug or feature ?-)
Thanks for any help.
Christian
#include <windows.h>
#include <stdio.h>
static void Check()
{
DWORD attr = GetFileAttributes("C:/System Volume
Information/MountPointManagerRemoteDatabase");
if (attr == ~(DWORD)0)
printf("GetFileAttributes failed: %ld\n", GetLastError());
else
printf("GetFileAttributes = 0x%04lx\n", attr); // Usually
0x0026, Archive|System|Hidden
}
static bool GetBackupPrivil()
{
HANDLE t;
if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &t))
{
printf("OpenProcessToken failed: %ld\n", GetLastError());
return false;
}
TOKEN_PRIVILEGES tp;
if(!LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &tp.Privileges[0].Luid))
{
printf("LookupPrivilegeValue failed: %ld\n", GetLastError());
return false;
}
tp.PrivilegeCount = 1;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(t, FALSE, &tp, 0, NULL, NULL);
if (GetLastError() != ERROR_SUCCESS) {
printf("AdjustTokenPrivileges failed: %ld\n", GetLastError());
return false;
}
CloseHandle(t);
printf(SE_BACKUP_NAME" enabled!\n");
return true;
}
main()
{
Check();
if (!GetBackupPrivil())
return 1;
Check();
return 0;
}
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/