Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
List authorization plug-ins and never move them
Țugui Dragoșa8eda957d272
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 413b120a..c86017e4 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -67937,6 +67937,112 @@}}},+ "Left alone: macOS may load this plug-in when someone logs in, and taking it away could keep anyone from logging in, so only its maker’s uninstaller removes it." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nedotčeno: systém macOS může tento plug-in načíst, když se někdo přihlašuje, a jeho odebrání by mohlo zabránit komukoli v přihlášení, proto ho odstraní jen odinstalátor jeho výrobce."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Unangetastet: macOS lädt dieses Plug-in möglicherweise, wenn sich jemand anmeldet, und es zu entfernen, könnte jede Anmeldung verhindern, daher wird es nur vom Deinstallationsprogramm seines Herstellers entfernt."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "No se toca: macOS puede cargar este módulo cuando alguien inicia sesión, y quitarlo podría impedir que nadie inicie sesión, así que solo se elimina con el desinstalador de su fabricante."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Laissé en place : macOS peut charger ce module lorsque quelqu’un ouvre une session, et le retirer pourrait empêcher quiconque d’ouvrir une session, si bien que seul le programme de désinstallation de son éditeur le supprime."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Resta dov’è: macOS potrebbe caricare questo plugin quando qualcuno esegue il login, e toglierlo potrebbe impedire a chiunque di eseguire il login, quindi lo rimuove solo il programma di disinstallazione del suo produttore."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "対象外: このプラグインはログイン時にmacOSが読み込む場合があり、取り除くと誰もログインできなくなる可能性があるため、削除できるのは開発元のアンインストーラだけです。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "그대로 둠: 누군가 로그인할 때 macOS가 이 플러그인을 로드할 수 있으며, 이 플러그인을 제거하면 아무도 로그인할 수 없게 될 수도 있으므로, 제작자의 제거 프로그램만 이 플러그인을 제거합니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Blijft staan: macOS kan deze plug-in laden wanneer iemand inlogt, en als de plug-in wordt weggehaald, kan er mogelijk niemand meer inloggen, dus alleen het de-installatieprogramma van de maker verwijdert die."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nietknięte: macOS może wczytać tę wtyczkę, gdy ktoś się loguje, a jej usunięcie mogłoby uniemożliwić komukolwiek logowanie się, więc usuwa ją tylko dezinstalator jej producenta."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Preservado: o macOS pode carregar este plug-in quando alguém iniciar a sessão, e retirá-lo poderia impedir que qualquer pessoa iniciasse a sessão, então só o desinstalador do fabricante o remove."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Lăsat neatins: macOS poate încărca acest plug-in când cineva face login, iar scoaterea lui ar putea împiedica pe oricine să facă login, așa că îl elimină doar programul de dezinstalare al producătorului său."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Остается на месте: macOS может загружать этот плагин, когда кто-то входит в систему, и, если его убрать, войти в систему может не удаться никому, поэтому его удаляет только программа удаления от производителя."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Rörs inte: macOS kan läsa in den här insticksfilen när någon loggar in, och om den tas bort kan det hindra alla från att logga in, så bara tillverkarens avinstallerare tar bort den."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Yerinde kalır: macOS bu yazılım ekini birisi oturum açtığında yükleyebilir ve onu kaldırmak kimsenin oturum açamamasına neden olabilir, bu yüzden onu yalnızca üreticisinin yükleme kaldırıcısı kaldırır."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Лишається на місці: macOS може завантажувати цей плагін, коли хтось входить у систему, а якщо його прибрати, увійти в систему може не вдатися нікому, тож його вилучає лише деінсталятор від виробника."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "留在原处:有人登录时,macOS可能会载入此插件,而移走它可能导致任何人都无法登录,因此只有其厂商的卸载器才会将其移除。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "原地保留:macOS可能會在有人登入時載入此外掛模組,而移除它可能會讓任何人都無法登入,因此只有其廠商的解除安裝程式會移除它。"+ }+ }+ }+ },"Left alone: macOS removes %@ only when the app goes to the Trash in Finder." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 2646dccd..5c475619 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -344,6 +344,7 @@ extension HoldBack {case .systemExtension:"a system extension macOS installed, which it removes only when its app goes to the Trash in Finder"case .systemExtensionGoingAtRestart: "a system extension macOS removes at the next restart"+ case .signInPlugIn: "a plug-in macOS may load at login, left to its maker's uninstaller"case .keptByMacOS: "a cache macOS keeps for itself"case .openedFromMail: "an attachment opened from Mail, which may be the only copy"case .crashReport: "a crash report, which the app's developer may still ask for"diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex 42019405..f1434f05 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -110,6 +110,8 @@ public enum HoldBack: String, Sendable, Hashable {case systemExtension/// A system extension macOS removes at the next restart.case systemExtensionGoingAtRestart+ /// An authorization plug-in macOS may load at login (`SignInPlugIns`), left to its maker's uninstaller.+ case signInPlugIn/// A cache macOS keeps for its own services, which may be using it at any moment (`SystemCaches`).case keptByMacOS/// A copy Mail keeps of an attachment that was opened. One that was edited may exist nowhere else.@@ -138,7 +140,8 @@ public enum HoldBack: String, Sendable, Hashable {public var cannotBeMoved: Bool {self == .holdsDocuments || self == .holdsALibrary || self == .holdsKeys || self == .holdsWorkKeptInACache|| self == .beyondTheHelper || self == .leftToItsUninstaller- || self == .systemExtension || self == .systemExtensionGoingAtRestart || self == .holdsAnExclusion+ || self == .systemExtension || self == .systemExtensionGoingAtRestart || self == .signInPlugIn+ || self == .holdsAnExclusion|| self == .inTheCloud || self == .holdsAnotherAppsData}@@ -328,6 +331,15 @@ public struct LeftoverScan: Sendable {)}+ func holdingBack(signInPlugInsUnder root: URL) -> LeftoverScan {+ LeftoverScan(+ leftovers: leftovers.map { SignInPlugIns.isOne($0.url, root: root) ? $0.heldBack(.signInPlugIn) : $0 },+ unreadableLocations: unreadableLocations,+ cutShortLocations: cutShortLocations,+ needsFullDiskAccess: needsFullDiskAccess+ )+ }+func leavingToItsUninstaller(_ app: UninstallsItself) -> LeftoverScan {LeftoverScan(leftovers: leftovers.map { app.removes($0.url) ? $0.heldBack(.leftToItsUninstaller) : $0 },diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swiftindex fceed67b..27912671 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SearchLocation.swift@@ -196,10 +196,10 @@ public struct SearchEnvironment: Sendable {Set(paths.map { String($0.prefix { $0 != "/" }) })}- /// Where a driver's kernel extensions and a file system's bundles stay in `/Library`. They are searched like- /// plug-ins, named for what they do, but the helper does not serve these folders, so what is found there is- /// listed and never moved.- static let systemCodeFolders = ["Extensions", "Filesystems"]+ /// Where a driver's kernel extensions, a file system's bundles and authorization plug-ins stay in `/Library`.+ /// They are searched like plug-ins, named for what they do, but the helper does not serve these folders, so what+ /// is found there is listed and never moved.+ static let systemCodeFolders = ["Extensions", "Filesystems", SignInPlugIns.folder]public var locations: [SearchLocation] {let userLibrary = homeDirectory.appending(path: "Library", directoryHint: .isDirectory)diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/SignInPlugIns.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/SignInPlugIns.swiftnew file mode 100644index 00000000..16c73844--- /dev/null+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/SignInPlugIns.swift@@ -0,0 +1,15 @@+import Foundation++/// The authorization plug-ins macOS loads from `/Library/Security/SecurityAgentPlugins` when a rule of the+/// authorization database names one, at login among others (Apple's NullAuthPlugin sample). No public tool lists every+/// rule, and a plug-in a rule still names, once gone, can keep anyone from logging in, so Peel lists them and never+/// moves them.+enum SignInPlugIns {+ static let folder = "Security/SecurityAgentPlugins"++ static func isOne(_ url: URL, root: URL) -> Bool {+ let folder = root.appending(path: "Library", directoryHint: .isDirectory)+ .appending(path: Self.folder, directoryHint: .isDirectory)+ return PathPattern.comparablePath(of: url.deletingLastPathComponent()) == PathPattern.comparablePath(of: folder)+ }+}diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swiftindex ed0c5427..c47cf355 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift@@ -153,6 +153,10 @@ public struct OrphanScanner: Sendable {item.installedFor = installedFor[path].flatMap { URL(filePath: $0).isMissing ? $0 : nil }return (entry.identifier, item)}+ if SignInPlugIns.isOne(item.url, root: environment.rootDirectory) {+ item.heldBack = .signInPlugIn+ return (entry.identifier, item)+ }guard item.requiresPrivileges, item.leftAlone == nil, reach.isBeyond(item.url) else { return entry }item.heldBack = .beyondTheHelperreturn (entry.identifier, item)diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swiftindex ecd16f03..863adb33 100644--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift@@ -259,10 +259,12 @@ public enum PackageReceipts {size: contents.flatMap { $0.couldNotBeRead ? nil : $0.size },requiresPrivileges: requiresPrivileges,refusal: removalGuard.refusal(of: url),- heldBack: requiresPrivileges && reach.isBeyond(url)- ? .beyondTheHelper- : HoldBack.seen(in: contents) ?? (isShared ? .sharedWithEveryone : nil)- ?? (isFilledByOthers ? .holdsWhatOthersPut : nil),+ heldBack: SignInPlugIns.isOne(url, root: volume)+ ? .signInPlugIn+ : requiresPrivileges && reach.isBeyond(url)+ ? .beyondTheHelper+ : HoldBack.seen(in: contents) ?? (isShared ? .sharedWithEveryone : nil)+ ?? (isFilledByOthers ? .holdsWhatOthersPut : nil),removedElsewhere: await removedElsewhere(url, installed: installed)))}diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swiftindex 92e6f4b2..04be6053 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift@@ -87,6 +87,7 @@ public struct Uninstallation: Sendable {if let uninstallsItself {scan = scan.leavingToItsUninstaller(uninstallsItself)}+ scan = scan.holdingBack(signInPlugInsUnder: environment.rootDirectory)let reach = HelperReach(environment: environment)scan = scan.holdingBack(beyond: reach, leaving: app.url)let appRequiresPrivileges = FileAccess.requiresPrivilegesToRemove(app.url)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swiftindex 3aff8db8..ddf7dbd7 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift@@ -817,6 +817,24 @@ struct OrphanScannerTests {#expect(Set(scan.groups.flatMap(\.items).map(\.url.lastPathComponent)) == ["Gone.vst3", "Gone Reverb.component"])}+ @Test func listsAGoneAppsSignInPlugInAndNeverOffersIt() async throws {+ let directory = try TemporaryDirectory()+ let info = #"<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>CFBundleIdentifier</key><string>com.gonevendor.AuthorizationPlugin</string></dict></plist>"#+ try directory.file(+ "root/Library/Security/SecurityAgentPlugins/GoneAuthPlugin.bundle/Contents/Info.plist",+ contents: Data(info.utf8)+ )+ let gone = RememberedApp(+ bundleIdentifier: "com.gonevendor.gone", name: "Gone", teamIdentifier: nil, lastSeen: .now, lastPath: "/Applications/Gone.app"+ )++ let scan = await scanner(in: directory).scan(installedApps: installed, remembered: [gone])++ let item = try #require(scan.groups.flatMap(\.items).first { $0.url.lastPathComponent == "GoneAuthPlugin.bundle" })+ #expect(item.heldBack == .signInPlugIn)+ #expect(item.leftAlone == .signInPlugIn)+ }+@Test func showsWhatAnAppThatLeftKeptWhileAnotherOfItsMakerStays() async throws {let directory = try TemporaryDirectory()try directory.file("home/Library/Caches/org.example.solo.nightly/cache.db")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swiftindex 10380bb0..7f13aae8 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift@@ -415,6 +415,39 @@ struct PackageReceiptsTests {/// An item that needs an administrator is left alone when the helper would refuse it. The helper refuses/// items outside the folders it serves, anything in `/Applications` that is not an app, and, in a folder/// command-line tools are linked into, anything but a link that leads nowhere.+ @Test func leavesAloneASignInPlugIn() async throws {+ let directory = try TemporaryDirectory()+ let volume = PathPattern.canonical(directory.url)+ let plugIn = PathPattern.canonical(try directory.directory("Library/Security/SecurityAgentPlugins/Example.bundle"))+ let settings = PathPattern.canonical(try directory.directory("Library/Application Support/Example"))+ let info = try #require(String(+ data: PropertyListSerialization.data(+ fromPropertyList: ["volume": volume.path(percentEncoded: false), "install-location": ""],+ format: .xml, options: 0+ ),+ encoding: .utf8+ ))+ let pkgutil: PackageReceipts.Pkgutil = { arguments in+ switch arguments.first {+ case "--pkgs-plist": PkgutilAnswer.packages("com.example.pkg")+ case "--pkg-info-plist": info+ case "--files": "Library/Security/SecurityAgentPlugins/Example.bundle\nLibrary/Application Support/Example\n"+ default: ""+ }+ }+ let environment = SearchEnvironment(+ homeDirectory: directory.url.appending(path: "home"),+ rootDirectory: directory.url.appending(path: "root")+ )++ let receipt = try #require(+ await PackageReceipts.list(exclusions: .none, pkgutil: pkgutil, environment: environment).receipts.first+ )++ #expect(receipt.items.first { $0.url == plugIn }?.heldBack == .signInPlugIn)+ #expect(receipt.items.first { $0.url == settings }?.heldBack == nil)+ }+@Test(.permissionsHold) func leavesAloneWhatTheHelperWouldRefuse() async throws {let directory = try TemporaryDirectory()let volume = PathPattern.canonical(directory.url).path(percentEncoded: false)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swiftindex d107134e..7265d3a8 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift@@ -82,6 +82,29 @@ struct UninstallationTests {return { [item] }}+ @Test func listsAnAppsSignInPlugInAndNeverOffersIt() async throws {+ let directory = try TemporaryDirectory()+ let app = InstalledApp(+ url: try directory.directory("root/Applications/Hexachord.app"), bundleIdentifier: "org.example.hexachord",+ name: "Hexachord"+ )+ let plugIn = try directory.file(+ "root/Library/Security/SecurityAgentPlugins/HexachordAuth.bundle/Contents/Info.plist",+ contents: Data(#"<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>CFBundleIdentifier</key><string>org.example.hexachord.AuthorizationPlugin</string></dict></plist>"#.utf8)+ ).deletingLastPathComponent().deletingLastPathComponent()+ let environment = SearchEnvironment(+ homeDirectory: directory.url.appending(path: "home", directoryHint: .isDirectory),+ rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)+ )++ let plan = await Uninstallation.prepare(app, installedApps: [app], environment: environment)++ let place = PathPattern.comparablePath(of: plugIn)+ let leftover = try #require(plan.scan.leftovers.first { PathPattern.comparablePath(of: $0.url) == place })+ #expect(leftover.match.heldBack == .signInPlugIn)+ #expect(!plan.selectable(canUseHelper: true).contains(leftover.url))+ }+@Test func leavesToFinderAnAppWhoseSystemExtensionMacOSInstalled() async throws {let directory = try TemporaryDirectory()let app = try appCarryingAFilter(in: directory)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UninstallsItselfTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UninstallsItselfTests.swiftindex 415a3d4b..7689f00d 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UninstallsItselfTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UninstallsItselfTests.swift@@ -394,6 +394,10 @@ struct UninstallsItselfTests {),root.appending(path: "Library/LaunchDaemons/com.teamviewer.UninstallerWatcher.plist"),root.appending(path: "Library/Application Support/TeamViewer"),+ try teamViewer.directory.file(+ "root/Library/Security/SecurityAgentPlugins/TeamViewerAuthPlugin.bundle/Contents/Info.plist",+ contents: Data(#"<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>CFBundleIdentifier</key><string>com.teamviewer.AuthorizationPlugin</string></dict></plist>"#.utf8)+ ).deletingLastPathComponent().deletingLastPathComponent(),]let leftByIt = [try teamViewer.directory.directory("home/Library/Caches/com.teamviewer.TeamViewer")]diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex fe4f6495..73c51fef 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -315,6 +315,8 @@ extension HoldBack {"Left alone: macOS installed this system extension and removes it only when the app that uses it goes to the Trash in Finder. If that app is gone, install it again, open it and use the feature that needs the extension, allow it when macOS asks, then move the app to the Trash in Finder and restart your Mac."case .systemExtensionGoingAtRestart:"Left alone: macOS removes this system extension when your Mac restarts."+ case .signInPlugIn:+ "Left alone: macOS may load this plug-in when someone logs in, and taking it away could keep anyone from logging in, so only its maker’s uninstaller removes it."case .keptByMacOS:"Not selected: macOS keeps this cache for its own services, which may be using it right now."case .openedFromMail:diff --git a/SAFETY.md b/SAFETY.mdindex d74c3b0b..f7ca6e2a 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -288,6 +288,10 @@ Only matches Peel is `certain` or `likely` about, and only when nothing else ins- **A system extension is left to macOS**, which removes it only when the app that uses it goes to the Trash inFinder, so the copy macOS installed is never listed with the app, and the app itself is moved from no page ofPeel: its own page, Package Receipts and the Homebrew page all leave it to Finder.+- **An authorization plug-in is never moved.** macOS loads one from `/Library/Security/SecurityAgentPlugins` when a+ rule of its authorization database names it, at login among others, and taking away one a rule still names can+ keep anyone from logging in. No public tool lists every rule, so Peel shows it, on the app's page, in Orphaned+ Files and in Package Receipts, and leaves it to its maker's uninstaller.- **An app that stays keeps its files.** Nothing at all is selected for an app that would stay: one macOS keeps, onethat is part of another app, one the helper may not move, or one that needs the helper while it cannot act. An appthat is part of another, such as a helper app inside the app it serves, is never moved on its own, from the app or