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