Skip to content

Read the home folder from the password database for every service - #301

Merged
mattt merged 3 commits into
mattt:mainfrom
heevy:fix-home-dir
Oct 25, 2026
Merged

mattt merged 3 commits into
mattt:mainfrom
heevy:fix-home-dir

Conversation

@heevy

@heevy heevy commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Messages, Phone, Voicemail and the Claude Desktop integration build their paths as /Users/<NSUserName()>/…. That breaks when the home folder has been moved. My Mac's home is at /Volumes/MiniHome/Users/<name>, and on it:

  • Messages: without a bookmark, iMCP read an old, empty chat.db at /Users/<name>/Library/Messages. After granting the real Messages folder, messages worked. But the Attachments picker rejects the real Attachments folder (wrongFolderSelected), because it compares the selection against the hard-coded path. So messages_attachment_read always fails with grantMissing.
  • Phone: read a stale copy of CallHistoryDB left at the old location.
  • Voicemail / Claude Desktop: same pattern. I didn't test these.

Mail.swift already gets the real home folder from getpwuid, because the sandbox points NSHomeDirectory() at the app container. This PR moves that code into FileManager.userHomeDirectoryPath (App/Extensions/Foundation+Extensions.swift, which the Mail tests already compile) and uses it in every service. The /Users/*/Library/Messages/ entitlement stays as it is. On a moved home it no longer matches, so the existing bookmark flow takes over, as it should.

Testing: swift format lint --strict passes on the changed files. The CI build command (xcodebuild -scheme iMCP -configuration Debug, unsigned) succeeds, and imcp-serverTests passes (88 tests, 1 skipped) with Xcode 27.1. I also ran an ad-hoc signed, sandboxed copy of the patched app (same entitlements as the release, minus WeatherKit) on the affected Mac. The Attachments picker accepted the real folder, messages_attachment_read read 19 of 20 attachments (the remaining one, noFile, isn't downloaded from iCloud yet), and phone_calls_fetch returned the current call history. The behaviour above was observed with the 1.7.1 release.

jiridudekusy and others added 3 commits October 25, 2026 09:15
Messages, Phone, Voicemail and the Claude Desktop integration built their
paths as /Users/<NSUserName()>, which misses a home folder that has been
moved, for example to another volume. On such a Mac, Messages read a stale
or empty database at the old location, the Attachments picker rejected the
real folder as wrongFolderSelected, so attachment reads always failed with
grantMissing, and Phone read an old copy of the call history.

Mail already resolved the home folder with getpwuid, because the sandbox
points NSHomeDirectory() at the app container. Move that into
FileManager.userHomeDirectoryPath and use it everywhere.
@mattt
mattt merged commit 2493110 into mattt:main Oct 25, 2026
2 checks passed
@mattt

mattt commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Thanks, @heevy! I really appreciate you tracking this down.

I pushed two commits on top: 0722b9b builds the paths with appendingPathComponent instead of + and reflows the doc comment, and 4a58335 passes the new path to iMessage.Database, which otherwise falls back to /Users/<name>.

@heevy
heevy deleted the fix-home-dir branch October 26, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants