This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH] fix unlink for Cygwin 1.5.25-15 -- unintended data loss with symbolic file links
- From: "Jason" <cygwin at jason-gouger dot com>
- To: <cygwin-patches at cygwin dot com>
- Date: Mon, 15 Sep 2008 14:31:07 -0700
- Subject: [PATCH] fix unlink for Cygwin 1.5.25-15 -- unintended data loss with symbolic file links
Please consider the patch below for inclusion in the Cygwin 1.5 branch which
corrects the deletion of symbolic link file types (Vista file reparse
points).
The problem is that CreateFile will open the target and not the link. See
the MSDN page
http://msdn.microsoft.com/en-us/library/aa365682(VS.85).aspx#CreateFile for
a more detailed description of Vista's symbolic link handling.
Thanks,
Jason
---
2008-09-15 Jason Gouger <cygwin at jason-gouger.com>
* syscalls.cc: Fix 'unlink' so that it will delete the symbolic link
and not the target file for Vista's file reparse points.
Index: cygwin/syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.403.4.3
diff -b -u -p -r1.403.4.3 syscalls.cc
--- cygwin/syscalls.cc 12 Nov 2007 15:30:20 -0000 1.403.4.3
+++ cygwin/syscalls.cc 15 Sep 2008 21:06:10 -0000
@@ -207,7 +207,7 @@ unlink (const char *ourname)
{
HANDLE h;
h = CreateFile (win32_name, 0, FILE_SHARE_READ, &sec_none_nih,
- OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0);
+ OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT |
FILE_FLAG_DELETE_ON_CLOSE, 0);
if (h != INVALID_HANDLE_VALUE)
{
if (wincap.has_hard_links () && setattrs)