Skip to content

Commit

Permalink
fix cache invalidation on macOS Mojave (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
tburgin authored Sep 21, 2018
1 parent 5e3f13b commit 2d98173
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion Source/santa-driver/SantaDecisionManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,17 @@ int SantaDecisionManager::VnodeCallback(const kauth_cred_t cred,
void SantaDecisionManager::FileOpCallback(
const kauth_action_t action, const vnode_t vp,
const char *path, const char *new_path) {
if (!ClientConnected() || proc_selfpid() == client_pid_) return;
if (!ClientConnected()) return;

// KAUTH_FILEOP_CLOSE implies KAUTH_FILEOP_CLOSE_MODIFIED, so remove it from the cache.
if (action == KAUTH_FILEOP_CLOSE) {
auto context = vfs_context_create(nullptr);
RemoveFromCache(GetVnodeIDForVnode(context, vp));
vfs_context_rele(context);
}

// Don't log santad fileops.
if (proc_selfpid() == client_pid_) return;

if (vp && action == KAUTH_FILEOP_EXEC) {
auto context = vfs_context_create(nullptr);
Expand Down
2 changes: 1 addition & 1 deletion Tests/KernelTests/main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ - (void)testNoTransitiveRules {
[hello waitUntilExit];
TFAILINFO("Should not have been able to launch /private/tmp/hello");
} @catch (NSException *exception) {
TPASS();
// All good
}
// Check that there wasn't a decision for /private/tmp/hello in the cache.
if (helloCount != 1) {
Expand Down

0 comments on commit 2d98173

Please sign in to comment.