libsepol: add support for filenametrans rules
PATCH 1/1 libsepol: add support for filenametrans rules
This patch add libsepol support for filename_trans rules. These rules allow on to make labeling decisions for new objects based partially on the last path component. They are stored in a list. If we find that the number of rules grows to an significant size I will likely choose to store these in a hash, both in libsepol and in the kernel. But as long as the number of such rules stays small, this should be good.
---
include/sepol/policydb/policydb.h renamed from include/sepol/policydb/policydb.h.eparis +31 -2
@@ -135,6 +135,16 @@ typedef struct role_allow {struct role_allow *next; } role_allow_t; +/* filename_trans rules */ +typedef struct filename_trans { +uint32_t stype; +uint32_t ttype; +uint32_t tclass; +char *name; +uint32_t otype; +struct filename_trans *next; +}filename_trans_t ; +/* Type attributes */ typedef struct type_datum { symtab_datum_t s;
@@ -245,6 +255,15 @@ typedef struct role_allow_rule {struct role_allow_rule *next; } role_allow_rule_t; +typedef struct filename_trans_rule { +type_set_t stypes; +type_set_t ttypes; +uint32_t tclass; +char *name; +uint32_t otype;/* new type */ +struct filename_trans_rule *next; +}filename_trans_rule_t ; + typedef struct range_trans_rule { type_set_t stypes; type_set_t ttypes;
@@ -374,6 +393,9 @@ typedef struct avrule_decl {scope_index_t required;/* symbols needed to activate this block */ scope_index_t declared;/* symbols declared within this block */ +/* type transition rules with a 'name' component */ +filename_trans_rule_t *filename_trans_rules; +/* for additive statements (type attribute, roles, and users) */ symtab_t symtab[SYM_NUM ];
@@ -484,6 +506,9 @@ typedef struct policydb {/* role transitions */ role_trans_t *role_tr; +/* type transition rules with a 'name' component */ +filename_trans_t *filename_trans; +/* role allows */ role_allow_t *role_allow;
@@ -562,6 +587,8 @@ extern void avrule_destroy(avrule_t * x)extern void avrule_list_destroy (avrule_t * x);extern void role_trans_rule_init (role_trans_rule_t * x);extern void role_trans_rule_list_destroy (role_trans_rule_t * x); +extern void filename_trans_rule_init (filename_trans_rule_t * x); +extern void filename_trans_rule_list_destroy (filename_trans_rule_t * x);extern void role_datum_init (role_datum_t * x);extern void role_datum_destroy (role_datum_t * x);
@@ -630,10 +657,11 @@ extern int policydb_set_target_platform(#define POLICYDB_VERSION_POLCAP 22#define POLICYDB_VERSION_PERMISSIVE 23#define POLICYDB_VERSION_BOUNDARY 24 +#define POLICYDB_VERSION_FILENAME_TRANS 25/* Range of policy versions we understand*/ #define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE -#define POLICYDB_VERSION_MAX POLICYDB_VERSION_BOUNDARY +#define POLICYDB_VERSION_MAX POLICYDB_VERSION_FILENAME_TRANS/* Module versions and specific changes*/ #define MOD_POLICYDB_VERSION_BASE 4
@@ -645,9 +673,10 @@ extern int policydb_set_target_platform(#define MOD_POLICYDB_VERSION_PERMISSIVE 8#define MOD_POLICYDB_VERSION_BOUNDARY 9#define MOD_POLICYDB_VERSION_BOUNDARY_ALIAS 10 +#define MOD_POLICYDB_VERSION_FILENAME_TRANS 11#define MOD_POLICYDB_VERSION_MIN MOD_POLICYDB_VERSION_BASE -#define MOD_POLICYDB_VERSION_MAX MOD_POLICYDB_VERSION_BOUNDARY_ALIAS +#define MOD_POLICYDB_VERSION_MAX MOD_POLICYDB_VERSION_FILENAME_TRANS#define POLICYDB_CONFIG_MLS 1
src/avrule_block.c renamed from src/avrule_block.c.eparis +1 -0
@@ -98,6 +98,7 @@ void avrule_decl_destroy(avrule_decl_t *cond_list_destroy (x->cond_list);avrule_list_destroy (x->avrules);role_trans_rule_list_destroy (x->role_tr_rules); +filename_trans_rule_list_destroy (x->filename_trans_rules);role_allow_rule_list_destroy (x->role_allow_rules);range_trans_rule_list_destroy (x->range_tr_rules);scope_index_destroy (&x->required);
src/expand.c renamed from src/expand.c.eparis +98 -0
110 lines not on this page · raw message
src/link.c renamed from src/link.c.eparis +49 -0
61 lines not on this page · raw message
src/policydb.c renamed from src/policydb.c.eparis +170 -0
230 lines not on this page · raw message
src/write.c renamed from src/write.c.eparis +85 -0
109 lines not on this page · raw message
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.