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 f74dc93c63, 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: f74dc93c63 ("fix native symlink spawn passing wrong arg0")
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit 28b82486d3)
This commit is contained in:
Takashi Yano committed 2025-12-20 03:27:02 +09:00
1 parent 9d17f9fefc
commit 6c3d26961d
1 file changed
+9
+9
View File
@@ -711,6 +711,15 @@ is_console_app (path_conv &pc)
wchar_t *e = wcsrchr (native_path, L'.');
if (e && (wcscasecmp (e, L".bat") == 0 || wcscasecmp (e, L".cmd") == 0))
return true;
if (pc.is_app_execution_alias ())
{
UNICODE_STRING upath;
RtlInitUnicodeString (&upath, native_path);
path_conv target (&upath, PC_SYM_FOLLOW);
target.get_wide_win32_path (native_path);
}
HANDLE h;
h = CreateFileW (native_path, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL);