Skip to content

Commit f27c915

Browse files
tyan0dscho
authored andcommitted
Cygwin: termios: Handle app execution alias in is_console_app()
Microsoft Store apps are run via app execution aliases, i.e. special reparse points. Currently, spawn.cc does not resolve a reparse point when retrieving the path of app after the commit f74dc93, that disabled to follow windows reparse point by adding PC_SYM_NOFOLLOW_REP flag. However, unlike proper reparse point, app execution aliases are not resolved when trying to open the file via CreateFile(). As a result, if the path, that is_console_app() received, is the reparse point for an app execution alias, the func retuned false due to open-failure because CreateFile() cannot open an app execution alias, while it can open normal reparse point. If is_console_app() returns false, standard handles for console app (such as WSL) would not be setup. This causes that the console input cannot be transfered to the non-cygwin app. This patch fixes the issue by locally converting the path once again using option PC_SYM_FOLLOW (without PC_SYM_NOFOLLOW_REP), which is used inside is_console_app() to resolve the reparse point, if the path is an app execution alias. Fixes: f74dc93 ("fix native symlink spawn passing wrong arg0") Reviewed-by: Johannes Schindelin <[email protected]> Signed-off-by: Takashi Yano <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent a18fe29 commit f27c915

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

winsup/cygwin/fhandler/termios.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,15 @@ is_console_app (path_conv &pc)
711711
wchar_t *e = wcsrchr (native_path, L'.');
712712
if (e && (wcscasecmp (e, L".bat") == 0 || wcscasecmp (e, L".cmd") == 0))
713713
return true;
714+
715+
if (pc.is_app_execution_alias ())
716+
{
717+
UNICODE_STRING upath;
718+
RtlInitUnicodeString (&upath, native_path);
719+
path_conv target (&upath, PC_SYM_FOLLOW);
720+
target.get_wide_win32_path (native_path);
721+
}
722+
714723
HANDLE h;
715724
h = CreateFileW (native_path, GENERIC_READ, FILE_SHARE_READ,
716725
NULL, OPEN_EXISTING, 0, NULL);

0 commit comments

Comments
 (0)