/* evaluate_cond_node evaluates the conditional stored in a struct cond_node and if the result is different than the current state of the node it sets the rules in the true/false list appropriately. If the result of the expression is undefined all of the rules are disabled for safety.  */
int evaluate_cond_node(struct policydb *p, struct cond_node *node)
/* evaluate_cond_node evaluates the conditional stored in a struct cond_node and if the result is different than the current state of the node it sets the rules in the true/false list appropriately. If the result of the expression is undefined all of the rules are disabled for safety.  */
int evaluate_cond_node(struct policydb *p, struct cond_node *node)
{
	int new_state;
	struct cond_av_list *cur;
	new_state = cond_evaluate_expr(p, node->expr);
	if (new_state != node->cur_state) {
		node->cur_state = new_state;
		if (new_state == -1)
			printk(KERN_ERR "SELinux: expression result was undefined - disabling all rules.\n");
		for (cur = node->true_list; cur; cur = cur->next) {
			if (new_state <= 0)
				cur->node->key.specified &= ~AVTAB_ENABLED;
			else
				cur->node->key.specified |= AVTAB_ENABLED;
		}
		for (cur = node->false_list; cur; cur = cur->next) {
			if (new_state)
				cur->node->key.specified &= ~AVTAB_ENABLED;
			else
				cur->node->key.specified |= AVTAB_ENABLED;
		}
	}
	return 0;
}