Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Say how the helper checks what it moves

Țugui Dragoș5687021df795
diff --git a/AGENTS.md b/AGENTS.md
index e06a8c40..fed1f181 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -172,8 +172,10 @@ disk that somebody may have replaced.
connection (`PrivilegedHelper.ask`): XPC delivers a reply at the quality its message went out with, so a reply to a
lower one waits while Peel is busy, and the wait for it ends first.
- It never uses a path again after checking it: it opens the folder, checks the item there as the kernel names the
- folder (`F_GETPATH`), works only through that descriptor, and moves the item only while its identity is the one
- it checked, so a folder or an item swapped after the check leads nowhere.
+ folder (`F_GETPATH`), and works only through that descriptor, so a folder swapped after the check leads nowhere.
+- A rename still goes by name, so every item the helper moves passes through `Staging`, beside its ledger, which only
+ root can reach (`HelperLedger.whileStaging`), and is checked there before it goes on; anything but the item goes
+ back. It never renames by name out of a folder another account can write, and never takes a name with a placeholder.
- A new operation needs `PrivilegedPathPolicyTests`, and any change to the helper a bump of
`HelperIdentity.protocolVersion`, so Peel never works with a helper of another version.
- The helper's identifier and its launchd property list stay the same from one version to the next. Updates rely on
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index c3eb597f..600d470d 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -275,6 +275,12 @@ macOS asks the user to approve it once. It talks to the app over XPC.
`ProtectedData` protects. It has no shell.
- It opens folders by descriptor and works through them, so a path swapped for a link after the check leads
nowhere.
+- A rename goes by name, so something else can take an item's name between the last look and the move. The helper
+ takes every item through `Staging`, a folder beside its ledger that only root can reach, and checks there that what
+ arrived is the item it opened and, for a Put Back, that the place takes it as it is now; anything else goes back
+ where it came from. So it moves nothing on another disk than its own folder's, nor where a rename can't refuse to
+ replace a name. What a move cut short leaves in `Staging` goes to its account's Trash when the helper starts and
+ before Remove Peel moves the ledger (`HelperLedger.recoverStaged`).
- It keeps a ledger of what it moved, in a folder only root can write (`/private/var/db/com.tuguidragos.Peel.Helper`),
and puts back only what that ledger knows. An item moves only once its record is on the drive (`DriveFlush`,
`F_FULLFSYNC`), and History is on the drive before the journal lets a removal's items go. While the ledger can't be
@@ -514,7 +520,7 @@ where a Homebrew install takes them from.
| `~/Library/Logs/Peel/<name>` | What the app measured while `PEEL_MEASURE=<name>` was set. |
| `~/Library/Caches/com.tuguidragos.Peel/org.sparkle-project.Sparkle/` | Sparkle's download of an update the user chose to install, and what it prepares to install it. |
| `~/Library/Caches/com.tuguidragos.Peel/Cache.db`, `fsCachedData/`, `~/Library/HTTPStorages/com.tuguidragos.Peel/`, `~/Library/HTTPStorages/com.tuguidragos.Peel.binarycookies` | What macOS's networking keeps for Sparkle's requests: a cache of their answers, what servers said about reaching them again, and a store of cookies that stays empty, since Peel accepts none (`PeelUpdater`). |
-| `/private/var/db/com.tuguidragos.Peel.Helper/` | The helper's ledger of what it moved. |
+| `/private/var/db/com.tuguidragos.Peel.Helper/` | The helper's ledger of what it moved, and `Staging`, where it checks each item on the way. |
| Peel's preferences | Settings, the day Peel was installed, what each tool found the last time it looked, the last answer of each update check, when Sparkle last looked for a new Peel, the Mac's model name (read once, under its model identifier), what Peel last learned of App Management, and what the tweaks, Terminal, and Git held before Peel changed them, so turning a setting off puts that back. |
| Outside Peel's own files | `~/.hushlogin` from the Terminal page; the Dock's two lists of icons (`persistent-apps` and `recent-apps`, through `DockTiles`); the settings Tweaks changes; Terminal's profiles and options; Git's settings; the Time Machine mark on each folder Build Artifacts leaves out of backups, with an attribute beside it that says Peel put it; and the background items disabled on the Background Items page, which launchd keeps disabled across restarts. |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b4b152c..9274e531 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -981,6 +981,10 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
- The helper serves an account that isn't an administrator only for a request carrying an administrator's approval
still in force, for Apple's own `system.privilege.admin` right, which the helper checks itself and which no process
of that account can redefine.
+- The helper takes each item it moves to the Trash or puts back through a folder of its own that only it can reach,
+ and checks there that it is the item it was asked to move, so nothing put in the item's place on the way moves
+ instead, nor goes back where code is loaded from. It no longer moves anything from outside the startup disk, such as
+ from a home folder kept on another disk.
## 1.2.1 (2026-10-25)
diff --git a/SAFETY.md b/SAFETY.md
index 3a30d585..86c188fe 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -682,8 +682,11 @@ and it fails closed.
the app, so it goes once the app is gone, and one that still starts a program stays. A browser starts what a
manifest there names, so these folders take back only what is owned by root and writable by nobody else.
- It never reuses a path after checking it. It opens the parent directory, checks the item there as the system
- names that directory, works only through that descriptor, and moves the item only while it is still the one it
- checked, so a folder or an item swapped after the check leads nowhere.
+ names that directory, and works only through that descriptor, so a folder swapped after the check leads nowhere.
+ It takes each item through a folder of its own that only root can reach, and checks there that what arrived is
+ the item it checked, and for a Put Back that the place takes it as it is now, so anything put in the item's place
+ on the way goes back where it came from. A rename can't leave its disk, so it moves nothing outside the startup
+ disk.
- "Put Back" is asked for by a record any process running as you can rewrite, so the helper believes none of
it. It keeps its own ledger, in a folder that is root's alone, of what it moved and from where: the item is
recognized by what it is (not by its name or place in the Trash), and it goes back only to the exact place