]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: realpath: fix cygwin installation dir being access via junction
authorCorinna Vinschen <corinna@vinschen.de>
Fri, 19 Feb 2021 17:15:58 +0000 (18:15 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Fri, 19 Feb 2021 17:15:58 +0000 (18:15 +0100)
commit6d898f43fc87a7bf3ab100d75538e381bd86f657
treed1f9191cfc4bd999c43261548cdfbb1b5f595459
parent543e39bb129ac77e29e3800a468100a754ad3d2a
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>
winsup/cygwin/cygheap.cc
This page took 0.029842 seconds and 5 git commands to generate.