https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=28b82486d39f6594f6fd3f8ba2ffdbe30ea932b2

commit 28b82486d39f6594f6fd3f8ba2ffdbe30ea932b2
Author: Takashi Yano <[email protected]>
Date:   Wed Dec 10 14:31:20 2025 +0900

    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 f74dc93c6359, 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: f74dc93c6359 ("fix native symlink spawn passing wrong arg0")
    Reviewed-by: Johannes Schindelin <[email protected]>
    Signed-off-by: Takashi Yano <[email protected]>

Diff:
---
 winsup/cygwin/fhandler/termios.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/winsup/cygwin/fhandler/termios.cc 
b/winsup/cygwin/fhandler/termios.cc
index 63b8f63fc..694a5c20f 100644
--- a/winsup/cygwin/fhandler/termios.cc
+++ b/winsup/cygwin/fhandler/termios.cc
@@ -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);

Reply via email to