Mail Archives: cygwin-apps/2002/01/14/16:17:48
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
/usr/sbin/slogin.lnk.
- 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.
Corinna
2002-01-14 Corinna Vinschen <corinna AT vinschen DOT de>
* package_meta.cc (packagemeta::uninstall): Uninstall a file
even with trailing ".lnk". Unset R/O file attribute before
trying to delete file.
Index: package_meta.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/package_meta.cc,v
retrieving revision 2.11
diff -u -p -r2.11 package_meta.cc
--- package_meta.cc 2002/01/06 11:31:47 2.11
+++ package_meta.cc 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))
+ if (dw == INVALID_FILE_ATTRIBUTES)
{
+ /* Check for Windows shortcut. */
+ strcpy (buf, d);
+ strcat (buf, ".lnk");
+ d = buf;
+ dw = GetFileAttributes (d);
+ }
+ if (dw != INVALID_FILE_ATTRIBUTES && !(dw & FILE_ATTRIBUTE_DIRECTORY))
+ {
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 mailto:cygwin AT cygwin DOT com
Red Hat, Inc.
- Raw text -