An app execution alias cannot be opened for read (CreateFile() with
GENERIC_READ fails with ERROR_CANT_ACCESS_FILE) because it does not
resolve the reparse point.  Therefore, we need to know if the path
is an app execution alias when opening it.

This patch adds new api path_conv::is_app_execution_alias() for
that purpose.

Reviewed-by:
Signed-off-by: Takashi Yano <[email protected]>
---
 winsup/cygwin/local_includes/path.h | 5 +++++
 winsup/cygwin/path.cc               | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/local_includes/path.h 
b/winsup/cygwin/local_includes/path.h
index a9ce2c7e4..ad142ddd3 100644
--- a/winsup/cygwin/local_includes/path.h
+++ b/winsup/cygwin/local_includes/path.h
@@ -79,6 +79,7 @@ enum path_types
   PATH_SOCKET          = _BIT ( 5),    /* AF_UNIX socket file */
   PATH_RESOLVE_PROCFD  = _BIT ( 6),    /* fd symlink via /proc */
   PATH_REP_NOAPI       = _BIT ( 7),    /* rep. point unknown to WinAPI */
+  PATH_APPEXECLINK     = _BIT ( 8),    /* rep. point app execution alias */
   PATH_DONT_USE                = _BIT (31)     /* conversion to signed 
happens. */
 };
 
@@ -214,6 +215,10 @@ class path_conv
   {
     return (path_flags & (PATH_REP | PATH_REP_NOAPI)) == PATH_REP;
   }
+  int is_app_execution_alias () const
+  {
+    return path_flags & PATH_APPEXECLINK;
+  }
 
   int isfifo () const {return dev.is_device (FH_FIFO);}
   int iscygdrive () const {return dev.is_device (FH_CYGDRIVE);}
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 710775e38..625e60686 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2661,7 +2661,7 @@ check_reparse_point_target (HANDLE h, bool remote, 
PREPARSE_DATA_BUFFER rp,
          if (i == 2 && n > 0 && n < size)
            {
              RtlInitCountedUnicodeString (psymbuf, buf, n * sizeof (WCHAR));
-             return PATH_SYMLINK | PATH_REP;
+             return PATH_SYMLINK | PATH_REP | PATH_APPEXECLINK;
            }
          if (i == 2)
            break;
-- 
2.51.0

Reply via email to