X-Spam-Check-By: sourceware.org Message-ID: <4405F5F9.8010708@t-online.de> Date: Wed, 01 Mar 2006 20:28:57 +0100 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: No effect of SE_BACKUP_NAME privilege on cygwin? Content-Type: multipart/mixed; boundary="------------090805050407070805000805" X-ID: T5e9dcZvYeEkeGbGly1VD2Tl2lhyXa7lKvCaGDeeaqZBx9r9jz4LrQ X-TOI-MSGID: b1b1f330-3be4-4760-933b-3fb9ec32c9a9 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --------------090805050407070805000805 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------090805050407070805000805 Content-Type: text/plain; name="privilege.cc" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="privilege.cc" #include #include 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; } --------------090805050407070805000805 Content-Type: text/plain; charset=us-ascii -- 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/ --------------090805050407070805000805--