Repository navigation
Read the home folder from the password database for every service - #301
Merged
Merged
Conversation
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.
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:chat.dbat/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. Somessages_attachment_readalways fails withgrantMissing.CallHistoryDBleft at the old location.Mail.swiftalready gets the real home folder fromgetpwuid, because the sandbox pointsNSHomeDirectory()at the app container. This PR moves that code intoFileManager.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 --strictpasses on the changed files. The CI build command (xcodebuild -scheme iMCP -configuration Debug, unsigned) succeeds, andimcp-serverTestspasses (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_readread 19 of 20 attachments (the remaining one,noFile, isn't downloaded from iCloud yet), andphone_calls_fetchreturned the current call history. The behaviour above was observed with the 1.7.1 release.