- if (kernel_policy->cond_custom_entitlement != NULL) {
- if (proc == NULL) {
- // No process found, cannot check entitlement
- return (FALSE);
- }
- task_t task = proc_task(proc);
- if (task == NULL ||
- !IOTaskHasEntitlement(task, kernel_policy->cond_custom_entitlement)) {
- // Process is missing custom entitlement
- return (FALSE);
+ if (kernel_policy->cond_custom_entitlement_matched == necp_boolean_state_false) {
+ // Process is missing entitlement based on previous check
+ return (FALSE);
+ } else if (kernel_policy->cond_custom_entitlement_matched == necp_boolean_state_unknown) {
+ if (kernel_policy->cond_custom_entitlement != NULL) {
+ if (proc == NULL) {
+ // No process found, cannot check entitlement
+ return (FALSE);
+ }
+ task_t task = proc_task(proc);
+ if (task == NULL ||
+ !IOTaskHasEntitlement(task, kernel_policy->cond_custom_entitlement)) {
+ // Process is missing custom entitlement
+ kernel_policy->cond_custom_entitlement_matched = necp_boolean_state_false;
+ return (FALSE);
+ } else {
+ kernel_policy->cond_custom_entitlement_matched = necp_boolean_state_true;
+ }