constraint.h 2.4 KB

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