Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Stop the launch when Steam files cannot be copied

NotProtonNotc26c86487722
diff --git a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift b/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
index d2a4a1b..7a1f7a9 100644
--- a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
+++ b/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
@@ -285,7 +285,8 @@ struct PrefixToolsTests {
for call in calls {
let rest = source[call.upperBound...]
let line = try #require(rest.firstIndex(of: "\n"))
- #expect(rest[line...].hasPrefix("\n exit 1\n") || rest[line...].hasPrefix("\n exit 1\n"))
+ let next = rest[rest.index(after: line)...].prefix { $0 != "\n" }
+ #expect(next.trimmingCharacters(in: .whitespaces) == "exit 1")
}
}
diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.sh
index bc9ffd4..8831686 100755
--- a/dylib/feats/compat_run.sh
+++ b/dylib/feats/compat_run.sh
@@ -856,7 +856,8 @@ install_lsteamclient_trigger() {
if place_bridge_file i386-windows/lsteamclient.dll "$dst"; then
echo "=== installed syswow64 lsteamclient trigger ===" >> "$log" 2>&1 || true
else
- echo "=== could not install the syswow64 lsteamclient trigger ===" >> "$log" 2>&1 || true
+ echo "=== could not copy i386-windows/lsteamclient.dll to $dst ===" >> "$log" 2>&1 || true
+ return 1
fi
}
@@ -869,7 +870,7 @@ install_legacy_steam_dll() {
if place_bridge_file legacycompat/Steam.dll "$dst"; then
echo "=== installed legacy Steam.dll ===" >> "$log" 2>&1 || true
else
- echo "=== could not install the legacy Steam.dll ===" >> "$log" 2>&1 || true
+ echo "=== could not copy legacycompat/Steam.dll to $dst ===" >> "$log" 2>&1 || true
fi
}
@@ -885,8 +886,11 @@ install_legacycompat() {
[ -f "$f" ] || continue
b=$(basename "$f")
cmp -s "$f" "$dst/$b" && continue
- cp -c -f "$f" "$dst/$b" && \
- echo "=== installed legacycompat/$b ===" >> "$log" 2>&1
+ if cp -c -f "$f" "$dst/$b" 2>> "$log"; then
+ echo "=== installed legacycompat/$b ===" >> "$log" 2>&1 || true
+ else
+ echo "=== could not copy legacycompat/$b to $dst/$b ===" >> "$log" 2>&1 || true
+ fi
done
}
@@ -912,7 +916,7 @@ bridge_origin() {
}
place_bridge_file() {
bridge_origin "$1"
- cp -c -fp "$origin" "$2" 2>/dev/null || cp -fp "$bridge_src/$1" "$2"
+ cp -c -fp "$origin" "$2" 2>/dev/null || cp -fp "$bridge_src/$1" "$2" 2>> "$log"
}
if [ -d "$bridge_src" ] && [ -n "$WINEPREFIX" ]; then
stage_step="bridge staging"
@@ -936,6 +940,7 @@ if [ -d "$bridge_src" ] && [ -n "$WINEPREFIX" ]; then
if [ "$bridge_matches" -eq 1 ]; then
echo "=== bridge already staged ===" >> "$log" 2>&1 || true
else
+ unstaged=0
for f in $bridge_files; do
rel="$f"
if [ "$f" = lsteamclient.so ]; then
@@ -947,9 +952,15 @@ if [ -d "$bridge_src" ] && [ -n "$WINEPREFIX" ]; then
continue
fi
cmp -s "$src" "$prefix_steam/$f" && continue
- place_bridge_file "$rel" "$prefix_steam/$f" || \
- echo "=== failed to stage $f ===" >> "$log" 2>&1
+ if ! place_bridge_file "$rel" "$prefix_steam/$f"; then
+ echo "=== could not copy $rel to $prefix_steam/$f ===" >> "$log" 2>&1 || true
+ unstaged=1
+ fi
done
+ if [ "$unstaged" -eq 1 ]; then
+ show_alert "Steam files could not be copied" "NotProton could not copy a file into this game's prefix. Open this prefix's notproton-run.log for details."
+ exit 1
+ fi
fi
for f in "$prefix_steam"/*.dll "$prefix_steam"/*.so "$prefix_steam"/*.exe; do
[ -f "$f" ] || continue
@@ -959,7 +970,10 @@ if [ -d "$bridge_src" ] && [ -n "$WINEPREFIX" ]; then
esac
done
verify_runner
- install_lsteamclient_trigger
+ if ! install_lsteamclient_trigger; then
+ show_alert "Steam files could not be copied" "NotProton could not copy a file into this game's prefix. Open this prefix's notproton-run.log for details."
+ exit 1
+ fi
install_legacy_steam_dll
export WINEDLLPATH="$prefix_steam:$WINEDLLPATH"
# If the same DLL appears twice in WINEDLLOVERRIDES, the last entry wins.
diff --git a/dylib/tests/bridgecheck.sh b/dylib/tests/bridgecheck.sh
index ac5ea31..bd17ccd 100644
--- a/dylib/tests/bridgecheck.sh
+++ b/dylib/tests/bridgecheck.sh
@@ -11,8 +11,11 @@ case "$block" in
*) echo "FAIL: the bridge staging block not found in $SRC"; exit 1 ;;
esac
block=$(printf '%s\n' "$block" | sed '$d')
+legacy=$(sed -n '/^install_legacycompat() {/,/^}/p' "$SRC")
+[ -n "$legacy" ] || { echo "FAIL: install_legacycompat not found in $SRC"; exit 1; }
body='same_volume() { [ -z "$cross" ]; }
volume_clones() { :; }
+show_alert() { printf "alert: %s\n" "$1" >> "$log"; }
'"$block
fi"
@@ -155,5 +158,48 @@ chmod 700 "${cache%/*}"
is "the launch goes on" reached "$(cat "$work/out")"
is "every file is copied" 6 "$(staged)"
+echo "== a file that cannot be staged stops the launch"
+cross=""
+rm "$steam/steam.exe"
+chmod 500 "$steam"
+stage
+chmod 700 "$steam"
+is "the launch stops" "" "$(grep -x reached "$work/out")"
+logged "the failure is logged" "=== could not copy steam.exe to $steam/steam.exe ==="
+is "the reason is logged" yes "$(grep -q 'Permission denied' "$work/log" && echo yes || echo no)"
+logged "the player is told" "alert: Steam files could not be copied"
+stage
+is "the next launch stages it" reached "$(cat "$work/out")"
+is "every file is copied" 6 "$(staged)"
+
+echo "== a syswow64 trigger that cannot be installed stops the launch"
+trigger=$(sed -n '/^install_lsteamclient_trigger() {/,/^}/p;/^bridge_origin() {/,/^}/p;/^place_bridge_file() {/,/^}/p' "$SRC")
+mkdir -p "$work/bridge/i386-windows" "$prefix/drive_c/windows/syswow64"
+printf 'i386 bridge\n' > "$work/bridge/i386-windows/lsteamclient.dll"
+chmod 500 "$prefix/drive_c/windows/syswow64"
+: > "$work/log"
+env bridge_src="$work/bridge" WINEPREFIX="$prefix" log="$work/log" bridge_cache="" trigger="$trigger" \
+ sh -ec 'eval "$trigger"; if install_lsteamclient_trigger; then echo installed; else echo refused; fi' > "$work/out" 2>&1 || true
+chmod 700 "$prefix/drive_c/windows/syswow64"
+is "the trigger reports the failure" refused "$(cat "$work/out")"
+logged "the failure is logged" "=== could not copy i386-windows/lsteamclient.dll to $prefix/drive_c/windows/syswow64/lsteamclient.dll ==="
+is "the reason is logged" yes "$(grep -q 'Permission denied' "$work/log" && echo yes || echo no)"
+is "the launch checks the trigger" 1 "$(grep -c '^ if ! install_lsteamclient_trigger; then$' "$SRC")"
+env bridge_src="$work/bridge" WINEPREFIX="$prefix" log="$work/log" bridge_cache="" trigger="$trigger" \
+ sh -ec 'eval "$trigger"; if install_lsteamclient_trigger; then echo installed; else echo refused; fi' > "$work/out" 2>&1 || true
+is "a writable prefix gets the trigger" installed "$(cat "$work/out")"
+
+echo "== a legacycompat file that cannot be installed does not stop the launch"
+mkdir -p "$work/bridge/legacycompat" "$work/client/legacycompat"
+printf 'bridge Steam.dll\n' > "$work/bridge/legacycompat/Steam.dll"
+chmod 500 "$work/client/legacycompat"
+: > "$work/log"
+env bridge_src="$work/bridge" STEAM_COMPAT_CLIENT_INSTALL_PATH="$work/client" log="$work/log" \
+ legacy="$legacy" sh -ec 'eval "$legacy"; install_legacycompat; echo reached' > "$work/out" 2>&1 || true
+chmod 700 "$work/client/legacycompat"
+is "the launch goes on" reached "$(cat "$work/out")"
+logged "the failure is logged" "=== could not copy legacycompat/Steam.dll to $work/client/legacycompat/Steam.dll ==="
+is "the reason is logged" yes "$(grep -q 'Permission denied' "$work/log" && echo yes || echo no)"
+
[ "$fails" -eq 0 ] || { echo "==> bridgecheck: $fails failure(s)"; exit 1; }
echo "==> bridgecheck: the bridge stages on fresh, current, stale and incomplete prefixes"