• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 Tresys Technology, LLC. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *    1. Redistributions of source code must retain the above copyright notice,
8  *       this list of conditions and the following disclaimer.
9  *
10  *    2. Redistributions in binary form must reproduce the above copyright notice,
11  *       this list of conditions and the following disclaimer in the documentation
12  *       and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY TRESYS TECHNOLOGY, LLC ``AS IS'' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17  * EVENT SHALL TRESYS TECHNOLOGY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * The views and conclusions contained in the software and documentation are those
26  * of the authors and should not be interpreted as representing official policies,
27  * either expressed or implied, of Tresys Technology, LLC.
28  */
29 
30 #ifndef CIL_BUILD_AST_H_
31 #define CIL_BUILD_AST_H_
32 
33 #include <stdint.h>
34 
35 #include "cil_internal.h"
36 #include "cil_flavor.h"
37 #include "cil_tree.h"
38 #include "cil_list.h"
39 
40 int cil_gen_node(struct cil_db *db, struct cil_tree_node *ast_node, struct cil_symtab_datum *datum, hashtab_key_t key, enum cil_sym_index sflavor, enum cil_flavor nflavor);
41 int cil_parse_to_list(struct cil_tree_node *parse_cl_head, struct cil_list *ast_cl, enum cil_flavor flavor);
42 
43 int cil_gen_block(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, uint16_t is_abstract);
44 void cil_destroy_block(struct cil_block *block);
45 int cil_gen_blockinherit(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
46 void cil_destroy_blockinherit(struct cil_blockinherit *inherit);
47 int cil_gen_blockabstract(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
48 void cil_destroy_blockabstract(struct cil_blockabstract *abstract);
49 int cil_gen_in(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
50 void cil_destroy_in(struct cil_in *in);
51 int cil_gen_class(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
52 void cil_destroy_class(struct cil_class *class);
53 int cil_gen_classorder(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
54 void cil_destroy_classorder(struct cil_classorder *classorder);
55 int cil_gen_perm(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor, unsigned int *num_perms);
56 void cil_destroy_perm(struct cil_perm *perm);
57 int cil_gen_perm_nodes(struct cil_db *db, struct cil_tree_node *current_perm, struct cil_tree_node *ast_node, enum cil_flavor flavor, unsigned int *num_perms);
58 int cil_fill_perms(struct cil_tree_node *start_perm, struct cil_list **perm_strs);
59 int cil_fill_classperms(struct cil_tree_node *parse_current, struct cil_classperms **cp);
60 void cil_destroy_classperms(struct cil_classperms *cp);
61 void cil_fill_classperms_set(struct cil_tree_node *parse_current, struct cil_classperms_set **cp_set);
62 void cil_destroy_classperms_set(struct cil_classperms_set *cp_set);
63 int cil_fill_classperms_list(struct cil_tree_node *parse_current, struct cil_list **expr_list);
64 void cil_destroy_classperms_list(struct cil_list **cp_list);
65 int cil_gen_classpermission(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
66 void cil_destroy_classpermission(struct cil_classpermission *cp);
67 int cil_gen_classpermissionset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
68 void cil_destroy_classpermissionset(struct cil_classpermissionset *cps);
69 int cil_gen_map_class(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
70 int cil_gen_classmapping(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
71 void cil_destroy_classmapping(struct cil_classmapping *mapping);
72 int cil_gen_common(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
73 int cil_gen_classcommon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
74 void cil_destroy_classcommon(struct cil_classcommon *clscom);
75 int cil_gen_sid(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
76 void cil_destroy_sid(struct cil_sid *sid);
77 int cil_gen_sidcontext(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
78 void cil_destroy_sidcontext(struct cil_sidcontext *sidcon);
79 int cil_gen_sidorder(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
80 void cil_destroy_sidorder(struct cil_sidorder *sidorder);
81 int cil_gen_user(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
82 void cil_destroy_user(struct cil_user *user);
83 int cil_gen_userattribute(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
84 void cil_destroy_userattribute(struct cil_userattribute *attr);
85 int cil_gen_userattributeset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
86 void cil_destroy_userattributeset(struct cil_userattributeset *attrset);
87 int cil_gen_userlevel(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
88 void cil_destroy_userlevel(struct cil_userlevel *usrlvl);
89 int cil_gen_userrange(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
90 void cil_destroy_userrange(struct cil_userrange *userrange);
91 int cil_gen_userbounds(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
92 int cil_gen_userprefix(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
93 void cil_destroy_userprefix(struct cil_userprefix *userprefix);
94 int cil_gen_selinuxuser(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
95 int cil_gen_selinuxuserdefault(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
96 void cil_destroy_selinuxuser(struct cil_selinuxuser *selinuxuser);
97 int cil_gen_role(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
98 void cil_destroy_role(struct cil_role *role);
99 int cil_gen_roletype(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
100 void cil_destroy_roletype(struct cil_roletype *roletype);
101 int cil_gen_userrole(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
102 void cil_destroy_userrole(struct cil_userrole *userrole);
103 int cil_gen_roletransition(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
104 void cil_destroy_roletransition(struct cil_roletransition *roletrans);
105 int cil_gen_roleallow(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
106 void cil_destroy_roleallow(struct cil_roleallow *roleallow);
107 int cil_gen_roleattribute(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
108 void cil_destroy_roleattribute(struct cil_roleattribute *role);
109 int cil_gen_roleattributeset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
110 void cil_destroy_roleattributeset(struct cil_roleattributeset *attrset);
111 int cil_gen_rolebounds(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
112 int cil_gen_avrule(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, uint32_t rule_kind);
113 void cil_destroy_avrule(struct cil_avrule *rule);
114 int cil_gen_avrulex(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, uint32_t rule_kind);
115 int cil_gen_permissionx(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
116 void cil_destroy_permissionx(struct cil_permissionx *permx);
117 int cil_gen_type_rule(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, uint32_t rule_kind);
118 void cil_destroy_type_rule(struct cil_type_rule *rule);
119 int cil_gen_type(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
120 void cil_destroy_type(struct cil_type *type);
121 int cil_gen_typeattribute(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
122 void cil_destroy_typeattribute(struct cil_typeattribute *type);
123 int cil_gen_bool(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, int tunableif);
124 void cil_destroy_bool(struct cil_bool *boolean);
125 int cil_gen_tunable(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
126 void cil_destroy_tunable(struct cil_tunable *tunable);
127 int cil_gen_constrain_expr(struct cil_tree_node *current, enum cil_flavor flavor, struct cil_list **stack);
128 int cil_gen_expr(struct cil_tree_node *current, enum cil_flavor flavor, struct cil_list **stack);
129 int cil_gen_boolif(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, int tunable_if);
130 void cil_destroy_boolif(struct cil_booleanif *bif);
131 int cil_gen_tunif(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
132 void cil_destroy_tunif(struct cil_tunableif *tif);
133 int cil_gen_condblock(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor);
134 void cil_destroy_condblock(struct cil_condblock *cb);
135 int cil_gen_alias(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor);
136 void cil_destroy_alias(struct cil_alias *alias);
137 int cil_gen_aliasactual(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor);
138 void cil_destroy_aliasactual(struct cil_aliasactual *aliasactual);
139 int cil_gen_typeattributeset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
140 void cil_destroy_typeattributeset(struct cil_typeattributeset *attrtypes);
141 int cil_gen_expandtypeattribute(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
142 void cil_destroy_expandtypeattribute(struct cil_expandtypeattribute *expandattr);
143 int cil_gen_typebounds(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
144 int cil_gen_typepermissive(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
145 void cil_destroy_typepermissive(struct cil_typepermissive *typeperm);
146 int cil_gen_typetransition(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
147 void cil_destroy_name(struct cil_name *name);
148 void cil_destroy_typetransition(struct cil_nametypetransition *nametypetrans);
149 int cil_gen_rangetransition(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
150 void cil_destroy_rangetransition(struct cil_rangetransition *rangetrans);
151 int cil_gen_sensitivity(struct cil_db *idb, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
152 void cil_destroy_sensitivity(struct cil_sens *sens);
153 int cil_gen_category(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
154 void cil_destroy_category(struct cil_cat *cat);
155 int cil_set_to_list(struct cil_tree_node *parse_current, struct cil_list *ast_cl);
156 void cil_destroy_catset(struct cil_catset *catset);
157 int cil_gen_catorder(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
158 void cil_destroy_catorder(struct cil_catorder *catorder);
159 int cil_gen_sensitivityorder(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
160 void cil_destroy_sensitivityorder(struct cil_sensorder *sensorder);
161 int cil_gen_senscat(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
162 void cil_destroy_senscat(struct cil_senscat *senscat);
163 int cil_gen_level(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
164 void cil_destroy_level(struct cil_level *level);
165 int cil_fill_levelrange(struct cil_tree_node *low, struct cil_levelrange *lvlrange);
166 int cil_gen_levelrange(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
167 void cil_destroy_levelrange(struct cil_levelrange *lvlrange);
168 void cil_destroy_constrain_node(struct cil_tree_node *cons_node);
169 int cil_gen_constrain(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor);
170 void cil_destroy_constrain(struct cil_constrain *cons);
171 int cil_gen_validatetrans(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor);
172 void cil_destroy_validatetrans(struct cil_validatetrans *validtrans);
173 int cil_fill_context(struct cil_tree_node *user_node, struct cil_context *context);
174 int cil_gen_context(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
175 void cil_destroy_context(struct cil_context *context);
176 int cil_gen_filecon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
177 void cil_destroy_filecon(struct cil_filecon *filecon);
178 int cil_gen_ibpkeycon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
179 void cil_destroy_ibpkeycon(struct cil_ibpkeycon *ibpkeycon);
180 int cil_gen_ibendportcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
181 void cil_destroy_ibendportcon(struct cil_ibendportcon *ibendportcon);
182 int cil_gen_portcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
183 void cil_destroy_portcon(struct cil_portcon *portcon);
184 int cil_gen_nodecon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
185 void cil_destroy_nodecon(struct cil_nodecon *nodecon);
186 int cil_gen_genfscon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
187 void cil_destroy_genfscon(struct cil_genfscon *genfscon);
188 int cil_gen_netifcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
189 void cil_destroy_netifcon(struct cil_netifcon *netifcon);
190 int cil_gen_pirqcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
191 void cil_destroy_pirqcon(struct cil_pirqcon *pirqcon);
192 int cil_gen_iomemcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
193 void cil_destroy_iomemcon(struct cil_iomemcon *iomemcon);
194 int cil_gen_ioportcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
195 void cil_destroy_ioportcon(struct cil_ioportcon *ioportcon);
196 int cil_gen_pcidevicecon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
197 void cil_destroy_pcidevicecon(struct cil_pcidevicecon *pcidevicecon);
198 int cil_gen_devicetreecon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
199 void cil_destroy_devicetreecon(struct cil_devicetreecon *devicetreecon);
200 int cil_gen_fsuse(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
201 void cil_destroy_fsuse(struct cil_fsuse *fsuse);
202 void cil_destroy_param(struct cil_param *param);
203 int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
204 void cil_destroy_macro(struct cil_macro *macro);
205 int cil_gen_call(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
206 void cil_destroy_call(struct cil_call *call);
207 void cil_destroy_args(struct cil_args *args);
208 int cil_gen_optional(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
209 void cil_destroy_optional(struct cil_optional *optional);
210 int cil_gen_policycap(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
211 void cil_destroy_policycap(struct cil_policycap *polcap);
212 int cil_gen_ipaddr(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
213 void cil_destroy_ipaddr(struct cil_ipaddr *ipaddr);
214 int cil_gen_bounds(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor);
215 void cil_destroy_bounds(struct cil_bounds *bounds);
216 int cil_gen_default(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor);
217 void cil_destroy_default(struct cil_default *def);
218 int cil_gen_handleunknown(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
219 void cil_destroy_handleunknown(struct cil_handleunknown *unk);
220 int cil_gen_mls(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
221 void cil_destroy_mls(struct cil_mls *mls);
222 int cil_gen_defaultrange(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
223 void cil_destroy_defaultrange(struct cil_defaultrange *def);
224 int cil_gen_src_info(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
225 void cil_destroy_src_info(struct cil_src_info *info);
226 
227 int cil_fill_cats(struct cil_tree_node *curr, struct cil_cats **cats);
228 void cil_destroy_cats(struct cil_cats *cats);
229 int cil_fill_context(struct cil_tree_node *user_node, struct cil_context *context);
230 int cil_fill_integer(struct cil_tree_node *int_node, uint32_t *integer, int base);
231 int cil_fill_integer64(struct cil_tree_node *int_node, uint64_t *integer, int base);
232 int cil_fill_ipaddr(struct cil_tree_node *addr_node, struct cil_ipaddr *addr);
233 int cil_fill_level(struct cil_tree_node *sens, struct cil_level *level);
234 
235 int cil_build_ast(struct cil_db *db, struct cil_tree_node *parse_tree, struct cil_tree_node *ast);
236 
237 #endif /* CIL_BUILD_AST_H_ */
238