Open luckman212 opened 3 years ago
leaving this crosspost here as well: Any sane way to log iCloud Drive file activity? - Ask Different
Just a comment, all those e_types are not logged currently by filemonitor. Just some of them. Check source. Just in csse you were expecting events from permission changes etc.
Thanks @tigersoul925 - I'm on Ventura now so there's a built in tool called eslogger
that can be used to capture these kinds of events coming through the Endpoint Security log.
Thanks @tigersoul925 - I'm on Ventura now so there's a built in tool called
eslogger
that can be used to capture these kinds of events coming through the Endpoint Security log.
Oh wow I was NOT aware of eslogger and it looks great as I potentielly could get updates of permission changes etc as well now which filemonitor does not support.
How is your experience with eslogger? Does it work well? It seems in the man pages that it isn't really meant for true usage:
eslogger is not intended to be used by applications. It is not meant provide the same functionality, performance and schema stability as natively interfacing with the Endpoint Security API does. It cannot provide the integrity protection granted to System Extensions. Applications should continue to interface with EndpointSecurity(7) natively.
It's a great tool, has helped me a lot and works fine. I think the warning is to discourage people from lazily forking out to it from inside their apps instead of properly interfacing with the ESF API.
It's a great tool, has helped me a lot and works fine. I think the warning is to discourage people from lazily forking out to it from inside their apps instead of properly interfacing with the ESF API.
I see. Got to try it soon. Sounds great. Just a shame it didn't appear earlier.
I've been trying to use FileMonitor to track down a really annoying and elusive bug with 0-byte files (files getting spuriously emptied and losing their data). I'm trying to trigger this bug while FileMonitor is running, and I'm seeing some weird behavior where it seems as if iCloud's daemons (
bird
and whatever other daemons run in the background and handle iCloud file sync) are able to modify the filesystem right under the nose of tools like FileMonitor.Here's a POC script for testing - requires jq (
brew install jq
)poor-mans-fsusage.sh
Running this script and then creating/updating the
xyzzy.txt
file at the root of iCloud Drive with common tools like Sublime Text,echo foo >>xyzzy.txt
orrm xyzzy.txt
produces output like this:However, if I open this file up on my iPhone (using Files.app) and modify it there, a strange thing happens. No
ES_EVENT_TYPE_NOTIFY_WRITE
events are seen. Yet the file somehow gets updated. It appears that maybe there is some sort of atomic saving going on (temp file saving, moving (renaming) the original, replacing etc. But I can't be sure. Here's a sample of the output:If I change the filtering to log all
NOTIFY_WRITE
s, I get a flurry of activity (I de-duped all the log lines below otherwise it would be pages long)output:
So it looks like a bunch of other helpers are involved in a simple file update on iCloud. I see
nsurlsessiond
,cloudd
,nehelper
... is there any sane way to log this type of activity?