Skip to content

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

fix(security): narrow quarantine removal and place installer components in Swift (#1579)

Raymond Chin23d3658b3d08
diff --git a/README.md b/README.md
index 7688e63..4ca1797 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ Also changed:
- Steam's default compatibility tool is set in `config.vdf`, and Bridgeplay's tools go in `compatibilitytools.d`.
- Steam's Accessibility and input permissions are reset (`tccutil`), so macOS asks again.
- Steam is signed with a local "NotProton Local Signing" keychain identity, or ad hoc, and loses Valve's hardened runtime.
-- The quarantine flag is removed from Steam.app and Bridgeplay's folder, and Wine loaders are re-signed ad hoc where needed.
+- The quarantine flag is removed from Bridgeplay.app and Steam.app once their signatures check out, from the Wine engine once it matches its pins, and from a CrossOver clone once its Wine loader and `ntdll.dll` match theirs (the rest of the clone isn't checked file by file). Wine loaders are re-signed ad hoc where needed.
- Optional **Block Steam client updates** (`steam.cfg`) also blocks Steam's security fixes.
- The library loads for every macOS user of a shared `/Applications/Steam.app`.
- In games, Steam calls reach your Mac Steam through Proton's lsteamclient, via an in-memory redirect (`ntdll-patch/`).
diff --git a/SECURITY.md b/SECURITY.md
index bc6363a..1161529 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -26,13 +26,17 @@ user is a hardening request, not a vulnerability, but it is still welcome as an
## Known trade-offs
- Releases are signed with the maintainer's Apple Developer ID (Team AF38EA29BA) and notarized by Apple.
- The installer still removes the quarantine flag from the folders it sets up. Download only from https://bridgeplay.dev or GitHub.
+ Download only from https://bridgeplay.dev or GitHub.
- Steam is re-signed to load Bridgeplay, with a local "NotProton Local Signing" keychain identity or ad hoc,
and loses Valve's hardened runtime.
- `notproton.dylib` loads for every macOS user of a shared `/Applications/Steam.app`.
-- Setup removes quarantine from Steam.app and Bridgeplay's folder, resets Steam's Accessibility,
- PostEvent and ListenEvent approvals (`tccutil`), re-signs Wine loaders ad hoc where needed, and sets
- Steam's default compatibility tool (`config.vdf`).
+- Setup removes quarantine in three places, each after a check. Bridgeplay.app must carry the
+ maintainer's signature and Steam.app Valve's. The Wine engine must match its pinned hashes first. In a
+ CrossOver clone only the Wine loader and `ntdll.dll` are pinned; the rest of the clone isn't checked
+ file by file. macOS refuses to load a quarantined Wine file once Bridgeplay has patched it and signed
+ it ad hoc. Setup also resets Steam's Accessibility, PostEvent and ListenEvent approvals
+ (`tccutil`), re-signs Wine loaders ad hoc where needed, and sets Steam's default compatibility tool
+ (`config.vdf`).
- Optional "Block Steam client updates" (`BootStrapperInhibitUpdateOnLaunch` in `steam.cfg`) also blocks
Steam's security fixes.
- Game calls to Steam's `steamclient` are redirected in memory to Proton's lsteamclient (`ntdll-patch/`).
diff --git a/app/Sources/BridgeplayApp/Model/FreeEngine.swift b/app/Sources/BridgeplayApp/Model/FreeEngine.swift
index 26ba451..28f7e2b 100644
--- a/app/Sources/BridgeplayApp/Model/FreeEngine.swift
+++ b/app/Sources/BridgeplayApp/Model/FreeEngine.swift
@@ -308,7 +308,7 @@ enum FreeEngine {
]
let plist = try PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0)
try plist.write(to: shaped.appending(path: "Contents/Info.plist"))
- RunnerInstaller.scrubDownloadMarkers(at: shaped)
+ RunnerInstaller.clearQuarantine(at: shaped)
let install = CrossOverSource.inspect(bundle: shaped)
guard case .supported(let build) = install.support, build.id == release.build else {
diff --git a/app/Sources/BridgeplayApp/Model/FreeEngineWinecx.swift b/app/Sources/BridgeplayApp/Model/FreeEngineWinecx.swift
index e1a8a3e..fb5c182 100644
--- a/app/Sources/BridgeplayApp/Model/FreeEngineWinecx.swift
+++ b/app/Sources/BridgeplayApp/Model/FreeEngineWinecx.swift
@@ -535,7 +535,7 @@ enum FreeEngineWinecx {
]
let plist = try PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0)
try plist.write(to: shaped.appending(path: "Contents/Info.plist"))
- RunnerInstaller.scrubDownloadMarkers(at: shaped)
+ RunnerInstaller.clearQuarantine(at: shaped)
let install = CrossOverSource.inspect(bundle: shaped)
guard case .supported(let build) = install.support, build.id == release.build else {
diff --git a/app/Sources/BridgeplayApp/Model/RunnerInstaller.swift b/app/Sources/BridgeplayApp/Model/RunnerInstaller.swift
index c85226b..a5fa0b1 100644
--- a/app/Sources/BridgeplayApp/Model/RunnerInstaller.swift
+++ b/app/Sources/BridgeplayApp/Model/RunnerInstaller.swift
@@ -33,6 +33,7 @@ enum RunnerInstaller {
defer { try? fm.removeItem(at: staging) }
try copyPayload(from: install.crossOverRoot, to: staging)
try verifyClone(build: build, root: staging.appending(path: "CrossOver"))
+ clearQuarantine(at: staging.appending(path: "CrossOver"))
guard occupied else {
try fm.moveItem(at: staging, to: target)
return build
@@ -270,10 +271,7 @@ enum RunnerInstaller {
let destination = landing.path(percentEncoded: false)
let cloned = try Shell.run("/bin/cp", ["-c", "-R", source, destination])
- if cloned.status == 0 {
- scrubDownloadMarkers(at: landing)
- return
- }
+ if cloned.status == 0 { return }
try? fm.removeItem(at: landing)
let copied = try Shell.run("/bin/cp", ["-R", source, destination])
@@ -283,13 +281,15 @@ enum RunnerInstaller {
detail: String(localized: "Copying \(source) failed. \(copied.stderr.trimmingCharacters(in: .whitespacesAndNewlines))")
)
}
- scrubDownloadMarkers(at: landing)
}
- static func scrubDownloadMarkers(at payload: URL) {
- for marker in ["com.apple.quarantine", "com.apple.provenance"] {
- _ = try? Shell.run("/usr/bin/xattr", ["-r", "-d", marker, payload.path(percentEncoded: false)])
- }
+ // Only for a tree already checked against its pins: a CrossOver clone, or an engine built
+ // from pinned archives. A browser-downloaded CrossOver, or an engine archive that came in
+ // a browser-downloaded installer zip (tar passes the flag on), leaves quarantine on files
+ // Bridgeplay patches and signs ad hoc, and macOS then refuses to load them. -s keeps xattr
+ // on the links themselves, so a link in the tree can't clear a file outside it.
+ static func clearQuarantine(at tree: URL) {
+ _ = try? Shell.run("/usr/bin/xattr", ["-r", "-s", "-d", "com.apple.quarantine", tree.path(percentEncoded: false)])
}
static func verifyClone(build: RunnerBuild, root: URL) throws {
diff --git a/app/Sources/BridgeplayApp/SetupAssistant.swift b/app/Sources/BridgeplayApp/SetupAssistant.swift
index 31dae7e..f89ac9b 100644
--- a/app/Sources/BridgeplayApp/SetupAssistant.swift
+++ b/app/Sources/BridgeplayApp/SetupAssistant.swift
@@ -213,9 +213,8 @@ final class SetupAssistant {
}
// The one-click installer's components zip, so the app alone is enough: BridgeplayInstallerCore
- // checks its EdDSA signature and Apple's signature on GPTK, then runs its Install.command
- // without the app step. That copies GPTK, the DXMT and DXVK archives and the configs, and
- // installs Steam from Valve when it is missing.
+ // checks its EdDSA signature and Apple's signature on GPTK, then copies GPTK, the DXMT and
+ // DXVK archives and the configs, and installs Steam from Valve when it is missing.
func downloadGPTK() async {
if let refusal = MigrationLaunch.shared.refusal {
message = refusal
@@ -255,7 +254,7 @@ final class SetupAssistant {
meter.clear()
gptkProgress = String(localized: "Installing the Game Porting Toolkit")
try await Task.detached(priority: .userInitiated) {
- try InstallerComponents.install(archive: archive, work: work, status: { AppLog.note("setup: Install.command: \($0)") })
+ try InstallerComponents.install(archive: archive, work: work, status: { AppLog.note("setup: components: \($0)") })
}.value
} catch {
AppLog.note("setup: components failed: \(error.localizedDescription)")
diff --git a/app/Sources/BridgeplayInstaller/InstallerModel.swift b/app/Sources/BridgeplayInstaller/InstallerModel.swift
index 57705ef..3b3916e 100644
--- a/app/Sources/BridgeplayInstaller/InstallerModel.swift
+++ b/app/Sources/BridgeplayInstaller/InstallerModel.swift
@@ -19,7 +19,7 @@ final class InstallerModel {
var paused = false
@ObservationIgnored private var control = InstallerDownloadControl()
@ObservationIgnored private var rate = DownloadRate()
- // Steam downloading inside Install.command, from curl's meter.
+ // Steam downloading during the components step, from curl's meter.
var scriptDownload: InstallerDownloadProgress?
var failure: String?
var openBridgeplay = true
@@ -166,7 +166,7 @@ final class InstallerModel {
componentStatus = nil
try await Task.detached(priority: .userInitiated) {
try InstallerComponents.install(archive: archive, work: work, status: { line in
- InstallerLog.write("Install.command: \(line)")
+ InstallerLog.write("Components: \(line)")
Task { @MainActor [weak self] in self?.componentStatus = Self.status(line); self?.scriptDownload = nil }
}, download: { meter in
Task { @MainActor [weak self] in self?.scriptDownload = meter }
@@ -229,7 +229,7 @@ final class InstallerModel {
} catch { failure = error.localizedDescription; finishing = false }
}
- // Install.command's "==>" steps, in the installer's words.
+ // The components steps (ComponentsPlacement), in the installer's words.
nonisolated static func status(_ line: String) -> String? {
if line.contains("Steam") { return tr("Installing Steam from Valve") }
if line.contains("Game Porting Toolkit") { return tr("Copying Apple's graphics, the engine and settings") }
diff --git a/app/Sources/BridgeplayInstallerCore/ComponentsPlacement.swift b/app/Sources/BridgeplayInstallerCore/ComponentsPlacement.swift
new file mode 100644
index 0000000..0b12c97
--- /dev/null
+++ b/app/Sources/BridgeplayInstallerCore/ComponentsPlacement.swift
@@ -0,0 +1,174 @@
+import CryptoKit
+import Foundation
+
+/// Puts the unpacked components in place: Steam from Valve when it is missing, then Apple's
+/// Game Porting Toolkit, the DXMT and DXVK archives and the default configs. What
+/// Install.command does for its own zip; the zip still carries that script for app versions
+/// that run it, but this app does not.
+struct ComponentsPlacement {
+ /// The `Bridgeplay` folder inside the unpacked components zip.
+ let source: URL
+ var home = FileManager.default.homeDirectoryForCurrentUser
+ var applications = URL(fileURLWithPath: "/Applications")
+ var installSteam: (_ applications: URL, _ download: @escaping @Sendable (InstallerDownloadProgress) -> Void) throws -> Void = ValveSteam.install
+ /// Shows the Setup Assistant again even if an earlier Bridgeplay was dismissed.
+ var resetSetupAssistant: () -> Void = {
+ _ = try? InstallerComponents.run("/usr/bin/defaults", ["delete", "com.bridgeplay.Bridgeplay", "setupAssistantFinished"])
+ }
+ var oldConfs = ComponentsPlacement.oldInstallerConfs
+
+ static let steamStatus = "Installing Steam from Valve"
+ static let copyStatus = "Copying the Game Porting Toolkit, DXMT, DXVK and configs"
+
+ // Installers up to 3.0.1 copied their own per-game confs into the user's gamefixes/,
+ // where they override the shipped defaults. A copy still byte-identical to one of those
+ // was never edited, so it goes; an edited one stays.
+ static let oldInstallerConfs = [
+ "1422450": "3ec703897532711d09717384333bce001642c16e9b33875e20f685af8fd09279",
+ "3669870": "e5aa727e1f42de9db3a0975a1837974334dd3691fab13138b299902a68737f02",
+ "3764200": "fef67384fb54b17d0f9818273f09548b699186e320eeae933b388f3b0aeda02f",
+ ]
+
+ func place(status: @escaping @Sendable (String) -> Void = { _ in },
+ download: @escaping @Sendable (InstallerDownloadProgress) -> Void = { _ in }) throws {
+ let fm = FileManager.default
+ if !fm.fileExists(atPath: applications.appending(path: "Steam.app").path) {
+ status(Self.steamStatus)
+ try installSteam(applications, download)
+ }
+
+ status(Self.copyStatus)
+ let (support, caches) = folders()
+ for folder in [support.appending(path: "gamefixes"), support.appending(path: "gamefixes-default"),
+ support.appending(path: ".installer"), caches] {
+ try fail("Bridgeplay's folders in Library could not be made.") {
+ try fm.createDirectory(at: folder, withIntermediateDirectories: true)
+ }
+ }
+
+ // Copied beside the old one first, so a failed copy leaves the working toolkit alone.
+ try fail("The Game Porting Toolkit could not be copied.") {
+ try Self.put(source.appending(path: "gptk"), at: support.appending(path: "gptk"))
+ }
+ // Bridgeplay reuses any cached file whose hash matches its pin, so DXMT and DXVK are
+ // not downloaded again. The WineCX runtime is not in the zip; the app downloads it.
+ try fail("The engine files could not be copied.") {
+ try InstallerComponents.run("/usr/bin/ditto", [source.appending(path: "cache").path, caches.path])
+ }
+
+ // Per-game confs are Bridgeplay's shipped defaults. They go to gamefixes-default/,
+ // which the app owns and refreshes on every update; the user's gamefixes/ holds only
+ // their overrides, and its default.conf is never written here.
+ let defaults = source.appending(path: "config/gamefixes-default")
+ let confs = (try? fm.contentsOfDirectory(at: defaults, includingPropertiesForKeys: nil)) ?? []
+ for conf in confs where conf.pathExtension == "conf" {
+ try fail("A game config could not be copied.") {
+ try Self.put(conf, at: support.appending(path: "gamefixes-default/\(conf.lastPathComponent)"))
+ }
+ }
+ for (appid, sha256) in oldConfs {
+ let old = support.appending(path: "gamefixes/\(appid).conf")
+ guard let data = fm.contents(atPath: old.path), Self.hex(SHA256.hash(data: data)) == sha256 else { continue }
+ try fail("An old game config could not be removed: \(old.path)") {
+ do { try fm.removeItem(at: old) } catch where !fm.fileExists(atPath: old.path) {}
+ }
+ }
+
+ // The user's own controller mappings: only seeded when there are none yet.
+ let mappings = support.appending(path: "gamecontrollerdb.txt")
+ if !fm.fileExists(atPath: mappings.path) {
+ try fail("gamecontrollerdb.txt could not be copied.") {
+ try Self.put(source.appending(path: "config/gamecontrollerdb.txt"), at: mappings, replacing: false)
+ }
+ }
+ resetSetupAssistant()
+ }
+
+ // Bridgeplay before 3.0.0 kept its files under "notproton". The app moves them to
+ // "bridgeplay" itself on first launch (with a backup); while only the old folders exist,
+ // the files go there so that move carries them along.
+ func folders() -> (support: URL, caches: URL) {
+ let library = home.appending(path: "Library")
+ func pick(_ parent: String) -> URL {
+ let current = library.appending(path: "\(parent)/bridgeplay"), legacy = library.appending(path: "\(parent)/notproton")
+ let fm = FileManager.default
+ return !fm.fileExists(atPath: current.path) && fm.fileExists(atPath: legacy.path) ? legacy : current
+ }
+ return (pick("Application Support"), pick("Caches"))
+ }
+
+ // Copies to a name unique to this run beside the target, then swaps it in atomically, so the
+ // installer and the app's Setup Assistant placing at once never leave a target missing or
+ // half-written. With replacing false, a target that appeared meanwhile is kept.
+ static func put(_ source: URL, at target: URL, replacing: Bool = true) throws {
+ let fm = FileManager.default
+ let staged = target.deletingLastPathComponent().appending(path: ".\(target.lastPathComponent)-\(UUID().uuidString)")
+ defer { try? fm.removeItem(at: staged) }
+ try InstallerComponents.run("/usr/bin/ditto", [source.path, staged.path])
+ do { try fm.moveItem(at: staged, to: target) }
+ catch where fm.fileExists(atPath: target.path) {
+ if replacing { _ = try fm.replaceItemAt(target, withItemAt: staged) }
+ }
+ }
+
+ static func hex(_ digest: SHA256.Digest) -> String { digest.map { String(format: "%02x", $0) }.joined() }
+
+ private func fail(_ message: String, _ body: () throws -> Void) throws {
+ do { try body() } catch { throw InstallerError.componentsFailure(message) }
+ }
+}
+
+/// Steam from Valve's CDN, installed only when Valve's signature on it checks out.
+enum ValveSteam {
+ static let url = URL(string: "https://cdn.cloudflare.steamstatic.com/client/installer/steam.dmg")!
+ /// The trust chain, Valve's Team ID and Steam's bundle identifier, checked as one requirement.
+ static let requirement = #"=anchor apple generic and certificate leaf[subject.OU] = "MXGJJ98X76" and identifier "com.valvesoftware.steam""#
+
+ static func install(into applications: URL, download: @escaping @Sendable (InstallerDownloadProgress) -> Void) throws {
+ let fm = FileManager.default
+ let work = fm.temporaryDirectory.appending(path: "bridgeplay-steam-\(UUID().uuidString)")
+ try fm.createDirectory(at: work, withIntermediateDirectories: true)
+ defer { try? fm.removeItem(at: work) }
+ let dmg = work.appending(path: "steam.dmg"), mount = work.appending(path: "mnt")
+
+ do {
+ try InstallerComponents.run("/usr/bin/curl", ["-fL", "--retry", "3", "--connect-timeout", "20",
+ "-o", dmg.path, url.absoluteString]) { line in
+ if let meter = InstallerDownloadProgress(curlMeter: line) { download(meter) }
+ }
+ } catch {
+ throw InstallerError.componentsFailure("Steam could not be downloaded. Check the internet connection and try again.")
+ }
+ // A UDIF disk image ends with a 512-byte trailer that starts with "koly".
+ guard isDiskImage(dmg) else {
+ throw InstallerError.componentsFailure("The Steam download is not Valve's installer. Try again later.")
+ }
+ try fm.createDirectory(at: mount, withIntermediateDirectories: true)
+ do {
+ try InstallerComponents.run("/usr/bin/hdiutil", ["attach", "-nobrowse", "-readonly", "-noautoopen", "-quiet",
+ "-mountpoint", mount.path, dmg.path])
+ } catch {
+ throw InstallerError.componentsFailure("The Steam installer could not be opened.")
+ }
+ defer { _ = try? InstallerComponents.run("/usr/bin/hdiutil", ["detach", "-quiet", mount.path]) }
+ let steam = mount.appending(path: "Steam.app")
+ guard (try? InstallerComponents.run("/usr/bin/codesign", ["--verify", "--strict", "-R", requirement, steam.path])) != nil else {
+ throw InstallerError.componentsFailure("The Steam download is not signed by Valve, so it was not installed.")
+ }
+ // Staged under its own name, so a failed copy never leaves a half-copied Steam.app that
+ // would pass as installed, and never removes one another placement put there meanwhile.
+ do {
+ try ComponentsPlacement.put(steam, at: applications.appending(path: "Steam.app"), replacing: false)
+ } catch {
+ throw InstallerError.componentsFailure("Steam could not be copied to Applications.")
+ }
+ }
+
+ static func isDiskImage(_ file: URL) -> Bool {
+ guard let handle = try? FileHandle(forReadingFrom: file) else { return false }
+ defer { try? handle.close() }
+ guard let size = try? handle.seekToEnd(), size >= 512 else { return false }
+ try? handle.seek(toOffset: size - 512)
+ return (try? handle.read(upToCount: 4)) == Data("koly".utf8)
+ }
+}
diff --git a/app/Sources/BridgeplayInstallerCore/InstallerComponents.swift b/app/Sources/BridgeplayInstallerCore/InstallerComponents.swift
index a6a72a1..509685a 100644
--- a/app/Sources/BridgeplayInstallerCore/InstallerComponents.swift
+++ b/app/Sources/BridgeplayInstallerCore/InstallerComponents.swift
@@ -2,9 +2,9 @@ import Foundation
/// Apple's Game Porting Toolkit, DXMT, DXVK and the default configs (not WineCX, which the
/// app downloads from dappermint): the one-click
-/// installer ZIP on the `installer` release, which Install.command inside it puts in place.
-/// The wizard downloads it only when this Mac lacks them, checks it against the same EdDSA
-/// key as the app, then runs that Install.command without the app step and without Terminal.
+/// installer ZIP on the `installer` release. The wizard downloads it only when this Mac lacks
+/// them, checks it against the same EdDSA key as the app, then puts its contents in place
+/// itself (ComponentsPlacement) rather than running the Install.command inside it.
public struct InstallerComponents: Sendable, Equatable {
public static let archiveURL = URL(
string: "https://github.com/raymondchins/Bridgeplay/releases/download/installer/Bridgeplay-Installer.zip"
@@ -120,26 +120,25 @@ public struct InstallerComponents: Sendable, Equatable {
try InstallerRelease.verify(data, signature: signature, publicKey: verificationKey)
}
- /// Unpack the verified archive and run its Install.command for Steam, GPTK, the engine and
- /// the configs. `status` gets each "==>" step the script announces.
+ /// Unpack the verified archive and put Steam, GPTK, the engine archives and the configs in
+ /// place (ComponentsPlacement). `status` gets each step as it starts.
public static func install(archive: URL, work: URL, status: @escaping @Sendable (String) -> Void = { _ in },
download: @escaping @Sendable (InstallerDownloadProgress) -> Void = { _ in }) throws {
+ try install(archive: archive, work: work, status: status, download: download) { _ in }
+ }
+
+ static func install(archive: URL, work: URL, status: @escaping @Sendable (String) -> Void,
+ download: @escaping @Sendable (InstallerDownloadProgress) -> Void,
+ configure: (inout ComponentsPlacement) -> Void) throws {
let unpacked = work.appending(path: "components")
try? FileManager.default.removeItem(at: unpacked)
try FileManager.default.createDirectory(at: unpacked, withIntermediateDirectories: true)
try run("/usr/bin/ditto", ["-x", "-k", archive.path, unpacked.path])
- let script = unpacked.appending(path: "Bridgeplay/Install.command")
- guard FileManager.default.isReadableFile(atPath: script.path) else {
- throw InstallerError.invalidInstallation("The components download has no Install.command.")
- }
- try verifyAppleSigned(gptk: unpacked.appending(path: "Bridgeplay/gptk"))
- var environment = ProcessInfo.processInfo.environment
- environment["BRIDGEPLAY_INSTALL_APP"] = "0"
- environment["BRIDGEPLAY_NONINTERACTIVE"] = "1"
- try run("/bin/bash", [script.path], environment: environment) { line in
- if line.hasPrefix("==> ") { status(String(line.dropFirst(4))) }
- else if let meter = InstallerDownloadProgress(curlMeter: line) { download(meter) }
- }
+ let source = unpacked.appending(path: "Bridgeplay")
+ try verifyAppleSigned(gptk: source.appending(path: "gptk"))
+ var placement = ComponentsPlacement(source: source)
+ configure(&placement)
+ try placement.place(status: status, download: download)
}
/// GPTK ships unmodified: D3DMetal.framework and every other Mach-O file must carry Apple's
diff --git a/app/Sources/BridgeplayInstallerCore/InstallerRelease.swift b/app/Sources/BridgeplayInstallerCore/InstallerRelease.swift
index cd0e18c..a165179 100644
--- a/app/Sources/BridgeplayInstallerCore/InstallerRelease.swift
+++ b/app/Sources/BridgeplayInstallerCore/InstallerRelease.swift
@@ -13,7 +13,7 @@ public struct InstallerDownloadProgress: Sendable, Equatable {
self.speed = speed
}
- /// One line of curl's progress meter, which Install.command shows while it downloads Steam:
+ /// One line of curl's progress meter, shown while the components step downloads Steam:
/// " 45 4200k 45 1890k 0 0 2105k 0 0:00:01 0:00:00 0:00:01 2105k"
public init?(curlMeter line: String) {
let fields = line.split(separator: " ")
diff --git a/app/Tests/BridgeplayAppTests/RunnerInstallerTests.swift b/app/Tests/BridgeplayAppTests/RunnerInstallerTests.swift
index a167188..40b5197 100644
--- a/app/Tests/BridgeplayAppTests/RunnerInstallerTests.swift
+++ b/app/Tests/BridgeplayAppTests/RunnerInstallerTests.swift
@@ -38,6 +38,49 @@ struct RunnerInstallerTests {
#expect(RunnerInstaller.hasClone(forBuild: version, runners: runners))
}
+ @Test("Clearing quarantine leaves the tree's other attributes alone")
+ func clearQuarantineOnlyRemovesQuarantine() throws {
+ let runners = try makeRunners()
+ defer { try? FileManager.default.removeItem(at: runners) }
+ let file = runners.appending(path: "lib/wine/ntdll.so")
+ try FileManager.default.createDirectory(at: file.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try Data("so".utf8).write(to: file)
+ try Shell.check("/usr/bin/xattr", ["-w", "com.apple.quarantine", "0083;6a2b3c4d;Safari;", file.path(percentEncoded: false)])
+ try Shell.check("/usr/bin/xattr", ["-w", "com.bridgeplay.keep", "1", file.path(percentEncoded: false)])
+
+ RunnerInstaller.clearQuarantine(at: runners)
+
+ let left = try Shell.run("/usr/bin/xattr", [file.path(percentEncoded: false)]).stdout
+ #expect(!left.contains("com.apple.quarantine"))
+ #expect(left.contains("com.bridgeplay.keep"))
+ }
+
+ @Test("Clearing quarantine doesn't follow links out of the tree")
+ func clearQuarantineStaysInsideTree() throws {
+ let runners = try makeRunners()
+ defer { try? FileManager.default.removeItem(at: runners) }
+ let tree = runners.appending(path: "tree")
+ let outside = runners.appending(path: "outside")
+ let outsideFile = outside.appending(path: "lib.dylib")
+ let lonelyFile = runners.appending(path: "lonely.dylib")
+ try FileManager.default.createDirectory(at: tree, withIntermediateDirectories: true)
+ try FileManager.default.createDirectory(at: outside, withIntermediateDirectories: true)
+ try Data("dylib".utf8).write(to: outsideFile)
+ try Data("dylib".utf8).write(to: lonelyFile)
+ for target in [outside, outsideFile, lonelyFile] {
+ try Shell.check("/usr/bin/xattr", ["-w", "com.apple.quarantine", "0083;6a2b3c4d;Safari;", target.path(percentEncoded: false)])
+ }
+ try FileManager.default.createSymbolicLink(at: tree.appending(path: "dir"), withDestinationURL: outside)
+ try FileManager.default.createSymbolicLink(at: tree.appending(path: "file.dylib"), withDestinationURL: lonelyFile)
+
+ RunnerInstaller.clearQuarantine(at: tree)
+
+ for target in [outside, outsideFile, lonelyFile] {
+ let left = try Shell.run("/usr/bin/xattr", [target.path(percentEncoded: false)]).stdout
+ #expect(left.contains("com.apple.quarantine"), "\(target.lastPathComponent) lost its quarantine")
+ }
+ }
+
// A CrossOver bundle holding only the files the clone path hashes, with the build describing
// those exact bytes, so verification passes without a real 1.2G install to copy.
private func makeSupportedInstall(
diff --git a/app/Tests/BridgeplayInstallerCoreTests/ComponentsPlacementTests.swift b/app/Tests/BridgeplayInstallerCoreTests/ComponentsPlacementTests.swift
new file mode 100644
index 0000000..edbe0ad
--- /dev/null
+++ b/app/Tests/BridgeplayInstallerCoreTests/ComponentsPlacementTests.swift
@@ -0,0 +1,168 @@
+import CryptoKit
+import Foundation
+import Testing
+@testable import BridgeplayInstallerCore
+
+@Suite("Placing the installer components")
+struct ComponentsPlacementTests {
+ private final class Calls: @unchecked Sendable {
+ var steam: [URL] = []
+ var resets = 0
+ var statuses: [String] = []
+ }
+
+ private struct Fixture {
+ let root: URL, source: URL, home: URL, applications: URL
+ var support: URL { home.appending(path: "Library/Application Support/bridgeplay") }
+ var caches: URL { home.appending(path: "Library/Caches/bridgeplay") }
+ }
+
+ private func fixture(steam: Bool = true) throws -> Fixture {
+ let fm = FileManager.default
+ let root = fm.temporaryDirectory.appending(path: "placement-\(UUID().uuidString)")
+ let source = root.appending(path: "Bridgeplay")
+ let files = [
+ "gptk/external/libd3dshared.dylib": "new gptk",
+ "cache/engines/dxmt.tar.gz": "dxmt",
+ "config/gamefixes-default/default.conf": "SHIPPED=1\n",
+ "config/gamefixes-default/448510.conf": "BACKEND=dxmt\n",
+ "config/gamefixes-default/notes.txt": "not a conf",
+ "config/gamecontrollerdb.txt": "shipped mappings",
+ ]
+ for (path, text) in files {
+ let url = source.appending(path: path)
+ try fm.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try Data(text.utf8).write(to: url)
+ }
+ let applications = root.appending(path: "Applications")
+ try fm.createDirectory(at: applications.appending(path: steam ? "Steam.app" : "Other.app"), withIntermediateDirectories: true)
+ let home = root.appending(path: "home")
+ try fm.createDirectory(at: home, withIntermediateDirectories: true)
+ return Fixture(root: root, source: source, home: home, applications: applications)
+ }
+
+ private func placement(_ f: Fixture, _ calls: Calls) -> ComponentsPlacement {
+ var placement = ComponentsPlacement(source: f.source)
+ placement.home = f.home
+ placement.applications = f.applications
+ placement.installSteam = { applications, _ in calls.steam.append(applications) }
+ placement.resetSetupAssistant = { calls.resets += 1 }
+ return placement
+ }
+
+ private func text(_ url: URL) -> String? {
+ FileManager.default.contents(atPath: url.path).map { String(decoding: $0, as: UTF8.self) }
+ }
+
+ @Test("A fresh Mac gets GPTK, the engine archives, the shipped confs and the mappings")
+ func freshMac() throws {
+ let f = try fixture()
+ defer { try? FileManager.default.removeItem(at: f.root) }
+ let calls = Calls()
+ try placement(f, calls).place(status: { calls.statuses.append($0) })
+
+ #expect(text(f.support.appending(path: "gptk/external/libd3dshared.dylib")) == "new gptk")
+ #expect(text(f.caches.appending(path: "engines/dxmt.tar.gz")) == "dxmt")
+ #expect(text(f.support.appending(path: "gamefixes-default/448510.conf")) == "BACKEND=dxmt\n")
+ #expect(!FileManager.default.fileExists(atPath: f.support.appending(path: "gamefixes-default/notes.txt").path))
+ // The user's own default.conf is never written.
+ #expect(!FileManager.default.fileExists(atPath: f.support.appending(path: "gamefixes/default.conf").path))
+ #expect(FileManager.default.fileExists(atPath: f.support.appending(path: ".installer").path))
+ #expect(text(f.support.appending(path: "gamecontrollerdb.txt")) == "shipped mappings")
+ #expect(calls.steam.isEmpty)
+ #expect(calls.resets == 1)
+ #expect(calls.statuses == [ComponentsPlacement.copyStatus])
+ }
+
+ @Test("Steam is installed first only when Applications has none")
+ func steamWhenMissing() throws {
+ let f = try fixture(steam: false)
+ defer { try? FileManager.default.removeItem(at: f.root) }
+ let calls = Calls()
+ try placement(f, calls).place(status: { calls.statuses.append($0) })
+ #expect(calls.steam == [f.applications])
+ #expect(calls.statuses == [ComponentsPlacement.steamStatus, ComponentsPlacement.copyStatus])
+ }
+
+ @Test("A failed Steam install stops before anything is copied")
+ func steamFailure() throws {
+ let f = try fixture(steam: false)
+ defer { try? FileManager.default.removeItem(at: f.root) }
+ var placement = placement(f, Calls())
+ placement.installSteam = { _, _ in throw InstallerError.componentsFailure("no Steam") }
+ #expect(throws: InstallerError.self) { try placement.place() }
+ #expect(!FileManager.default.fileExists(atPath: f.support.appending(path: "gptk").path))
+ }
+
+ @Test("An older GPTK is replaced whole, and the user's mappings and edited confs stay")
+ func update() throws {
+ let f = try fixture()
+ defer { try? FileManager.default.removeItem(at: f.root) }
+ let fm = FileManager.default
+ for (path, text) in ["gptk/stale.dylib": "old", "gamecontrollerdb.txt": "my mappings",
+ "gamefixes/111.conf": "untouched copy", "gamefixes/222.conf": "edited copy",
+ "gamefixes-default/448510.conf": "BACKEND=d3dmetal\n"] {
+ let url = f.support.appending(path: path)
+ try fm.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try Data(text.utf8).write(to: url)
+ }
+ var placement = placement(f, Calls())
+ placement.oldConfs = ["111": ComponentsPlacement.hex(SHA256.hash(data: Data("untouched copy".utf8))),
+ "222": ComponentsPlacement.hex(SHA256.hash(data: Data("original copy".utf8)))]
+ try placement.place()
+
+ #expect(!fm.fileExists(atPath: f.support.appending(path: "gptk/stale.dylib").path))
+ #expect(try fm.contentsOfDirectory(atPath: f.support.path).filter { $0.hasPrefix(".gptk-") }.isEmpty)
+ #expect(text(f.support.appending(path: "gamecontrollerdb.txt")) == "my mappings")
+ #expect(!fm.fileExists(atPath: f.support.appending(path: "gamefixes/111.conf").path))
+ #expect(text(f.support.appending(path: "gamefixes/222.conf")) == "edited copy")
+ #expect(text(f.support.appending(path: "gamefixes-default/448510.conf")) == "BACKEND=dxmt\n")
+ }
+
+ @Test("Two placements at once both succeed and leave one whole toolkit")
+ func concurrentPlacements() throws {
+ let f = try fixture()
+ defer { try? FileManager.default.removeItem(at: f.root) }
+ var placement = placement(f, Calls())
+ // Shared by the workers below, so it must not touch the unlocked call counters.
+ placement.resetSetupAssistant = {}
+ try placement.place()
+ nonisolated(unsafe) let shared = placement
+ nonisolated(unsafe) var failures: [Error] = []
+ let lock = NSLock()
+ DispatchQueue.concurrentPerform(iterations: 4) { _ in
+ do { try shared.place() } catch { lock.withLock { failures.append(error) } }
+ }
+ #expect(failures.isEmpty, "\(failures)")
+ #expect(text(f.support.appending(path: "gptk/external/libd3dshared.dylib")) == "new gptk")
+ #expect(try FileManager.default.contentsOfDirectory(atPath: f.support.path).filter { $0.hasPrefix(".gptk-") }.isEmpty)
+ }
+
+ @Test("While only the notproton folders exist, the files go there for the app's own move")
+ func legacyFolders() throws {
+ let f = try fixture()
+ defer { try? FileManager.default.removeItem(at: f.root) }
+ let library = f.home.appending(path: "Library")
+ for legacy in ["Application Support/notproton", "Caches/notproton"] {
+ try FileManager.default.createDirectory(at: library.appending(path: legacy), withIntermediateDirectories: true)
+ }
+ try placement(f, Calls()).place()
+ #expect(text(library.appending(path: "Application Support/notproton/gptk/external/libd3dshared.dylib")) == "new gptk")
+ #expect(text(library.appending(path: "Caches/notproton/engines/dxmt.tar.gz")) == "dxmt")
+ #expect(!FileManager.default.fileExists(atPath: f.support.path))
+ }
+
+ @Test("Only a file ending in a UDIF trailer passes as Valve's disk image")
+ func diskImage() throws {
+ let dir = FileManager.default.temporaryDirectory.appending(path: "koly-\(UUID().uuidString)")
+ try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
+ defer { try? FileManager.default.removeItem(at: dir) }
+ let good = dir.appending(path: "good.dmg"), bad = dir.appending(path: "bad.dmg"), short = dir.appending(path: "short.dmg")
+ try (Data(repeating: 0, count: 1000) + Data("koly".utf8) + Data(repeating: 0, count: 508)).write(to: good)
+ try Data(repeating: 0, count: 2000).write(to: bad)
+ try Data("koly".utf8).write(to: short)
+ #expect(ValveSteam.isDiskImage(good))
+ #expect(!ValveSteam.isDiskImage(bad))
+ #expect(!ValveSteam.isDiskImage(short))
+ }
+}
diff --git a/docs/NATIVE-INSTALLER.md b/docs/NATIVE-INSTALLER.md
index 19ae447..16d59aa 100644
--- a/docs/NATIVE-INSTALLER.md
+++ b/docs/NATIVE-INSTALLER.md
@@ -5,9 +5,10 @@ or updates `/Applications/Bridgeplay.app`. It downloads the app from the release
Bridgeplay's Sparkle feed and checks its EdDSA signature before extracting it. On a Mac
without Game Porting Toolkit or Steam it also downloads the one-click installer zip
(`Bridgeplay-Installer.zip` on the `installer` release, signature in the `.sig` beside it),
-checks it against the same key, and runs its `Install.command` without the app step and
-without Terminal. That zip carries GPTK, DXMT, DXVK and the default configs, not Wine: the app
-downloads the WineCX runtime from dappermint/winecx-gptk during its Setup Assistant (see
+checks it against the same key, and puts its contents in place itself
+(`ComponentsPlacement` in `BridgeplayInstallerCore`), without running the `Install.command` the
+zip still carries for older app versions. That zip carries GPTK, DXMT, DXVK and the default
+configs, not Wine: the app downloads the WineCX runtime from dappermint/winecx-gptk during its Setup Assistant (see
[NOTICE](../NOTICE)). Discussion: [issue #17](https://github.com/raymondchins/Bridgeplay/issues/17).
## Build
@@ -47,16 +48,18 @@ rotated by rename before replacement. Retired copies owned by another account or
read-only directories stay intact as `.Bridgeplay.app.previous-<UUID>` siblings; an
administrator can remove them in Finder. They do not block subsequent updates.
-Prefixes, saves and Steam libraries are never touched. The components step writes only what
-`Install.command` writes (`gptk/`, `gamefixes-default/`, the cached DXMT/DXVK archives, and
-`default.conf` unless the user edited it; see [installer/README.md](../installer/README.md)).
+Prefixes, saves and Steam libraries are never touched. The components step writes `gptk/`,
+`gamefixes-default/`, the cached DXMT/DXVK archives, and `gamecontrollerdb.txt` when there is
+none yet. It never writes the user's `gamefixes/default.conf`, and from `gamefixes/` it removes
+only per-game confs still identical to ones earlier installers copied there (see
+[installer/README.md](../installer/README.md)).
Opening the installed app continues its Setup Assistant, which downloads the WineCX engine
and sets up Steam. Neither installer changes Sparkle's update feed.
Bridgeplay.app does not need either installer. Its Setup Assistant's Graphics step offers
Download, which fetches the same `Bridgeplay-Installer.zip` through `BridgeplayInstallerCore`
-(EdDSA check, then Apple's signature on every Mach-O file in `gptk/`) and runs its
-`Install.command` without the app step, so a Mac with only the app gets the same files.
+(EdDSA check, then Apple's signature on every Mach-O file in `gptk/`) and puts it in
+place the same way, so a Mac with only the app gets the same files.
On Finish, users may open Bridgeplay. When the installer was started from a mounted disk
image that `hdiutil` identifies exactly, it also offers to eject the image and move it to
diff --git a/gamefixes/448510.conf b/gamefixes/448510.conf
new file mode 100644
index 0000000..549af33
--- /dev/null
+++ b/gamefixes/448510.conf
@@ -0,0 +1,4 @@
+# Overcooked (448510)
+# Evidence: on WineCX 11.17 (M5 Max, 2026-10-29) D3DMetal draws every frame solid magenta, which in
+# a Unity game means its shaders failed. DXMT draws the game correctly, so use it for this D3D11 game.
+BACKEND=dxmt
diff --git a/installer/Install.command b/installer/Install.command
index afa4c27..88320d1 100755
--- a/installer/Install.command
+++ b/installer/Install.command
@@ -63,8 +63,6 @@ cleanup() {
}
trap cleanup EXIT
-xattr -dr com.apple.quarantine "$here" 2>/dev/null || true
-
[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" = "1" ] || die "Mac ini bukan Apple Silicon (M1/M2/M3/...). Bridgeplay tidak jalan di Mac Intel."
major="$(sw_vers -productVersion | cut -d. -f1)"
[ "$major" -ge 26 ] || die "Butuh macOS 26 atau lebih baru (sekarang $(sw_vers -productVersion)). Update macOS dulu."
@@ -163,7 +161,6 @@ done
if [ ! -f "$support/gamecontrollerdb.txt" ]; then
cp "$here/config/gamecontrollerdb.txt" "$support/" || die "gamecontrollerdb.txt gagal disalin."
fi
-xattr -dr com.apple.quarantine "$support" 2>/dev/null || true
# Show the Setup Assistant again even if an earlier Bridgeplay was dismissed.
defaults delete com.bridgeplay.Bridgeplay setupAssistantFinished >/dev/null 2>&1 || true
diff --git a/installer/README.md b/installer/README.md
index 36cd8bc..bf4b84b 100644
--- a/installer/README.md
+++ b/installer/README.md
@@ -6,9 +6,11 @@ configs from the folder it sits in, downloads Steam from Valve's CDN when
`/Applications/Steam.app` is missing, then opens the app's Setup Assistant. The Setup
Assistant downloads the WineCX engine (dappermint/winecx-gptk's runtime) itself: the zip does
not carry it, because it bundles GPL libraries whose source neither project publishes (see
-`NOTICE`). `Bridgeplay Installer.app` runs the same script without the app step
-([docs/NATIVE-INSTALLER.md](../docs/NATIVE-INSTALLER.md)), and so does the app's own Setup
-Assistant when the user presses Download in its Graphics step.
+`NOTICE`). `Bridgeplay Installer.app` and the app's own Setup Assistant (Download in its
+Graphics step) no longer run this script: `ComponentsPlacement` in `BridgeplayInstallerCore`
+does the same steps without the app step ([docs/NATIVE-INSTALLER.md](../docs/NATIVE-INSTALLER.md)).
+The zip still carries the script for app versions before that, so a change to one belongs in
+the other.
Before copying Steam, `Install.command` verifies its strict code signature against Apple's
trust chain, Valve's Team ID, and the `com.valvesoftware.steam` bundle identifier.