Home | History | Annotate | Download | only in policydb
      1 
      2 /* Author : Stephen Smalley, <sds (at) epoch.ncsc.mil> */
      3 
      4 /* FLASK */
      5 
      6 /*
      7  * A constraint is a condition that must be satisfied in
      8  * order for one or more permissions to be granted.
      9  * Constraints are used to impose additional restrictions
     10  * beyond the type-based rules in `te' or the role-based
     11  * transition rules in `rbac'.  Constraints are typically
     12  * used to prevent a process from transitioning to a new user
     13  * identity or role unless it is in a privileged type.
     14  * Constraints are likewise typically used to prevent a
     15  * process from labeling an object with a different user
     16  * identity.
     17  */
     18 
     19 #ifndef _SEPOL_POLICYDB_CONSTRAINT_H_
     20 #define _SEPOL_POLICYDB_CONSTRAINT_H_
     21 
     22 #include <sepol/policydb/policydb.h>
     23 #include <sepol/policydb/ebitmap.h>
     24 #include <sepol/policydb/flask_types.h>
     25 
     26 #define CEXPR_MAXDEPTH 5
     27 
     28 struct type_set;
     29 
     30 typedef struct constraint_expr {
     31 #define CEXPR_NOT		1	/* not expr */
     32 #define CEXPR_AND		2	/* expr and expr */
     33 #define CEXPR_OR		3	/* expr or expr */
     34 #define CEXPR_ATTR		4	/* attr op attr */
     35 #define CEXPR_NAMES		5	/* attr op names */
     36 	uint32_t expr_type;	/* expression type */
     37 
     38 #define CEXPR_USER 1		/* user */
     39 #define CEXPR_ROLE 2		/* role */
     40 #define CEXPR_TYPE 4		/* type */
     41 #define CEXPR_TARGET 8		/* target if set, source otherwise */
     42 #define CEXPR_XTARGET 16	/* special 3rd target for validatetrans rule */
     43 #define CEXPR_L1L2 32		/* low level 1 vs. low level 2 */
     44 #define CEXPR_L1H2 64		/* low level 1 vs. high level 2 */
     45 #define CEXPR_H1L2 128		/* high level 1 vs. low level 2 */
     46 #define CEXPR_H1H2 256		/* high level 1 vs. high level 2 */
     47 #define CEXPR_L1H1 512		/* low level 1 vs. high level 1 */
     48 #define CEXPR_L2H2 1024		/* low level 2 vs. high level 2 */
     49 	uint32_t attr;		/* attribute */
     50 
     51 #define CEXPR_EQ     1		/* == or eq */
     52 #define CEXPR_NEQ    2		/* != */
     53 #define CEXPR_DOM    3		/* dom */
     54 #define CEXPR_DOMBY  4		/* domby  */
     55 #define CEXPR_INCOMP 5		/* incomp */
     56 	uint32_t op;		/* operator */
     57 
     58 	ebitmap_t names;	/* names */
     59 	struct type_set *type_names;
     60 
     61 	struct constraint_expr *next;	/* next expression */
     62 } constraint_expr_t;
     63 
     64 typedef struct constraint_node {
     65 	sepol_access_vector_t permissions;	/* constrained permissions */
     66 	constraint_expr_t *expr;	/* constraint on permissions */
     67 	struct constraint_node *next;	/* next constraint */
     68 } constraint_node_t;
     69 
     70 struct policydb;
     71 
     72 extern int constraint_expr_init(constraint_expr_t * expr);
     73 extern void constraint_expr_destroy(constraint_expr_t * expr);
     74 
     75 #endif				/* _CONSTRAINT_H_ */
     76 
     77 /* FLASK */
     78