Mailing-List: contact cygwin-apps-help AT cygwin DOT com; run by ezmlm Sender: cygwin-apps-owner AT cygwin DOT com List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps AT cygwin DOT com Delivered-To: mailing list cygwin-apps AT cygwin DOT com Date: Thu, 16 May 2002 10:33:22 +0200 From: Pavel Tsekov Reply-To: Pavel Tsekov Organization: Syntrex, Inc. X-Priority: 3 (Normal) Message-ID: <734230833.20020516103322@syntrex.com> To: "Robert Collins" CC: cygwin-apps AT cygwin DOT com, cygwin-xfree AT sources DOT redhat DOT com Subject: Re[2]: setup.exe and inuse files for X In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello Robert, Friday, May 03, 2002, 1:58:28 AM, you wrote: >> -----Original Message----- >> From: Corinna Vinschen [mailto:cygwin-apps AT cygwin DOT com] >> Sent: Friday, May 03, 2002 1:44 AM >> To: CygWin Apps; Cygwin-Xfree >> Subject: Re: setup.exe and inuse files for X >> >> >> On Wed, May 01, 2002 at 04:58:36PM +1000, Robert Collins wrote: >> > I think I've got a handle on this... looks like read only >> (-r--r--r--) >> > files don't delete properly, so setup fails to overwrite them. >> > >> > Patches gratefully accepted, it's going in the TODO for now. >> >> I recall having sent a patch for this a few months ago to the >> cygwin-apps list... RC> Yes. And I had implemented similar code. (Including the RC> SetFileAttributes call). RC> I'm not sure why it is still failing to do what it should. Check this out: Quoted from the description of DeleteFile in the MDSN library: To delete or rename a file, you must have either delete permission on the file or delete child permission in the parent directory. If you set up a directory with all access except delete and delete child and the ACLs of new files are inherited, then you should be able to create a file without being able to delete it. However, you can then create a file, and you will get all the access you request on the handle returned to you at the time you create the file. If you requested delete permission at the time you created the file, you could delete or rename the file with that handle but not with any other. ACL of a mode 400 file from my home directory: C:\cygwin\home\paveltz\test.c MORDOR\paveltz:(accesso speciale:) READ_CONTROL WRITE_DAC WRITE_OWNER SYNCHRONIZE FILE_GENERIC_READ FILE_READ_DATA FILE_READ_EA FILE_WRITE_EA FILE_READ_ATTRIBUTES FILE_WRITE_ATTRIBUTES MORDOR\Nessuno:(accesso speciale:) READ_CONTROL FILE_READ_EA FILE_READ_ATTRIBUTES Everyone:(accesso speciale:) READ_CONTROL FILE_READ_EA FILE_READ_ATTRIBUTES Obviously the DELETE permission is missing. You call SetFileAttributes with ~FILE_ATTRIBUTE_READONLY which shoul enable the file for reading but it does not - I suppose this is why: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/filesio_6c8i.asp Note that it is said: dwFileAttributes Specifies FAT-style attribute information for the file or directory. But if we're on NTFS there is no joy :( I've tried a simple test with SetFileAttributes and ~FILE_ATTRIBUTE_READONLY and it doesnt affect the file at all. Ok here is how to fix this issues I've just tried it on my XP Home and it worked fine. HANDLE h = CreateFile("test.c", DELETE, 0, // We want it all :) NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY /*to be compatible*/ | FILE_FLAG_DELETE_ON_CLOSE, NULL); CloseHandle (h);