Skip to content

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

fix(keeper): keep reporting a broken Steam signature (#2068)

Raymond Chin96c5f1a0be1a
diff --git a/app/Sources/BridgeplayApp/Model/SteamInstaller.swift b/app/Sources/BridgeplayApp/Model/SteamInstaller.swift
index a2cfadb..30af7fa 100644
--- a/app/Sources/BridgeplayApp/Model/SteamInstaller.swift
+++ b/app/Sources/BridgeplayApp/Model/SteamInstaller.swift
@@ -41,6 +41,8 @@ struct InstallOutcome: Sendable {
// Input access services macOS refused to reset after Steam's signature changed. nil when
// the signature didn't change, so no reset ran.
var failedInputResets: [String]?
+ // Steam's signature is broken and only another account can sign it again.
+ var sealWarning: String?
}
enum SteamInstaller {
@@ -154,7 +156,9 @@ enum SteamInstaller {
try verifyRunner(build, SupportPaths.clonedRoot(forBuild: build.id, runners: runners))
}
try modifications.mark(app)
- let patching = try needsPatching(plist: plist, dylib: dylib, shipping: payload.dylib, app: app)
+ var sealWarning: String?
+ let patching = try needsPatching(plist: plist, dylib: dylib, shipping: payload.dylib, app: app,
+ onBrokenSeal: { sealWarning = $0 })
let replacingFiles = try files.contains {
try $0.needsClientStopped && !$0.matches() && FileManager.default.fileExists(atPath: $0.destination.path(percentEncoded: false))
}
@@ -267,7 +271,8 @@ enum SteamInstaller {
build: build,
signatureDatabases: payload.signatures.count,
backedUpPlist: backedUp,
- failedInputResets: failedInputResets
+ failedInputResets: failedInputResets,
+ sealWarning: sealWarning
)
}
@@ -350,7 +355,11 @@ enum SteamInstaller {
}
}
- static func needsPatching(plist: URL, dylib: URL, shipping: URL, app: URL) throws -> Bool {
+ static func needsPatching(
+ plist: URL, dylib: URL, shipping: URL, app: URL,
+ checkWritable: (URL) throws -> Void = assertBundleIsWritable,
+ onBrokenSeal: (String) -> Void = { _ in }
+ ) throws -> Bool {
let deployed = SteamBundle.currentInsert(at: plist) == dylib.path(percentEncoded: false)
&& SteamBundle.currentControllerBlock(at: plist) == SteamBundle.controllerBlockValue
let file = DeploymentContent.File(source: shipping, destination: dylib, name: "notproton.dylib", allowsResigning: true)
@@ -361,10 +370,13 @@ enum SteamInstaller {
}
// Signing failed and the plist could not be put back (#1931): sign it again.
do {
- try assertBundleIsWritable(app)
+ try checkWritable(app)
} catch let refusal as WriteRefused {
guard let detail = brokenSealDetail(refusal.remedy) else { throw refusal }
- throw StepFailure(step: step, detail: detail)
+ // This account's own install doesn't depend on the seal, so it carries on.
+ AppLog.note("install: Steam's signature no longer matches and this account can't sign it")
+ onBrokenSeal(detail)
+ return false
}
return true
}
diff --git a/app/Sources/BridgeplayApp/Model/SteamPatchKeeper.swift b/app/Sources/BridgeplayApp/Model/SteamPatchKeeper.swift
index dc45e98..f72ffdd 100644
--- a/app/Sources/BridgeplayApp/Model/SteamPatchKeeper.swift
+++ b/app/Sources/BridgeplayApp/Model/SteamPatchKeeper.swift
@@ -68,6 +68,15 @@ enum SteamPatchKeeper {
return .reapply(kind)
}
+ // A failed re-apply can leave the insert in a bundle it never signed, which reads as
+ // installed, so the failure stands until the signature is good again.
+ static func failureStands(
+ _ deployment: SteamDeployment, lastAttemptFailed: Bool, sealIsIntact: () -> Bool
+ ) -> Bool {
+ guard lastAttemptFailed, case .installed = deployment else { return false }
+ return !sealIsIntact()
+ }
+
// Reads only what decide() needs: the plist, two process lists and one small file.
static func capture(
bundledVersion: String,
diff --git a/app/Sources/BridgeplayApp/SetupAssistant.swift b/app/Sources/BridgeplayApp/SetupAssistant.swift
index 8b585f9..ea540d8 100644
--- a/app/Sources/BridgeplayApp/SetupAssistant.swift
+++ b/app/Sources/BridgeplayApp/SetupAssistant.swift
@@ -375,7 +375,7 @@ final class SetupAssistant {
set("steam", .running)
await status.installIntoSteam()
- if let failure = status.failure {
+ if let failure = status.failure, status.sealWarning == nil {
if status.failureRemedy == .appManagement {
askForAppManagement(status)
} else if let tool = (status.lastRunError as? SteamInstaller.ForeignInsert)?.tool {
@@ -411,6 +411,8 @@ final class SetupAssistant {
return
}
+ // The later steps cleared it, so the Status page shows it again after Setup.
+ if let warning = status.sealWarning { status.setFailure(warning) }
UserDefaults.standard.set(true, forKey: Self.finishedKey)
step = .done
}
diff --git a/app/Sources/BridgeplayApp/Support/InstallIntoSteamCommand.swift b/app/Sources/BridgeplayApp/Support/InstallIntoSteamCommand.swift
index 5123de1..b1ca904 100644
--- a/app/Sources/BridgeplayApp/Support/InstallIntoSteamCommand.swift
+++ b/app/Sources/BridgeplayApp/Support/InstallIntoSteamCommand.swift
@@ -34,6 +34,7 @@ enum InstallIntoSteamCommand {
try SteamInstaller.finish(result)
UserDefaults.standard.removeObject(forKey: SteamPatchKeeper.pausedKey)
say("Bridgeplay \(ProductVersion.short) installed into Steam.")
+ if let warning = result.sealWarning { say(warning) }
return 0
} catch {
AppLog.note("command line failed: \(RemoveEverythingCommand.failureMessage(error))")
diff --git a/app/Sources/BridgeplayApp/SystemStatus.swift b/app/Sources/BridgeplayApp/SystemStatus.swift
index 1675f51..ff649fd 100644
--- a/app/Sources/BridgeplayApp/SystemStatus.swift
+++ b/app/Sources/BridgeplayApp/SystemStatus.swift
@@ -629,12 +629,17 @@ final class SystemStatus {
// unattended: nobody pressed anything, so a Steam that opened since the decision to
// install is left running and the install stops instead.
+ // Steam's signature is broken and only another account can sign it again. The install
+ // itself finished, so Setup carries on, but it shows as a failure until an install clears it.
+ private(set) var sealWarning: String?
+
func installIntoSteam(unattended: Bool = false, holdBack: (Error) -> Bool = { _ in false }) async {
if let refusal = MigrationLaunch.shared.refusal {
setFailure(refusal)
AppLog.note("run refused: install waits for the 3.0 folder move")
return
}
+ sealWarning = nil
await perform(from: InstallPhase.checkingPayload.label, holdBack: holdBack) { progress in
let lock = try DeploymentContent.acquireInstallationLock()
defer { lock.release() }
@@ -683,10 +688,13 @@ final class SystemStatus {
try SteamInstaller.finish(result)
}.value
+ // Set last, so a step that fails above is not read as a finished install.
+ sealWarning = result.sealWarning
return parts.joined(separator: " ")
}
if failure == nil {
UserDefaults.standard.removeObject(forKey: SteamPatchKeeper.pausedKey)
+ if let sealWarning { setFailure(sealWarning) }
}
}
@@ -763,6 +771,15 @@ final class SystemStatus {
switch decision {
case .nothing:
+ let deployment = seen.deployment
+ let failed = autoReapplyFailed
+ let app = SupportPaths.Steam.app
+ let stands = await Task.detached(priority: .utility) {
+ SteamPatchKeeper.failureStands(deployment, lastAttemptFailed: failed) {
+ SteamInstaller.sealIsIntact(app)
+ }
+ }.value
+ if stands { return }
if patchBanner != nil { AppLog.note("patch keeper (\(trigger)): Steam carries Bridgeplay again") }
patchBanner = nil
autoReapplyFailed = false
diff --git a/app/Tests/BridgeplayAppTests/SteamInstallerTests.swift b/app/Tests/BridgeplayAppTests/SteamInstallerTests.swift
index 0860fe7..baa3067 100644
--- a/app/Tests/BridgeplayAppTests/SteamInstallerTests.swift
+++ b/app/Tests/BridgeplayAppTests/SteamInstallerTests.swift
@@ -740,6 +740,33 @@ struct SteamInstallerTests {
)
}
+ @Test("A broken seal this account can't sign again doesn't stop its own install")
+ func brokenSealElsewhereKeepsInstalling() async throws {
+ let work = try scratchDirectory("install")
+ defer { try? FileManager.default.removeItem(at: work) }
+ let fixture = try await self.fixture(into: work)
+
+ _ = try install(fixture)
+ var dict = try #require(SteamBundle.readInfoPlist(at: fixture.plist))
+ dict["BridgeplayTestKey"] = "changed"
+ try SteamBundle.writeInfoPlist(dict, at: fixture.plist)
+
+ var warning: String?
+ let patching = try SteamInstaller.needsPatching(
+ plist: fixture.plist, dylib: fixture.deployedDylib, shipping: fixture.payload.dylib, app: fixture.app,
+ checkWritable: { throw WriteRefused(path: $0.path(percentEncoded: false), remedy: .otherAccount) },
+ onBrokenSeal: { warning = $0 })
+ #expect(!patching)
+ #expect(warning == SteamInstaller.brokenSealDetail(.otherAccount))
+
+ // A refusal this account can fix itself is still reported.
+ #expect(throws: WriteRefused.self) {
+ try SteamInstaller.needsPatching(
+ plist: fixture.plist, dylib: fixture.deployedDylib, shipping: fixture.payload.dylib, app: fixture.app,
+ checkWritable: { throw WriteRefused(path: $0.path(percentEncoded: false), remedy: .ownership) })
+ }
+ }
+
@Test("The installer records the package build time rather than the installation time")
func recordsPackageBuild() async throws {
let work = try scratchDirectory("install-record")
diff --git a/app/Tests/BridgeplayAppTests/SteamPatchKeeperTests.swift b/app/Tests/BridgeplayAppTests/SteamPatchKeeperTests.swift
index 1f0a508..000cb4c 100644
--- a/app/Tests/BridgeplayAppTests/SteamPatchKeeperTests.swift
+++ b/app/Tests/BridgeplayAppTests/SteamPatchKeeperTests.swift
@@ -180,6 +180,18 @@ struct SteamPatchKeeperTests {
#expect(tries == 0)
}
+ @Test("A failed re-apply stands while Steam's signature stays broken")
+ func failureStandsOnBrokenSeal() {
+ #expect(SteamPatchKeeper.failureStands(.installed(version: nil), lastAttemptFailed: true) { false })
+ #expect(!SteamPatchKeeper.failureStands(.installed(version: nil), lastAttemptFailed: true) { true })
+
+ // Nothing failed, or Steam isn't installed: the signature is not read at all.
+ var read = false
+ #expect(!SteamPatchKeeper.failureStands(.installed(version: nil), lastAttemptFailed: false) { read = true; return false })
+ #expect(!SteamPatchKeeper.failureStands(.notInstalled, lastAttemptFailed: true) { read = true; return false })
+ #expect(!read)
+ }
+
@Test("Only a failure marked as passing is retried")
func retryableFailures() {
#expect(SteamPatchKeeper.isRetryable(StepFailure(step: "s", detail: "d", retryable: true)))