This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Preliminary patch for symlink problem in setup.exe

I've found a problem in setup.exe which potentially results in
two symlinks with the same name.

As you know, the default setting for symlinks in Cygwin is using
Windows shortcuts while setup.exe always creates symlinks as
the old-style system files.

Now imagine the following simple situation

- Delete /usr/bin/slogin by mistake.

- Recreate /usr/sbin/slogin with ln(1) creates a Windows shortcut

- A new OpenSSH package is downloaded using setup.exe.

Now look into the /usr/bin directory.  You will find two files,
`slogin' and `slogin.lnk'.

The following patch is a quick hack which I'd like to get reviewed
by the active setup contributors (not me).

The additional advantage of that patch is that it alleviates the
problem that setup complains when a file couldn't be installed
because the file already exists and couldn't be unlinked before.
That happens mostly when the R/O file attribute is set since
DeleteFile() fails then.

Oh, and I'm using the new INVALID_FILE_ATTRIBUTES define which
I found in the latest MSDN (surprise, surprise) and which
substitutes all prior ((DWORD) -1) or 0xffffffff constants
to mark the return code of GetFileAttributes() for ... yeah, you
guessed it, invalid file attributes.


2002-01-14  Corinna Vinschen  <>

	* (packagemeta::uninstall): Uninstall a file
	even with trailing ".lnk".  Unset R/O file attribute before
	trying to delete file.

RCS file: /cvs/src/src/winsup/cinstall/,v
retrieving revision 2.11
diff -u -p -r2.11
---	2002/01/06 11:31:47	2.11
+++	2002/01/14 21:08:44
@@ -120,11 +120,22 @@ packagemeta::uninstall ()
 	  dirs.add_subdirs (line);
+	  char buf[512];
 	  char *d = cygpath ("/", line, NULL);
 	  DWORD dw = GetFileAttributes (d);
-	  if (dw != 0xffffffff && !(dw & FILE_ATTRIBUTE_DIRECTORY))
+	      /* Check for Windows shortcut. */
+	      strcpy (buf, d);
+	      strcat (buf, ".lnk");
+	      d = buf;
+	      dw = GetFileAttributes (d);
+	    }
+	    {
 	      log (LOG_BABBLE, "unlink %s", d);
+	      SetFileAttributes (d, dw & ~FILE_ATTRIBUTE_READONLY);
 	      DeleteFile (d);
 	  line = installed->getnextfile ();

Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                      
Red Hat, Inc.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]