Skip to content

Commit

Permalink
Process unmount events first
Browse files Browse the repository at this point in the history
  • Loading branch information
mlw committed Apr 19, 2023
1 parent 5023257 commit de17843
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Source/santad/EventProviders/SNTEndpointSecurityDeviceManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ - (NSString *)description {

- (void)handleMessage:(Message &&)esMsg
recordEventMetrics:(void (^)(EventDisposition))recordEventMetrics {
// Process the unmount event first so that caches are flushed before any
// other potential early returns.
if (esMsg->event_type == ES_EVENT_TYPE_NOTIFY_UNMOUNT) {
self->_authResultCache->FlushCache(FlushCacheMode::kNonRootOnly);
recordEventMetrics(EventDisposition::kProcessed);
return;
}

if (!self.blockUSBMount) {
// TODO: We should also unsubscribe from events when this isn't set, but
// this is generally a low-volume event type.
Expand All @@ -180,12 +188,6 @@ - (void)handleMessage:(Message &&)esMsg
return;
}

if (esMsg->event_type == ES_EVENT_TYPE_NOTIFY_UNMOUNT) {
self->_authResultCache->FlushCache(FlushCacheMode::kNonRootOnly);
recordEventMetrics(EventDisposition::kProcessed);
return;
}

[self processMessage:std::move(esMsg)
handler:^(const Message &msg) {
es_auth_result_t result = [self handleAuthMount:msg];
Expand Down

0 comments on commit de17843

Please sign in to comment.