| 1 |
/* Author : Stephen Smalley, <[email protected]> */ |
| 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/ebitmap.h> |
| 22 |
#include <sepol/policydb/flask_types.h> |
| 23 |
|
| 24 |
#ifdef __cplusplus |
| 25 |
extern "C" { |
| 26 |
#endif |
| 27 |
|
| 28 |
#define CEXPR_MAXDEPTH 5 |
| 29 |
|
| 30 |
struct type_set; |
| 31 |
|
| 32 |
typedef struct constraint_expr { |
| 33 |
#define CEXPR_NOT 1 /* not expr */ |
| 34 |
#define CEXPR_AND 2 /* expr and expr */ |
| 35 |
#define CEXPR_OR 3 /* expr or expr */ |
| 36 |
#define CEXPR_ATTR 4 /* attr op attr */ |
| 37 |
#define CEXPR_NAMES 5 /* attr op names */ |
| 38 |
uint32_t expr_type; /* expression type */ |
| 39 |
|
| 40 |
#define CEXPR_USER 1 /* user */ |
| 41 |
#define CEXPR_ROLE 2 /* role */ |
| 42 |
#define CEXPR_TYPE 4 /* type */ |
| 43 |
#define CEXPR_TARGET 8 /* target if set, source otherwise */ |
| 44 |
#define CEXPR_XTARGET 16 /* special 3rd target for validatetrans rule */ |
| 45 |
#define CEXPR_L1L2 32 /* low level 1 vs. low level 2 */ |
| 46 |
#define CEXPR_L1H2 64 /* low level 1 vs. high level 2 */ |
| 47 |
#define CEXPR_H1L2 128 /* high level 1 vs. low level 2 */ |
| 48 |
#define CEXPR_H1H2 256 /* high level 1 vs. high level 2 */ |
| 49 |
#define CEXPR_L1H1 512 /* low level 1 vs. high level 1 */ |
| 50 |
#define CEXPR_L2H2 1024 /* low level 2 vs. high level 2 */ |
| 51 |
uint32_t attr; /* attribute */ |
| 52 |
|
| 53 |
#define CEXPR_EQ 1 /* == or eq */ |
| 54 |
#define CEXPR_NEQ 2 /* != */ |
| 55 |
#define CEXPR_DOM 3 /* dom */ |
| 56 |
#define CEXPR_DOMBY 4 /* domby */ |
| 57 |
#define CEXPR_INCOMP 5 /* incomp */ |
| 58 |
uint32_t op; /* operator */ |
| 59 |
|
| 60 |
ebitmap_t names; /* names */ |
| 61 |
struct type_set *type_names; |
| 62 |
|
| 63 |
struct constraint_expr *next; /* next expression */ |
| 64 |
} constraint_expr_t; |
| 65 |
|
| 66 |
typedef struct constraint_node { |
| 67 |
sepol_access_vector_t permissions; /* constrained permissions */ |
| 68 |
constraint_expr_t *expr; /* constraint on permissions */ |
| 69 |
struct constraint_node *next; /* next constraint */ |
| 70 |
} constraint_node_t; |
| 71 |
|
| 72 |
extern int constraint_expr_init(constraint_expr_t * expr); |
| 73 |
extern void constraint_expr_destroy(constraint_expr_t * expr); |
| 74 |
|
| 75 |
#ifdef __cplusplus |
| 76 |
} |
| 77 |
#endif |
| 78 |
|
| 79 |
#endif /* _CONSTRAINT_H_ */ |
| 80 |
|
| 81 |
/* FLASK */ |