summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2025-01-28 05:24:52 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2025-01-28 05:24:52 (GMT)
commit5a9b2f09ddd894b869c2bd989af746a501ae12aa (patch)
treeac87eec55fa3138e4b1606bce6a655a078434514
parent5edd595ea2319f0c083c7a8a8b758bec36ad2a33 (diff)
downloadtcl-5a9b2f09ddd894b869c2bd989af746a501ae12aa.zip
tcl-5a9b2f09ddd894b869c2bd989af746a501ae12aa.tar.gz
tcl-5a9b2f09ddd894b869c2bd989af746a501ae12aa.tar.bz2
Cherry pick fix for [4f0b5767ac]. Exec of App Execution Aliases on Windows
-rw-r--r--tests/exec.test11
-rw-r--r--win/tclWinPipe.c13
2 files changed, 23 insertions, 1 deletions
diff --git a/tests/exec.test b/tests/exec.test
index e77a0ac..ff32799 100644
--- a/tests/exec.test
+++ b/tests/exec.test
@@ -23,6 +23,12 @@ source [file join [file dirname [info script]] tcltests.tcl]
# Some skips when running in a macOS CI environment
testConstraint noosxCI [expr {![info exists ::env(MAC_CI)]}]
+# Need a App Exec Alias for testing exec of reparse points
+if {[info exists ::env(LOCALAPPDATA)] &&
+ [file exists [file join $::env(LOCALAPPDATA) "Microsoft" "WindowsApps" "winget.exe"]]} {
+ testConstraint haveWinget 1
+}
+
unset -nocomplain path
# Utilities that are like Bourne shell stalwarts, but cross-platform.
@@ -706,6 +712,11 @@ test exec-20.1 {exec .CMD file} -constraints {win} -body {
exec [makeFile "echo %1> $log" exec201.CMD] "Testing exec-20.1"
viewFile $log
} -result "\"Testing exec-20.1\""
+
+test exec-bug-4f0b5767ac {exec App Execution Alias} -constraints haveWinget -body {
+ exec winget --info
+} -result "Windows Package Manager*" -match glob
+
# ----------------------------------------------------------------------
# cleanup
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 229f670..869ff2b 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -1320,11 +1320,22 @@ ApplicationType(
hFile = CreateFileW(nativeFullPath,
GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OPEN_REPARSE_POINT, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
continue;
}
+ if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
+ /*
+ * But [4f0b5767ac]. Likely a App Execution Alias. This can only
+ * be a Win32 APP. Attempt to ReadFile below will fail. We assume
+ * that if it is on the PATH, and it is a reparse point, it is an
+ * App Execution Alias.
+ */
+ applType = APPL_WIN32;
+ break;
+ }
+
header.e_magic = 0;
ReadFile(hFile, (void *) &header, sizeof(header), &read, NULL);
if (header.e_magic != IMAGE_DOS_SIGNATURE) {