Commit 89d4d7c8 authored by Ondrej Mosnacek's avatar Ondrej Mosnacek Committed by Paul Moore

selinux: generalize evaluate_cond_node()

Both callers iterate the cond_list and call it for each node - turn it
into evaluate_cond_nodes(), which does the iteration for them.
Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 8794d783
...@@ -86,7 +86,7 @@ static int cond_evaluate_expr(struct policydb *p, struct cond_expr *expr) ...@@ -86,7 +86,7 @@ static int cond_evaluate_expr(struct policydb *p, struct cond_expr *expr)
* list appropriately. If the result of the expression is undefined * list appropriately. If the result of the expression is undefined
* all of the rules are disabled for safety. * all of the rules are disabled for safety.
*/ */
void evaluate_cond_node(struct policydb *p, struct cond_node *node) static void evaluate_cond_node(struct policydb *p, struct cond_node *node)
{ {
struct avtab_node *avnode; struct avtab_node *avnode;
int new_state; int new_state;
...@@ -117,6 +117,14 @@ void evaluate_cond_node(struct policydb *p, struct cond_node *node) ...@@ -117,6 +117,14 @@ void evaluate_cond_node(struct policydb *p, struct cond_node *node)
} }
} }
void evaluate_cond_nodes(struct policydb *p)
{
u32 i;
for (i = 0; i < p->cond_list_len; i++)
evaluate_cond_node(p, &p->cond_list[i]);
}
int cond_policydb_init(struct policydb *p) int cond_policydb_init(struct policydb *p)
{ {
int rc; int rc;
......
...@@ -78,6 +78,6 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key, ...@@ -78,6 +78,6 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key,
struct av_decision *avd, struct extended_perms *xperms); struct av_decision *avd, struct extended_perms *xperms);
void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key, void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key,
struct extended_perms_decision *xpermd); struct extended_perms_decision *xpermd);
void evaluate_cond_node(struct policydb *p, struct cond_node *node); void evaluate_cond_nodes(struct policydb *p);
#endif /* _CONDITIONAL_H_ */ #endif /* _CONDITIONAL_H_ */
...@@ -2957,8 +2957,7 @@ int security_set_bools(struct selinux_state *state, u32 len, int *values) ...@@ -2957,8 +2957,7 @@ int security_set_bools(struct selinux_state *state, u32 len, int *values)
policydb->bool_val_to_struct[i]->state = 0; policydb->bool_val_to_struct[i]->state = 0;
} }
for (i = 0; i < policydb->cond_list_len; i++) evaluate_cond_nodes(policydb);
evaluate_cond_node(policydb, &policydb->cond_list[i]);
seqno = ++state->ss->latest_granting; seqno = ++state->ss->latest_granting;
rc = 0; rc = 0;
...@@ -3011,8 +3010,7 @@ static int security_preserve_bools(struct selinux_state *state, ...@@ -3011,8 +3010,7 @@ static int security_preserve_bools(struct selinux_state *state,
if (booldatum) if (booldatum)
booldatum->state = bvalues[i]; booldatum->state = bvalues[i];
} }
for (i = 0; i < policydb->cond_list_len; i++) evaluate_cond_nodes(policydb);
evaluate_cond_node(policydb, &policydb->cond_list[i]);
out: out:
if (bnames) { if (bnames) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment