Path: blob/master/security/selinux/ss/conditional.h
10817 views
/* Authors: Karl MacMillan <[email protected]>1* Frank Mayer <[email protected]>2*3* Copyright (C) 2003 - 2004 Tresys Technology, LLC4* This program is free software; you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation, version 2.7*/89#ifndef _CONDITIONAL_H_10#define _CONDITIONAL_H_1112#include "avtab.h"13#include "symtab.h"14#include "policydb.h"1516#define COND_EXPR_MAXDEPTH 101718/*19* A conditional expression is a list of operators and operands20* in reverse polish notation.21*/22struct cond_expr {23#define COND_BOOL 1 /* plain bool */24#define COND_NOT 2 /* !bool */25#define COND_OR 3 /* bool || bool */26#define COND_AND 4 /* bool && bool */27#define COND_XOR 5 /* bool ^ bool */28#define COND_EQ 6 /* bool == bool */29#define COND_NEQ 7 /* bool != bool */30#define COND_LAST COND_NEQ31__u32 expr_type;32__u32 bool;33struct cond_expr *next;34};3536/*37* Each cond_node contains a list of rules to be enabled/disabled38* depending on the current value of the conditional expression. This39* struct is for that list.40*/41struct cond_av_list {42struct avtab_node *node;43struct cond_av_list *next;44};4546/*47* A cond node represents a conditional block in a policy. It48* contains a conditional expression, the current state of the expression,49* two lists of rules to enable/disable depending on the value of the50* expression (the true list corresponds to if and the false list corresponds51* to else)..52*/53struct cond_node {54int cur_state;55struct cond_expr *expr;56struct cond_av_list *true_list;57struct cond_av_list *false_list;58struct cond_node *next;59};6061int cond_policydb_init(struct policydb *p);62void cond_policydb_destroy(struct policydb *p);6364int cond_init_bool_indexes(struct policydb *p);65int cond_destroy_bool(void *key, void *datum, void *p);6667int cond_index_bool(void *key, void *datum, void *datap);6869int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp);70int cond_read_list(struct policydb *p, void *fp);71int cond_write_bool(void *key, void *datum, void *ptr);72int cond_write_list(struct policydb *p, struct cond_node *list, void *fp);7374void cond_compute_av(struct avtab *ctab, struct avtab_key *key, struct av_decision *avd);7576int evaluate_cond_node(struct policydb *p, struct cond_node *node);7778#endif /* _CONDITIONAL_H_ */798081