newlib-cygwin/winsup
Corinna Vinschen 6d898f43fc Cygwin: realpath: fix cygwin installation dir being access via junction
Consider this case:

- Cygwin installed in C:\cygwin64

- mklink /j D:\cygwin64 C:\cygwin64

- create testcase calling

    realpath("/", result);
    printf ("%s\n", result);

- start cmd

    >C:\cygwin64\bin\bash -lc <path-to-testcase>
    /
    >D\cygwin64\bin\bash -lc <path-to-testcase>
    /cygdrive/c/cygwin64

This scenario circumventing the mount point handling which is automated
in terms of /, depending on the path returned from GetModuleFileNameW
for the Cygwin DLL.  When calling D:\cygwin64\bin\bash the dir returned
from GetModuleFileNameW is D:\cygwin64\bin, thus root is D:\cygwin64.

However, junctions are treated as symlinks in Cygwin which explains why
the path gets converted to a cygdrive path.

Fix this by calling GetFinalPathNameByHandleW on the result from
GetModuleFileNameW to get the correct root path, even if accessed via
a junction point.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-02-19 18:15:58 +01:00
..
CVSChangeLogs.old winsup: Move all old CVS Changelogs into CVSChangeLogs.old dir 2016-03-19 13:59:52 +01:00
cygserver Cygwin: Remove recursive configure 2020-11-20 15:56:11 +00:00
cygwin Cygwin: realpath: fix cygwin installation dir being access via junction 2021-02-19 18:15:58 +01:00
doc Cygwin: Add console fix regarding Ctrl-Z etc. to release notes. 2021-02-19 17:58:15 +01:00
testsuite Cygwin: testsuite: libltp: fix warnings showing up with -Wall 2020-12-02 14:12:56 +01:00
utils Cygwin: Fix remaining warnings building path testsuite 2020-12-02 15:31:58 +00:00
CONTRIBUTORS Cygwin: Add Ben Wijen to list of contributors 2021-01-18 12:01:19 +01:00
COPYING
COPYING.LIB Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
CYGWIN_LICENSE Clarify source file license in CYGWIN_LICENSE 2016-06-23 21:52:12 +02:00
Makefile.common Cygwin: Remove nostdlib Makefile variable 2020-10-21 17:11:02 +01:00
Makefile.in Cygwin: Remove recursive configure 2020-11-20 15:56:11 +00:00
README Fix typo and wrong URL in winsup/README 2016-05-24 10:25:18 +02:00
acinclude.m4 Cygwin: Remove recursive configure 2020-11-20 15:56:11 +00:00
aclocal.m4
autogen.sh Cygwin: Remove surplus autoconf auxiliary files 2020-11-20 15:56:21 +00:00
configure Cygwin: Remove recursive configure 2020-11-20 15:56:11 +00:00
configure.ac Cygwin: Remove recursive configure 2020-11-20 15:56:11 +00:00

README

THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESSED OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Cygwin documentation is available on the net at https://cygwin.com
You might especially be interested in

https://cygwin.com/faq/faq.html#faq.programming.building-cygwin