From cbdc188ff734e5e8ec727d8aa624a73b92070966 Mon Sep 17 00:00:00 2001 From: Aman Karmani Date: Sun, 1 Sep 2024 12:13:12 -0700 Subject: [PATCH] macos: avoid open() calls on stat failures this fixes sandboxd/tccd security dialogs when calling open() on files that are in other app containers --- src/macos/FSEventsBackend.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/macos/FSEventsBackend.cc b/src/macos/FSEventsBackend.cc index 4e3ced0..65c1c6e 100644 --- a/src/macos/FSEventsBackend.cc +++ b/src/macos/FSEventsBackend.cc @@ -137,7 +137,7 @@ void FSEventsCallback( // If multiple flags were set, then we need to call `stat` to determine if the file really exists. // This helps disambiguate creates, updates, and deletes. struct stat file; - if (!pathExists(paths[i]) || stat(paths[i], &file)) { + if (stat(paths[i], &file) || !pathExists(paths[i])) { // File does not exist, so we have to assume it was removed. This is not exact since the // flags set by fsevents get coalesced together (e.g. created & deleted), so there is no way to // know whether the create and delete both happened since our snapshot (in which case