4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-13 20:49:08 +08:00
Corinna Vinschen afdd946b01 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-03-03 17:57:33 -05:00
..
2020-10-14 10:54:21 -04:00
2020-10-14 10:54:29 -04:00
2016-06-25 00:43:01 +02:00
2020-10-14 10:54:03 -04:00
2020-10-14 10:54:03 -04:00
2021-02-01 12:16:54 -05:00
2018-02-20 17:59:53 +01:00
2021-02-01 12:16:54 -05:00
2020-10-14 10:54:29 -04:00
2020-10-19 17:54:55 -04:00
2017-03-27 22:03:58 +01:00
2015-08-17 11:05:43 +02:00
2020-12-07 14:08:38 -05:00
2020-10-14 10:54:29 -04:00
2018-04-16 22:46:11 -05:00
2020-10-14 10:54:29 -04:00
2020-10-14 10:53:55 -04:00
2020-10-14 10:53:55 -04:00