| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* Authors: Karl MacMillan <kmacmillan@tresys.com> |
|---|
| 2 | 3 | * Frank Mayer <mayerf@tresys.com> |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2003 - 2004 Tresys Technology, LLC |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 7 | | - * the Free Software Foundation, version 2. |
|---|
| 8 | 6 | */ |
|---|
| 9 | 7 | |
|---|
| 10 | 8 | #ifndef _CONDITIONAL_H_ |
|---|
| .. | .. |
|---|
| 21 | 19 | * A conditional expression is a list of operators and operands |
|---|
| 22 | 20 | * in reverse polish notation. |
|---|
| 23 | 21 | */ |
|---|
| 24 | | -struct cond_expr { |
|---|
| 22 | +struct cond_expr_node { |
|---|
| 25 | 23 | #define COND_BOOL 1 /* plain bool */ |
|---|
| 26 | 24 | #define COND_NOT 2 /* !bool */ |
|---|
| 27 | 25 | #define COND_OR 3 /* bool || bool */ |
|---|
| .. | .. |
|---|
| 30 | 28 | #define COND_EQ 6 /* bool == bool */ |
|---|
| 31 | 29 | #define COND_NEQ 7 /* bool != bool */ |
|---|
| 32 | 30 | #define COND_LAST COND_NEQ |
|---|
| 33 | | - __u32 expr_type; |
|---|
| 34 | | - __u32 bool; |
|---|
| 35 | | - struct cond_expr *next; |
|---|
| 31 | + u32 expr_type; |
|---|
| 32 | + u32 bool; |
|---|
| 33 | +}; |
|---|
| 34 | + |
|---|
| 35 | +struct cond_expr { |
|---|
| 36 | + struct cond_expr_node *nodes; |
|---|
| 37 | + u32 len; |
|---|
| 36 | 38 | }; |
|---|
| 37 | 39 | |
|---|
| 38 | 40 | /* |
|---|
| .. | .. |
|---|
| 41 | 43 | * struct is for that list. |
|---|
| 42 | 44 | */ |
|---|
| 43 | 45 | struct cond_av_list { |
|---|
| 44 | | - struct avtab_node *node; |
|---|
| 45 | | - struct cond_av_list *next; |
|---|
| 46 | + struct avtab_node **nodes; |
|---|
| 47 | + u32 len; |
|---|
| 46 | 48 | }; |
|---|
| 47 | 49 | |
|---|
| 48 | 50 | /* |
|---|
| .. | .. |
|---|
| 54 | 56 | */ |
|---|
| 55 | 57 | struct cond_node { |
|---|
| 56 | 58 | int cur_state; |
|---|
| 57 | | - struct cond_expr *expr; |
|---|
| 58 | | - struct cond_av_list *true_list; |
|---|
| 59 | | - struct cond_av_list *false_list; |
|---|
| 60 | | - struct cond_node *next; |
|---|
| 59 | + struct cond_expr expr; |
|---|
| 60 | + struct cond_av_list true_list; |
|---|
| 61 | + struct cond_av_list false_list; |
|---|
| 61 | 62 | }; |
|---|
| 62 | 63 | |
|---|
| 63 | | -int cond_policydb_init(struct policydb *p); |
|---|
| 64 | +void cond_policydb_init(struct policydb *p); |
|---|
| 64 | 65 | void cond_policydb_destroy(struct policydb *p); |
|---|
| 65 | 66 | |
|---|
| 66 | 67 | int cond_init_bool_indexes(struct policydb *p); |
|---|
| .. | .. |
|---|
| 68 | 69 | |
|---|
| 69 | 70 | int cond_index_bool(void *key, void *datum, void *datap); |
|---|
| 70 | 71 | |
|---|
| 71 | | -int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp); |
|---|
| 72 | +int cond_read_bool(struct policydb *p, struct symtab *s, void *fp); |
|---|
| 72 | 73 | int cond_read_list(struct policydb *p, void *fp); |
|---|
| 73 | 74 | int cond_write_bool(void *key, void *datum, void *ptr); |
|---|
| 74 | | -int cond_write_list(struct policydb *p, struct cond_node *list, void *fp); |
|---|
| 75 | +int cond_write_list(struct policydb *p, void *fp); |
|---|
| 75 | 76 | |
|---|
| 76 | 77 | void cond_compute_av(struct avtab *ctab, struct avtab_key *key, |
|---|
| 77 | 78 | struct av_decision *avd, struct extended_perms *xperms); |
|---|
| 78 | 79 | void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key, |
|---|
| 79 | 80 | struct extended_perms_decision *xpermd); |
|---|
| 80 | | -int evaluate_cond_node(struct policydb *p, struct cond_node *node); |
|---|
| 81 | +void evaluate_cond_nodes(struct policydb *p); |
|---|
| 82 | +void cond_policydb_destroy_dup(struct policydb *p); |
|---|
| 83 | +int cond_policydb_dup(struct policydb *new, struct policydb *orig); |
|---|
| 81 | 84 | |
|---|
| 82 | 85 | #endif /* _CONDITIONAL_H_ */ |
|---|