]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1769: executable() ignoring symlinks on Windows v9.0.1769
authorAmberArr <me@frost.moe>
Sun, 20 Aug 2023 18:03:45 +0000 (20:03 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 20 Aug 2023 18:03:45 +0000 (20:03 +0200)
Problem:  executable() ignoring symlinks on Windows
Solution: resolve reparse points

closes: #12562

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: AmberArr <me@frost.moe>
src/os_mswin.c
src/os_win32.c
src/proto/os_mswin.pro
src/testdir/test_functions.vim
src/version.c

index 5360fa9894e24fcb4aae12a20c0e43384ccb72f0..aa5fe5243e43ea9998403c885c6075438f8422ff 100644 (file)
@@ -1775,7 +1775,11 @@ is_reparse_point_included(LPCWSTR fname)
     return FALSE;
 }
 
-    static char_u *
+/*
+ * Return the resolved file path, NULL if "fname" is an AppExecLink reparse
+ * point, already fully resolved, or it doesn't exists.
+ */
+    char_u *
 resolve_reparse_point(char_u *fname)
 {
     HANDLE         h = INVALID_HANDLE_VALUE;
index 52e0583fc65190836e36a0cc5bc69ced20bd908d..ff60e04aed9b51b321dbaf53e34c347c0e360ea6 100644 (file)
@@ -2720,6 +2720,8 @@ executable_file(char *name, char_u **path)
     if (attrs & FILE_ATTRIBUTE_REPARSE_POINT)
     {
        char_u  *res = resolve_appexeclink((char_u *)name);
+       if (res == NULL)
+           res = resolve_reparse_point((char_u *)name);
        if (res == NULL)
            return FALSE;
        // The path is already absolute.
index c63129f145839e8681c6b5ee98a45ff42d5bb315..d9172ee01ba39898027f9fb7aa9919086a67f2ac 100644 (file)
@@ -37,6 +37,7 @@ int mch_print_text_out(char_u *p, int len);
 void mch_print_set_font(int iBold, int iItalic, int iUnderline);
 void mch_print_set_bg(long_u bgcol);
 void mch_print_set_fg(long_u fgcol);
+char_u *resolve_reparse_point(char_u *fname);
 char_u *mch_resolve_path(char_u *fname, int reparse_point);
 void win32_set_foreground(void);
 void serverInitMessaging(void);
index 60e99210e26b3c2de1b3c6d457258912ff0c6a22..a500b734b276f5b1eb596024f711d3cb16043da6 100644 (file)
@@ -1818,6 +1818,10 @@ func Test_Executable()
     let [pathext, $PATHEXT] = [$PATHEXT, '.com;.exe;.bat;.cmd']
     call assert_equal(notepadbat, exepath('notepad'))
     let $PATHEXT = pathext
+    " check for symbolic link
+    execute 'silent !mklink np.bat "' .. notepadbat .. '"'
+    call assert_equal(1, executable('./np.bat'))
+    call assert_equal(1, executable('./np'))
     bwipe
     eval 'Xnotedir'->delete('rf')
   elseif has('unix')
index 598e3eecdcdaae46a683b10a7d23c2c79ecd8471..e81dd7184029f658340810be999a9498fb94ff11 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1769,
 /**/
     1768,
 /**/