diff --git a/macos/Permissions.mm b/macos/Permissions.mm index d2576b6..5b63799 100644 --- a/macos/Permissions.mm +++ b/macos/Permissions.mm @@ -49,30 +49,38 @@ void Permissions::openAccessibilitySettings() { bool Permissions::checkFullDiskAccess() { // There's no official API to check Full Disk Access. - // We try to read a protected file that requires FDA permission. - // Safari bookmarks is a commonly used test file. + // Try to actually read a protected file that requires FDA. - NSArray* testPaths = @[ - [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Safari/Bookmarks.plist"], - [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Safari/CloudTabs.db"], - @"/Library/Application Support/com.apple.TCC/TCC.db", - [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/com.apple.TCC/TCC.db"] - ]; + NSString* testPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Safari/Bookmarks.plist"]; NSFileManager* fm = [NSFileManager defaultManager]; - for (NSString* path in testPaths) { - if ([fm fileExistsAtPath:path]) { - // File exists, try to read it - if ([fm isReadableFileAtPath:path]) { - return true; // Can read protected file = FDA granted - } else { - return false; // File exists but can't read = FDA not granted - } + if ([fm fileExistsAtPath:testPath]) { + // Try to actually read the file (more reliable than isReadableFileAtPath) + NSData* data = [NSData dataWithContentsOfFile:testPath]; + if (data != nil) { + NSLog(@"FDA check: OK (can read Safari bookmarks)"); + return true; + } else { + NSLog(@"FDA check: FAILED (Safari bookmarks exists but unreadable)"); + return false; } } - // If none of the test files exist, assume FDA is granted - // (edge case: fresh system without Safari history) + // Safari bookmarks doesn't exist, try TCC database + testPath = @"/Library/Application Support/com.apple.TCC/TCC.db"; + if ([fm fileExistsAtPath:testPath]) { + NSData* data = [NSData dataWithContentsOfFile:testPath]; + if (data != nil) { + NSLog(@"FDA check: OK (can read TCC.db)"); + return true; + } else { + NSLog(@"FDA check: FAILED (TCC.db exists but unreadable)"); + return false; + } + } + + // No test files exist, assume OK + NSLog(@"FDA check: SKIPPED (no test files found)"); return true; } diff --git a/macos/main.mm b/macos/main.mm index 62e8253..e722f9e 100644 --- a/macos/main.mm +++ b/macos/main.mm @@ -496,10 +496,11 @@ int main(int argc, const char* argv[]) Permissions::requestAccessibility(); } + // FDA check is unreliable (no official API), just log a warning if (!Permissions::checkFullDiskAccess()) { - NSLog(@"Full Disk Access permission not granted."); - NSLog(@"Please grant permission in System Preferences > Privacy & Security > Full Disk Access"); - Permissions::openFullDiskAccessSettings(); + NSLog(@"Full Disk Access: not detected (may be false negative)."); + NSLog(@"If file access issues occur, grant FDA in System Preferences > Privacy & Security > Full Disk Access"); + // Don't auto-open settings since detection is unreliable } // Create client