Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
fix(install): judge write refusals by their error and folder (#391)
Raystormab4f3b285326
diff --git a/app/Sources/BridgeplayApp/Model/SteamInstaller.swift b/app/Sources/BridgeplayApp/Model/SteamInstaller.swiftindex a191b2b..ddf5704 100644--- a/app/Sources/BridgeplayApp/Model/SteamInstaller.swift+++ b/app/Sources/BridgeplayApp/Model/SteamInstaller.swift@@ -353,7 +353,7 @@ enum SteamInstaller {try Data("probe".utf8).write(to: probe, options: .withoutOverwriting)try FileManager.default.removeItem(at: probe)} catch let error as NSError where error.code == NSFileWriteNoPermissionError {- throw WriteRefused(path: directory.path(percentEncoded: false))+ throw WriteRefused(path: directory.path(percentEncoded: false), errno: WriteRefused.posixCode(of: error))} catch {throw StepFailure(step: step,diff --git a/app/Sources/BridgeplayApp/Model/UpdateBlock.swift b/app/Sources/BridgeplayApp/Model/UpdateBlock.swiftindex de98af6..bb32471 100644--- a/app/Sources/BridgeplayApp/Model/UpdateBlock.swift+++ b/app/Sources/BridgeplayApp/Model/UpdateBlock.swift@@ -89,7 +89,7 @@ enum UpdateBlock {} catch let refusal as WriteRefused {throw refusal} catch let error as NSError where error.code == NSFileWriteNoPermissionError {- throw WriteRefused(path: required.path(percentEncoded: false))+ throw WriteRefused(path: required.path(percentEncoded: false), errno: WriteRefused.posixCode(of: error))} catch {throw StepFailure(step: step,diff --git a/app/Sources/BridgeplayApp/Support/AtomicReplace.swift b/app/Sources/BridgeplayApp/Support/AtomicReplace.swiftindex daf053d..dd218a9 100644--- a/app/Sources/BridgeplayApp/Support/AtomicReplace.swift+++ b/app/Sources/BridgeplayApp/Support/AtomicReplace.swift@@ -16,7 +16,7 @@ func atomicReplace(_ destination: URL, from source: URL, step: String) throws {) != 0 {let code = errnoif code == EACCES || code == EPERM {- throw WriteRefused(path: destination.path(percentEncoded: false))+ throw WriteRefused(path: destination.path(percentEncoded: false), errno: code)}let reason = String(cString: strerror(code))throw StepFailure(diff --git a/app/Sources/BridgeplayApp/Support/RemoveEverythingCommand.swift b/app/Sources/BridgeplayApp/Support/RemoveEverythingCommand.swiftindex 71f63c7..79bd579 100644--- a/app/Sources/BridgeplayApp/Support/RemoveEverythingCommand.swift+++ b/app/Sources/BridgeplayApp/Support/RemoveEverythingCommand.swift@@ -36,10 +36,15 @@ enum RemoveEverythingCommand {static func failureMessage(_ error: Error) -> String {guard let refused = error as? WriteRefused else { return error.localizedDescription }- // Only App Management names a different app here: the terminal, not Bridgeplay.- let advice = refused.remedy == .appManagement- ? "Allow your terminal app in System Settings > Privacy & Security > App Management, then run it again."- : refused.remedy.advice+ // The app's advice, except where the command line asks for something else.+ let advice = switch refused.remedy {+ case .appManagement:+ "Allow your terminal app in System Settings > Privacy & Security > App Management, then run it again."+ case .otherAccount:+ "Steam was installed by another account on this Mac. Run this again while logged in to that account."+ case .rootOwned, .ownership:+ refused.remedy.advice+ }return "Could not write \(refused.path). \(advice)"}diff --git a/app/Sources/BridgeplayApp/Support/WriteRefused.swift b/app/Sources/BridgeplayApp/Support/WriteRefused.swiftindex 3e07918..ecce197 100644--- a/app/Sources/BridgeplayApp/Support/WriteRefused.swift+++ b/app/Sources/BridgeplayApp/Support/WriteRefused.swift@@ -8,9 +8,18 @@ struct WriteRefused: LocalizedError {// Worked out when the write fails, while the folder is as the write found it.let remedy: Remedy- init(path: String, remedy: Remedy? = nil) {+ init(path: String, errno code: Int32? = nil, remedy: Remedy? = nil) {self.path = path- self.remedy = remedy ?? Remedy(forPath: path)+ self.remedy = remedy ?? Remedy(forPath: path, errno: code)+ }++ static func posixCode(of error: Error) -> Int32? {+ var current: NSError? = error as NSError+ while let error = current {+ if error.domain == NSPOSIXErrorDomain { return Int32(error.code) }+ current = error.userInfo[NSUnderlyingErrorKey] as? NSError+ }+ return nil}var errorDescription: String? { String(localized: "Could not write files.") }@@ -21,7 +30,7 @@ extension WriteRefused {do {return try body()} catch let error as NSError where error.code == NSFileWriteNoPermissionError {- throw WriteRefused(path: path)+ throw WriteRefused(path: path, errno: posixCode(of: error))}}@@ -35,9 +44,9 @@ extension WriteRefused {enum Remedy: Hashable {case appManagementcase otherAccount- // Root owns it (MDM, `sudo cp`). Only a bundle gets a chown command: a root folder- // outside one may be /Applications itself, which nobody should take over.- case rootOwned(bundle: String?)+ // Root owns it (MDM, `sudo cp`, `sudo make deploy`). Carries what a chown should cover,+ // if anything: a root folder outside a bundle and the home may be /Applications itself.+ case rootOwned(handOver: String?)case ownershipvar advice: String {@@ -48,8 +57,8 @@ enum Remedy: Hashable {String(localized: "Bridgeplay needs the App Management permission. Turn on Bridgeplay in System Settings › Privacy & Security › App Management. After a Bridgeplay update the switch can look on but no longer work: turn it off and on again.")case .otherAccount:String(localized: "Steam was installed by another account on this Mac. Only that account can modify it. Log in to macOS with that account to reinstall Bridgeplay.")- case .rootOwned(let bundle?):- String(localized: "\(bundle) belongs to the system (root), not to your account, so Bridgeplay cannot change it. An administrator has to make your account its owner, for example by running this in Terminal: \(Self.chownCommand(bundle))")+ case .rootOwned(let target?):+ String(localized: "\(target) belongs to the system (root), not to your account, so Bridgeplay cannot change it. An administrator has to make your account its owner, for example by running this in Terminal: \(Self.chownCommand(target))")case .rootOwned(nil):String(localized: "This folder belongs to the system (root), and your account cannot write to it. Try again from an administrator account, or ask an administrator for help.")case .ownership: String(localized: "Check permissions, make sure your user owns the folder.")@@ -82,47 +91,40 @@ enum Remedy: Hashable {NSWorkspace.shared.open(pane)}- struct Owner: Equatable {- var uid: uid_t- var gid: gid_t- var mode: Int+ // What the lookup reads, swappable in tests.+ struct Lookup {+ var owner: (String) -> uid_t? = Remedy.owner(of:)+ var writable: (String) -> Bool = { access($0, W_OK) == 0 }+ var user: uid_t = getuid()+ var home: String = NSHomeDirectory()+ }- // The POSIX check: owner bits for the owner, group bits for a member, other bits otherwise.- func letsWrite(_ user: uid_t, groups: Set<gid_t>) -> Bool {- if uid == user { return mode & 0o200 != 0 }- if groups.contains(gid) { return mode & 0o020 != 0 }- return mode & 0o002 != 0- }+ static func owner(of path: String) -> uid_t? {+ guard+ let attributes = try? FileManager.default.attributesOfItem(atPath: path),+ let owner = attributes[.ownerAccountID] as? NSNumber+ else { return nil }+ return uid_t(owner.uint32Value)}- static func owner(of path: String) -> Owner? {- let files = FileManager.default- let url = URL(filePath: path)- for candidate in [url, url.deletingLastPathComponent()] {- guard- let attributes = try? files.attributesOfItem(- atPath: candidate.path(percentEncoded: false)- ),- let uid = attributes[.ownerAccountID] as? NSNumber,- let gid = attributes[.groupOwnerAccountID] as? NSNumber,- let mode = attributes[.posixPermissions] as? NSNumber- else { continue }- return Owner(uid: uid_t(uid.uint32Value), gid: gid_t(gid.uint32Value), mode: mode.intValue)- }- return nil+ private static func plainPath(_ url: URL) -> String {+ var path = url.path(percentEncoded: false)+ if path.count > 1, path.hasSuffix("/") { path.removeLast() }+ return path}- static func groups(of user: String = NSUserName(), primary: gid_t = getgid()) -> Set<gid_t> {- var size: Int32 = 64- while size <= 4096 {- var list = [Int32](repeating: 0, count: Int(size))- var count = size- if getgrouplist(user, Int32(bitPattern: primary), &list, &count) == 0 {- return Set(list.prefix(Int(count)).map { gid_t(bitPattern: $0) })+ // The folder whose permissions decide a create, rename or delete: the path when it is a+ // folder, else the one it sits in.+ static func folder(holding path: String) -> String? {+ let url = URL(filePath: path)+ for candidate in [url, url.deletingLastPathComponent()] {+ var isDirectory: ObjCBool = false+ if FileManager.default.fileExists(atPath: plainPath(candidate), isDirectory: &isDirectory),+ isDirectory.boolValue {+ return plainPath(candidate)}- size *= 2}- return [primary]+ return nil}// The outermost one, so a refusal inside Steam Helper.app names Steam.app.@@ -133,25 +135,36 @@ enum Remedy: Hashable {while directory.pathComponents.count > 1 {let plist = directory.appending(path: "Contents/Info.plist")if files.fileExists(atPath: plist.path(percentEncoded: false)) {- var bundle = directory.path(percentEncoded: false)- if bundle.count > 1, bundle.hasSuffix("/") { bundle.removeLast() }- outermost = bundle+ outermost = plainPath(directory)}directory = directory.deletingLastPathComponent()}return outermost}- init(- forPath path: String,- owner: (String) -> Owner? = Remedy.owner(of:),- user: uid_t = getuid(),- groups: @autoclosure () -> Set<gid_t> = Remedy.groups()- ) {- // A folder the permissions let this account write was refused by App Management,- // whoever owns it (a root:admin 775 Steam.app, for an admin).- if let owner = owner(path), owner.uid != user, !owner.letsWrite(user, groups: groups()) {- self = owner.uid == 0 ? .rootOwned(bundle: Self.enclosingBundle(of: path)) : .otherAccount+ // The outermost bundle, or the topmost folder root owns inside the home.+ static func handOver(_ path: String, folder: String, lookup: Lookup) -> String? {+ if let bundle = enclosingBundle(of: path) { return bundle }+ let inside = lookup.home + "/"+ guard folder.hasPrefix(inside) else { return nil }+ var top = URL(filePath: folder)+ while true {+ let parent = plainPath(top.deletingLastPathComponent())+ guard parent.hasPrefix(inside), lookup.owner(parent) == 0 else { break }+ top = URL(filePath: parent)+ }+ return plainPath(top)+ }++ init(forPath path: String, errno code: Int32? = nil, lookup: Lookup = Lookup()) {+ // EPERM is a policy refusing (App Management, a locked file), EACCES the permissions.+ // Without a code, ask the system, which counts ACLs and every group.+ if let folder = Self.folder(holding: path),+ code.map({ $0 != EPERM }) ?? !lookup.writable(folder),+ let owner = lookup.owner(folder), owner != lookup.user {+ self = owner == 0+ ? .rootOwned(handOver: Self.handOver(path, folder: folder, lookup: lookup))+ : .otherAccountreturn}self = Self.enclosingBundle(of: path) == nil ? .ownership : .appManagement@@ -165,7 +178,7 @@ enum Remedy: Hashable {let allRoot = !distinct.isEmpty && distinct.allSatisfy {if case .rootOwned = $0 { true } else { false }}- return allRoot ? .rootOwned(bundle: nil) : nil+ return allRoot ? .rootOwned(handOver: nil) : nil}}diff --git a/app/Tests/BridgeplayAppTests/RemedyOwnerTests.swift b/app/Tests/BridgeplayAppTests/RemedyOwnerTests.swiftindex a19cc1c..4461efe 100644--- a/app/Tests/BridgeplayAppTests/RemedyOwnerTests.swift+++ b/app/Tests/BridgeplayAppTests/RemedyOwnerTests.swift@@ -8,20 +8,25 @@ import Testingstruct RemedyOwnerTests {private static let user: uid_t = 501- private static let staff: gid_t = 20- private static let admin: gid_t = 80- private static func owned(by uid: uid_t, group: gid_t = 0, mode: Int = 0o755) -> (String) -> Remedy.Owner? {- { _ in Remedy.Owner(uid: uid, gid: group, mode: mode) }+ private static func lookup(+ owner: @escaping (String) -> uid_t?, writable: Bool = false, home: String = "/Users/np-test"+ ) -> Remedy.Lookup {+ Remedy.Lookup(owner: owner, writable: { _ in writable }, user: user, home: home)}- private func remedy(_ path: String, _ owner: @escaping (String) -> Remedy.Owner?,- groups: Set<gid_t> = [staff]) -> Remedy {- Remedy(forPath: path, owner: owner, user: Self.user, groups: groups)+ private static func owned(by uid: uid_t, writable: Bool = false) -> Remedy.Lookup {+ lookup(owner: { _ in uid }, writable: writable)}- private func steamBundle() throws -> (root: URL, app: URL, inside: String) {+ private func scratch() throws -> URL {let root = URL.temporaryDirectory.appending(path: "np-owner-\(UUID().uuidString)")+ try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)+ return root+ }++ private func steamBundle() throws -> (root: URL, app: URL, inside: String) {+ let root = try scratch()let app = root.appending(path: "Steam.app")let inside = app.appending(path: "Contents/MacOS")try FileManager.default.createDirectory(at: inside, withIntermediateDirectories: true)@@ -34,10 +39,38 @@ struct RemedyOwnerTests {let steam = try steamBundle()defer { try? FileManager.default.removeItem(at: steam.root) }- let found = remedy(steam.inside, Self.owned(by: 0))+ let found = Remedy(forPath: steam.inside, lookup: Self.owned(by: 0))- #expect(found == .rootOwned(bundle: steam.app.path(percentEncoded: false)))+ #expect(found == .rootOwned(handOver: steam.app.path(percentEncoded: false)))#expect(found.settingsPane == nil)+ #expect(Remedy(forPath: steam.inside, errno: EACCES, lookup: Self.owned(by: 0, writable: true))+ == found, "the permissions refused it, whatever access() says")+ }++ // EPERM comes from a policy, App Management among them, not from who owns the folder.+ @Test("A root-owned bundle refused by a policy asks for App Management")+ func policyRefusalAsksForAppManagement() throws {+ let steam = try steamBundle()+ defer { try? FileManager.default.removeItem(at: steam.root) }++ #expect(Remedy(forPath: steam.inside, errno: EPERM, lookup: Self.owned(by: 0)) == .appManagement)+ #expect(Remedy(forPath: steam.inside, errno: EPERM, lookup: Self.owned(by: 502)) == .appManagement)+ }++ // Renames and new files are decided by the folder, not by the file being replaced.+ @Test("The folder holding a file decides, not the file")+ func folderDecides() throws {+ let steam = try steamBundle()+ defer { try? FileManager.default.removeItem(at: steam.root) }+ let dylib = URL(filePath: steam.inside).appending(path: "notproton.dylib")+ try Data("old".utf8).write(to: dylib)+ let path = dylib.path(percentEncoded: false)+ let rootFolder = Self.lookup(owner: { $0 == steam.inside ? 0 : Self.user })++ #expect(Remedy(forPath: path, errno: EACCES, lookup: rootFolder)+ == .rootOwned(handOver: steam.app.path(percentEncoded: false)))+ #expect(Remedy(forPath: path, errno: EPERM, lookup: Self.lookup(owner: { $0 == path ? 0 : Self.user }))+ == .appManagement)}@Test("A refusal inside a nested app names the outer bundle")@@ -52,44 +85,61 @@ struct RemedyOwnerTests {let inside = helper.appending(path: "Contents/MacOS").path(percentEncoded: false)- #expect(remedy(inside, Self.owned(by: 0)) == .rootOwned(bundle: steam.app.path(percentEncoded: false)))+ #expect(Remedy(forPath: inside, lookup: Self.owned(by: 0))+ == .rootOwned(handOver: steam.app.path(percentEncoded: false)))}- @Test("A root folder outside a bundle gets no chown command")- func rootOwnedFolder() {- let found = remedy("/nonexistent/folder", Self.owned(by: 0))+ @Test("A root folder outside a bundle and the home gets no chown command")+ func rootOwnedFolder() throws {+ let root = try scratch()+ defer { try? FileManager.default.removeItem(at: root) }++ let found = Remedy(forPath: root.path(percentEncoded: false), lookup: Self.owned(by: 0))- #expect(found == .rootOwned(bundle: nil))+ #expect(found == .rootOwned(handOver: nil))#expect(!found.advice.contains("chown"))#expect(!found.advice.contains("its owner"), "advised taking over a system folder")}- // /Applications itself is root:admin 775. A target missing under it is looked up there.+ // /Applications itself is root-owned. A target missing under it is judged by it.@Test("A missing target under /Applications is not advised to take over /Applications")func missingTargetUnderApplications() {- let found = remedy("/Applications/np-missing-\(UUID().uuidString).app",- Self.owned(by: 0, group: Self.admin, mode: 0o775))+ let found = Remedy(forPath: "/Applications/np-missing-\(UUID().uuidString).app",+ errno: EACCES, lookup: Self.owned(by: 0))- #expect(found == .rootOwned(bundle: nil))+ #expect(found == .rootOwned(handOver: nil))#expect(!found.advice.contains("chown"))}- @Test("A root:admin group-writable bundle asks an admin for App Management")- func groupWritableBundleAsksForAppManagement() throws {- let steam = try steamBundle()- defer { try? FileManager.default.removeItem(at: steam.root) }- let owner = Self.owned(by: 0, group: Self.admin, mode: 0o775)+ // After `sudo make deploy`, say: the support folder is root's, inside the user's home.+ @Test("A root-owned folder in the home hands over its topmost root-owned folder")+ func rootOwnedFolderInTheHome() throws {+ let home = try scratch()+ defer { try? FileManager.default.removeItem(at: home) }+ let support = home.appending(path: "Library/Application Support")+ let bridgeplay = support.appending(path: "bridgeplay")+ let runners = bridgeplay.appending(path: "runners")+ try FileManager.default.createDirectory(at: runners, withIntermediateDirectories: true)+ let rootOwned = bridgeplay.path(percentEncoded: false)+ let lookup = Self.lookup(+ owner: { $0.hasPrefix(rootOwned) ? 0 : Self.user },+ home: home.path(percentEncoded: false)+ )++ let found = Remedy(forPath: runners.appending(path: "crossover-1").path(percentEncoded: false),+ errno: EACCES, lookup: lookup)- #expect(remedy(steam.inside, owner, groups: [Self.staff, Self.admin]) == .appManagement)- #expect(remedy(steam.inside, owner, groups: [Self.staff]) == .rootOwned(bundle: steam.app.path(percentEncoded: false)))+ #expect(found == .rootOwned(handOver: rootOwned))+ #expect(found.advice.contains(Remedy.chownCommand(rootOwned)))}- @Test("A world-writable bundle another account owns asks for App Management")- func worldWritableBundleAsksForAppManagement() throws {+ @Test("A bundle root owns that this account may still write asks for App Management")+ func writableRootBundleAsksForAppManagement() throws {let steam = try steamBundle()defer { try? FileManager.default.removeItem(at: steam.root) }- #expect(remedy(steam.inside, Self.owned(by: 502, group: Self.staff, mode: 0o777)) == .appManagement)+ #expect(Remedy(forPath: steam.inside, lookup: Self.owned(by: 0, writable: true)) == .appManagement)+ #expect(Remedy(forPath: steam.inside, lookup: Self.owned(by: 502, writable: true)) == .appManagement)}@Test("A bundle another user owns is still another account's")@@ -97,15 +147,18 @@ struct RemedyOwnerTests {let steam = try steamBundle()defer { try? FileManager.default.removeItem(at: steam.root) }- #expect(remedy(steam.inside, Self.owned(by: 502, group: Self.staff)) == .otherAccount)+ #expect(Remedy(forPath: steam.inside, lookup: Self.owned(by: 502)) == .otherAccount)+ #expect(Remedy(forPath: steam.inside, errno: EACCES, lookup: Self.owned(by: 502)) == .otherAccount)}@Test("Root running the app owns what root owns")func rootIsItsOwnAccount() throws {let steam = try steamBundle()defer { try? FileManager.default.removeItem(at: steam.root) }+ var lookup = Self.owned(by: 0)+ lookup.user = 0- #expect(Remedy(forPath: steam.inside, owner: Self.owned(by: 0), user: 0, groups: [0]) == .appManagement)+ #expect(Remedy(forPath: steam.inside, lookup: lookup) == .appManagement)}@Test("An own folder inside a bundle asks for App Management")@@ -114,25 +167,50 @@ struct RemedyOwnerTests {defer { try? FileManager.default.removeItem(at: steam.root) }#expect(Remedy(forPath: steam.inside) == .appManagement)- #expect(remedy(steam.inside, Self.owned(by: Self.user, group: Self.staff)) == .appManagement)+ #expect(Remedy(forPath: steam.inside, lookup: Self.owned(by: Self.user)) == .appManagement)}@Test("An own folder outside a bundle asks to check ownership")func ownFolder() throws {- let root = URL.temporaryDirectory.appending(path: "np-owner-\(UUID().uuidString)")- try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)+ let root = try scratch()defer { try? FileManager.default.removeItem(at: root) }#expect(Remedy(forPath: root.path(percentEncoded: false)) == .ownership)}- @Test("The real lookup reads owner, group and mode")- func realLookup() throws {- let owner = try #require(Remedy.owner(of: "/usr/bin"))+ @Test("A path that is not there asks to check ownership")+ func missingPath() {+ #expect(Remedy(forPath: "/nonexistent/np-\(UUID().uuidString)/file", lookup: Self.owned(by: 0)) == .ownership)+ }- #expect(owner.uid == 0)- #expect(!owner.letsWrite(Self.user, groups: [Self.staff, Self.admin]))- #expect(Remedy.groups().contains(getgid()))+ // Real refusals: a locked folder gives EPERM, a read-only one EACCES.+ @Test("A real refusal carries its POSIX code")+ func realRefusalsCarryTheirCode() throws {+ let steam = try steamBundle()+ let files = FileManager.default+ defer {+ try? files.setAttributes([.immutable: false, .posixPermissions: 0o755], ofItemAtPath: steam.inside)+ try? files.removeItem(at: steam.root)+ }+ let probe = URL(filePath: steam.inside).appending(path: "probe")++ try files.setAttributes([.immutable: true], ofItemAtPath: steam.inside)+ let locked = try #require(throws: WriteRefused.self) {+ try WriteRefused.catching(probe) { try Data("x".utf8).write(to: probe) }+ }+ #expect(locked.remedy == .appManagement)+ try files.setAttributes([.immutable: false], ofItemAtPath: steam.inside)++ try files.setAttributes([.posixPermissions: 0o555], ofItemAtPath: steam.inside)+ let readOnly = try #require(throws: NSError.self) { try Data("x".utf8).write(to: probe) }+ #expect(WriteRefused.posixCode(of: readOnly) == EACCES)+ }++ @Test("The real lookup reads the owner")+ func realLookup() throws {+ #expect(Remedy.owner(of: "/usr/bin") == 0)+ #expect(Remedy.folder(holding: "/usr/bin/true") == "/usr/bin")+ #expect(Remedy.folder(holding: "/usr/bin") == "/usr/bin")}@Test("The remedy is fixed when the write is refused")@@ -146,7 +224,7 @@ struct RemedyOwnerTests {@Test("The advice names the bundle and a command that hands it over")func adviceCarriesTheCommand() {- let advice = Remedy.rootOwned(bundle: "/Applications/Steam.app").advice+ let advice = Remedy.rootOwned(handOver: "/Applications/Steam.app").advice#expect(advice.contains("/Applications/Steam.app belongs to the system (root)"))#expect(advice.contains("sudo chown -R '\(NSUserName())' '/Applications/Steam.app'"))@@ -163,7 +241,7 @@ struct RemedyOwnerTests {@Test("Refusals root owns in one bundle keep the command")func oneRootBundleKeepsTheCommand() throws {- let steam = Remedy.rootOwned(bundle: "/Applications/Steam.app")+ let steam = Remedy.rootOwned(handOver: "/Applications/Steam.app")let report = try #require(FailureReport([WriteRefused(path: "/Applications/Steam.app/Contents/MacOS", remedy: steam),WriteRefused(path: "/Applications/Steam.app/Contents/Info.plist", remedy: steam),@@ -177,11 +255,11 @@ struct RemedyOwnerTests {func rootRefusalsInDifferentPlacesShareAdvice() throws {let report = try #require(FailureReport([WriteRefused(path: "/Applications/Steam.app/Contents/MacOS",- remedy: .rootOwned(bundle: "/Applications/Steam.app")),- WriteRefused(path: "/Library/Shared/np", remedy: .rootOwned(bundle: nil)),+ remedy: .rootOwned(handOver: "/Applications/Steam.app")),+ WriteRefused(path: "/Library/Shared/np", remedy: .rootOwned(handOver: nil)),]))- #expect(report.remedy == .rootOwned(bundle: nil))+ #expect(report.remedy == .rootOwned(handOver: nil))#expect(report.message.contains("belongs to the system (root)"))#expect(!report.message.contains("chown"))}@@ -189,7 +267,7 @@ struct RemedyOwnerTests {@Test("Refusals with different causes share no advice")func mixedRefusalsShareNothing() throws {let report = try #require(FailureReport([- WriteRefused(path: "/a", remedy: .rootOwned(bundle: nil)),+ WriteRefused(path: "/a", remedy: .rootOwned(handOver: nil)),WriteRefused(path: "/b", remedy: .otherAccount),]))@@ -198,7 +276,7 @@ struct RemedyOwnerTests {@Test("Installing into a root-owned Steam says root owns it, not another account")func installerNamesRoot() throws {- let root = Remedy.rootOwned(bundle: "/Applications/Steam.app")+ let root = Remedy.rootOwned(handOver: "/Applications/Steam.app")let unpatched = try #require(SteamInstaller.refusalDetail(root, deployed: false))#expect(unpatched == root.advice)@@ -224,13 +302,16 @@ struct RemedyOwnerTests {#expect(SteamInstaller.refusalDetail(.ownership, deployed: true) == nil)}- @Test("The command line gives the app's advice, except for App Management")- func commandLineSharesTheAdvice() {- let root = Remedy.rootOwned(bundle: "/Applications/Steam.app")+ @Test("The command line gives the app's root advice and keeps its own wording elsewhere")+ func commandLineAdvice() {+ let root = Remedy.rootOwned(handOver: "/Applications/Steam.app")#expect(RemoveEverythingCommand.failureMessage(WriteRefused(path: "/x", remedy: root))== "Could not write /x. \(root.advice)")#expect(RemoveEverythingCommand.failureMessage(WriteRefused(path: "/x", remedy: .appManagement)).contains("Allow your terminal app"))+ let other = RemoveEverythingCommand.failureMessage(WriteRefused(path: "/x", remedy: .otherAccount))+ #expect(other.contains("Run this again while logged in to that account"))+ #expect(!other.contains("reinstall"))}}diff --git a/app/Tests/BridgeplayAppTests/SystemStatusTests.swift b/app/Tests/BridgeplayAppTests/SystemStatusTests.swiftindex 37c1e6a..ad416c6 100644--- a/app/Tests/BridgeplayAppTests/SystemStatusTests.swift+++ b/app/Tests/BridgeplayAppTests/SystemStatusTests.swift@@ -292,7 +292,7 @@ struct FailureReportTests {@Test("A path root owns is not blamed on App Management")func rootOwnedBeatsAppManagement() throws {- #expect(Remedy(forPath: "/usr/bin") == .rootOwned(bundle: nil))+ #expect(Remedy(forPath: "/usr/bin") == .rootOwned(handOver: nil))#expect(Remedy(forPath: "/usr/bin").settingsPane == nil)}