Lines Matching refs:parse_current
186 int cil_gen_block(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, uint16_t is_abstract)
199 if (db == NULL || parse_current == NULL || ast_node == NULL) {
203 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
212 key = parse_current->next->data;
222 cil_tree_log(parse_current, CIL_ERR, "Bad block declaration");
241 int cil_gen_blockinherit(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
252 if (db == NULL || parse_current == NULL || ast_node == NULL) {
256 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
263 inherit->block_str = parse_current->next->data;
271 cil_tree_log(parse_current, CIL_ERR, "Bad blockinherit declaration");
285 int cil_gen_blockabstract(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
296 if (db == NULL || parse_current == NULL || ast_node == NULL) {
300 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
307 abstract->block_str = parse_current->next->data;
315 cil_tree_log(parse_current, CIL_ERR, "Bad blockabstract declaration");
329 int cil_gen_in(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
341 if (db == NULL || parse_current == NULL || ast_node == NULL) {
345 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
352 in->block_str = parse_current->next->data;
359 cil_tree_log(parse_current, CIL_ERR, "Bad in statement");
375 int cil_gen_class(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
389 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
396 key = parse_current->next->data;
408 if (parse_current->next->next != NULL) {
409 perms = parse_current->next->next->cl_head;
415 cil_tree_log(parse_current, CIL_ERR, "Too many permissions in class '%s'", class->datum.name);
424 cil_tree_log(parse_current, CIL_ERR, "Bad class declaration");
442 int cil_gen_classorder(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
455 if (db == NULL || parse_current == NULL || ast_node == NULL) {
459 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
466 rc = cil_fill_list(parse_current->next->cl_head, CIL_CLASSORDER, &classorder->class_list_str);
492 cil_tree_log(parse_current, CIL_ERR, "Bad classorder declaration");
510 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)
518 key = parse_current->data;
619 int cil_fill_classperms(struct cil_tree_node *parse_current, struct cil_classperms **cp)
629 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
636 (*cp)->class_str = parse_current->data;
638 rc = cil_fill_perms(parse_current->next, &(*cp)->perm_strs);
664 void cil_fill_classperms_set(struct cil_tree_node *parse_current, struct cil_classperms_set **cp_set)
667 (*cp_set)->set_str = parse_current->data;
679 int cil_fill_classperms_list(struct cil_tree_node *parse_current, struct cil_list **cp_list)
688 if (parse_current == NULL || cp_list == NULL) {
692 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
699 curr = parse_current->cl_head;
704 cil_fill_classperms_set(parse_current, &new_cp_set);
747 int cil_gen_classpermission(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
759 if (db == NULL || parse_current == NULL || ast_node == NULL) {
763 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
770 key = parse_current->next->data;
780 cil_tree_log(parse_current, CIL_ERR, "Bad classpermission declaration");
805 int cil_gen_classpermissionset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
817 if (db == NULL || parse_current == NULL || ast_node == NULL) {
821 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
828 cps->set_str = parse_current->next->data;
830 rc = cil_fill_classperms_list(parse_current->next->next, &cps->classperms);
841 cil_tree_log(parse_current, CIL_ERR, "Bad classpermissionset");
857 int cil_gen_map_class(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
870 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
877 key = parse_current->next->data;
884 rc = cil_gen_perm_nodes(db, parse_current->next->next->cl_head, ast_node, CIL_MAP_PERM, &map->num_perms);
892 cil_tree_log(parse_current, CIL_ERR, "Bad map class declaration");
898 int cil_gen_classmapping(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
911 if (db == NULL || parse_current == NULL || ast_node == NULL) {
915 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
922 mapping->map_class_str = parse_current->next->data;
923 mapping->map_perm_str = parse_current->next->next->data;
925 rc = cil_fill_classperms_list(parse_current->next->next->next, &mapping->classperms);
936 cil_tree_log(parse_current, CIL_ERR, "Bad classmapping declaration");
953 int cil_gen_common(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
966 if (db == NULL || parse_current == NULL || ast_node == NULL) {
970 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
977 key = parse_current->next->data;
984 rc = cil_gen_perm_nodes(db, parse_current->next->next->cl_head, ast_node, CIL_PERM, &common->num_perms);
989 cil_tree_log(parse_current, CIL_ERR, "Too many permissions in common '%s'", common->datum.name);
996 cil_tree_log(parse_current, CIL_ERR, "Bad common declaration");
1003 int cil_gen_classcommon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1015 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1019 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1026 clscom->class_str = parse_current->next->data;
1027 clscom->common_str = parse_current->next->next->data;
1035 cil_tree_log(parse_current, CIL_ERR, "Bad classcommon declaration");
1050 int cil_gen_sid(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1062 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1066 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1073 key = parse_current->next->data;
1083 cil_tree_log(parse_current, CIL_ERR, "Bad sid declaration");
1099 int cil_gen_sidcontext(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1111 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1115 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1122 sidcon->sid_str = parse_current->next->data;
1124 if (parse_current->next->next->cl_head == NULL) {
1125 sidcon->context_str = parse_current->next->next->data;
1129 rc = cil_fill_context(parse_current->next->next->cl_head, sidcon->context);
1141 cil_tree_log(parse_current, CIL_ERR, "Bad sidcontext declaration");
1159 int cil_gen_sidorder(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1171 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1175 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1182 rc = cil_fill_list(parse_current->next->cl_head, CIL_SIDORDER, &sidorder->sid_list_str);
1201 cil_tree_log(parse_current, CIL_ERR, "Bad sidorder declaration");
1219 int cil_gen_user(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1231 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1235 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1242 key = parse_current->next->data;
1252 cil_tree_log(parse_current, CIL_ERR, "Bad user declaration");
1270 int cil_gen_userattribute(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1282 if (parse_current == NULL || ast_node == NULL) {
1286 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1293 key = parse_current->next->data;
1301 cil_tree_log(parse_current, CIL_ERR, "Bad userattribute declaration");
1336 int cil_gen_userattributeset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1348 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1352 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1359 attrset->attr_str = parse_current->next->data;
1361 rc = cil_gen_expr(parse_current->next->next, CIL_USER, &attrset->str_expr);
1371 cil_tree_log(parse_current, CIL_ERR, "Bad userattributeset declaration");
1389 int cil_gen_userlevel(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1401 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1405 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1412 usrlvl->user_str = parse_current->next->data;
1414 if (parse_current->next->next->cl_head == NULL) {
1415 usrlvl->level_str = parse_current->next->next->data;
1419 rc = cil_fill_level(parse_current
1431 cil_tree_log(parse_current, CIL_ERR, "Bad userlevel declaration");
1449 int cil_gen_userrange(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1461 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1465 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1472 userrange->user_str = parse_current->next->data;
1474 if (parse_current->next->next->cl_head == NULL) {
1475 userrange->range_str = parse_current->next->next->data;
1479 rc = cil_fill_levelrange(parse_current->next->next->cl_head, userrange->range);
1491 cil_tree_log(parse_current, CIL_ERR, "Bad userrange declaration");
1509 int cil_gen_userprefix(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1521 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1525 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1532 userprefix->user_str = parse_current->next->data;
1533 userprefix->prefix_str = parse_current->next->next->data;
1540 cil_tree_log(parse_current, CIL_ERR, "Bad userprefix declaration");
1554 int cil_gen_selinuxuser(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1567 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1571 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1578 selinuxuser->name_str = parse_current->next->data;
1579 selinuxuser->user_str = parse_current->next->next->data;
1581 if (parse_current->next->next->next->cl_head == NULL) {
1582 selinuxuser->range_str = parse_current->next->next->next->data;
1586 rc = cil_fill_levelrange(parse_current->next->next->next->cl_head, selinuxuser->range);
1597 cil_tree_log(parse_current, CIL_ERR, "Bad selinuxuser declaration");
1602 int cil_gen_selinuxuserdefault(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1614 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1618 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1626 selinuxuser->user_str = parse_current->next->data;
1628 if (parse_current->next->next->cl_head == NULL) {
1629 selinuxuser->range_str = parse_current->next->next->data;
1633 rc = cil_fill_levelrange(parse_current->next->next->cl_head, selinuxuser->range);
1644 cil_tree_log(parse_current, CIL_ERR, "Bad selinuxuserdefault declaration");
1662 int cil_gen_role(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1674 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1678 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1685 key = parse_current->next->data;
1695 cil_tree_log(parse_current, CIL_ERR, "Bad role declaration");
1713 int cil_gen_roletype(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1725 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1729 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1736 roletype->role_str = parse_current->next->data;
1737 roletype->type_str = parse_current->next->next->data;
1745 cil_tree_log(parse_current, CIL_ERR, "Bad roletype declaration");
1759 int cil_gen_userrole(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1771 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1775 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1782 userrole->user_str = parse_current->next->data;
1783 userrole->role_str = parse_current->next->next->data;
1791 cil_tree_log(parse_current, CIL_ERR, "Bad userrole declaration");
1805 int cil_gen_roletransition(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1819 if (parse_current == NULL || ast_node == NULL) {
1823 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1830 roletrans->src_str = parse_current->next->data;
1831 roletrans->tgt_str = parse_current->next->next->data;
1832 roletrans->obj_str = parse_current->next->next->next->data;
1833 roletrans->result_str = parse_current->next->next->next->next->data;
1841 cil_tree_log(parse_current, CIL_ERR, "Bad roletransition rule");
1855 int cil_gen_roleallow(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1867 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1871 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1878 roleallow->src_str = parse_current->next->data;
1879 roleallow->tgt_str = parse_current->next->next->data;
1887 cil_tree_log(parse_current, CIL_ERR, "Bad roleallow rule");
1901 int cil_gen_roleattribute(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1913 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1917 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1922 if (parse_current->next->data == CIL_KEY_SELF) {
1930 key = parse_current->next->data;
1938 cil_tree_log(parse_current, CIL_ERR, "Bad roleattribute declaration");
1970 int cil_gen_roleattributeset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
1982 if (db == NULL || parse_current == NULL || ast_node == NULL) {
1986 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
1993 attrset->attr_str = parse_current->next->data;
1995 rc = cil_gen_expr(parse_current->next->next, CIL_ROLE, &attrset->str_expr);
2005 cil_tree_log(parse_current, CIL_ERR, "Bad roleattributeset declaration");
2023 int cil_gen_avrule(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, uint32_t rule_kind)
2036 if (parse_current == NULL || ast_node == NULL) {
2040 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2050 rule->src_str = parse_current->next->data;
2051 rule->tgt_str = parse_current->next->next->data;
2053 rc = cil_fill_classperms_list(parse_current->next->next->next, &rule->perms.classperms);
2064 cil_tree_log(parse_current, CIL_ERR, "Bad allow rule");
2086 int cil_fill_permissionx(struct cil_tree_node *parse_current, struct cil_permissionx *permx)
2097 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2102 if (parse_current->data == CIL_KEY_IOCTL) {
2105 cil_log(CIL_ERR, "Unknown permissionx kind, %s. Must be \"ioctl\"\n", (char *)parse_current->data);
2110 permx->obj_str = parse_current->next->data;
2112 rc = cil_gen_expr(parse_current->next->next, CIL_PERMISSIONX, &permx->expr_str);
2120 cil_tree_log(parse_current, CIL_ERR, "Bad permissionx content");
2124 int cil_gen_permissionx(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
2137 if (parse_current == NULL || ast_node == NULL) {
2141 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2148 key = parse_current->next->data;
2155 rc = cil_fill_permissionx(parse_current->next->next->cl_head, permx);
2163 cil_tree_log(parse_current, CIL_ERR, "Bad permissionx statement");
2183 int cil_gen_avrulex(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, uint32_t rule_kind)
2196 if (parse_current == NULL || ast_node == NULL) {
2200 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2209 rule->src_str = parse_current->next->data;
2210 rule->tgt_str = parse_current->next->next->data;
2212 if (parse_current->next->next->next->cl_head == NULL) {
2213 rule->perms.x.permx_str = parse_current->next->next->next->data;
2217 rc = cil_fill_permissionx(parse_current->next->next->next->cl_head, rule->perms.x.permx);
2229 cil_tree_log(parse_current, CIL_ERR, "Bad allowx rule");
2234 int cil_gen_type_rule(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, uint32_t rule_kind)
2248 if (parse_current == NULL || ast_node == NULL) {
2252 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2260 rule->src_str = parse_current->next->data;
2261 rule->tgt_str = parse_current->next->next->data;
2262 rule->obj_str = parse_current->next->next->next->data;
2263 rule->result_str = parse_current->next->next->next->next->data;
2271 cil_tree_log(parse_current, CIL_ERR, "Bad type rule");
2285 int cil_gen_type(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
2297 if (db == NULL || parse_current == NULL || ast_node == NULL) {
2301 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2306 if (parse_current->next->data == CIL_KEY_SELF) {
2314 key = parse_current->next->data;
2323 cil_tree_log(parse_current, CIL_ERR, "Bad type declaration");
2339 int cil_gen_typeattribute(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
2351 if (db == NULL || parse_current == NULL || ast_node == NULL) {
2355 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2360 if (parse_current->next->data == CIL_KEY_SELF) {
2368 key = parse_current->next->data;
2377 cil_tree_log(parse_current, CIL_ERR, "Bad typeattribute declaration");
2409 int cil_gen_bool(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, int tunableif)
2422 if (db == NULL || parse_current == NULL || ast_node == NULL) {
2426 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2433 key = parse_current->next->data;
2435 if (parse_current->next->next->data == CIL_KEY_CONDTRUE) {
2437 } else if (parse_current->next->next->data == CIL_KEY_CONDFALSE) {
2454 cil_tree_log(parse_current, CIL_ERR, "Bad tunable (treated as a boolean due to preserve-tunables) declaration");
2456 cil_tree_log(parse_current, CIL_ERR, "Bad boolean declaration");
2473 int cil_gen_tunable(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
2486 if (db == NULL || parse_current == NULL || ast_node == NULL) {
2490 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2497 key = parse_current->next->data;
2499 if (parse_current->next->next->data == CIL_KEY_CONDTRUE) {
2501 } else if (parse_current->next->next->data == CIL_KEY_CONDFALSE) {
2517 cil_tree_log(parse_current, CIL_ERR, "Bad tunable declaration");
2830 int cil_gen_boolif(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, int tunableif)
2845 if (db == NULL || parse_current == NULL || ast_node == NULL) {
2849 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2857 rc = cil_gen_expr(parse_current->next, CIL_BOOL, &bif->str_expr);
2862 cond = parse_current->next->next;
2883 next = parse_current->next->next;
2884 cil_tree_subtree_destroy(parse_current->next);
2885 parse_current->next = next;
2894 cil_tree_log(parse_current, CIL_ERR, "Bad tunableif (treated as a booleanif due to preserve-tunables) declaration");
2896 cil_tree_log(parse_current, CIL_ERR, "Bad booleanif declaration");
2914 int cil_gen_tunif(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
2929 if (db == NULL || parse_current == NULL || ast_node == NULL) {
2933 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
2940 rc = cil_gen_expr(parse_current->next, CIL_TUNABLE, &tif->str_expr);
2945 cond = parse_current->next->next;
2966 next = parse_current->next->next;
2967 cil_tree_subtree_destroy(parse_current->next);
2968 parse_current->next = next;
2976 cil_tree_log(parse_current, CIL_ERR, "Bad tunableif declaration");
2993 int cil_gen_condblock(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor)
3004 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3008 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3029 cil_tree_log(parse_current, CIL_ERR, "Bad %s condition declaration",
3030 (char*)parse_current->data);
3045 int cil_gen_alias(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor)
3058 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3062 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3067 if (flavor == CIL_TYPEALIAS && parse_current->next->data == CIL_KEY_SELF) {
3075 key = parse_current->next->data;
3090 cil_tree_log(parse_current, CIL_ERR, "Bad %s declaration", (char*)parse_current->data);
3108 int cil_gen_aliasactual(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor)
3120 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3124 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3129 if ((flavor == CIL_TYPEALIAS && parse_current->next->data == CIL_KEY_SELF) || parse_current->next->next->data == CIL_KEY_SELF) {
3137 aliasactual->alias_str = parse_current->next->data;
3139 aliasactual->actual_str = parse_current->next->next->data;
3147 cil_tree_log(parse_current, CIL_ERR, "Bad %s association", cil_node_to_string(parse_current));
3161 int cil_gen_typeattributeset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3173 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3177 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3184 attrset->attr_str = parse_current->next->data;
3186 rc = cil_gen_expr(parse_current->next->next, CIL_TYPE, &attrset->str_expr);
3196 cil_tree_log(parse_current, CIL_ERR, "Bad typeattributeset statement");
3213 int cil_gen_expandtypeattribute(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3226 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3230 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3237 if (parse_current->next->cl_head == NULL) {
3239 cil_list_append(expandattr->attr_strs, CIL_STRING, parse_current->next->data);
3241 rc = cil_fill_list(parse_current->next->cl_head, CIL_TYPE, &expandattr->attr_strs);
3247 expand_str = parse_current->next->next->data;
3264 cil_tree_log(parse_current, CIL_ERR, "Bad expandtypeattribute statement");
3282 int cil_gen_typepermissive(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3293 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3297 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3304 typeperm->type_str = parse_current->next->data;
3312 cil_tree_log(parse_current, CIL_ERR, "Bad typepermissive declaration");
3326 int cil_gen_typetransition(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3341 if (db == NULL || parse_current == NULL || ast_node == NULL ) {
3345 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3350 s1 = parse_current->next->data;
3351 s2 = parse_current->next->next->data;
3352 s3 = parse_current->next->next->next->data;
3353 s4 = parse_current->next->next->next->next->data;
3356 if (parse_current->next->next->next->next->next) {
3358 s4 = parse_current->next->next->next->next->next->data;
3360 s5 = parse_current->next->next->next->next->next->data;
3395 cil_tree_log(parse_current, CIL_ERR, "Bad typetransition declaration");
3418 int cil_gen_rangetransition(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3432 if (db == NULL || parse_current == NULL || ast_node == NULL ) {
3436 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3443 rangetrans->src_str = parse_current->next->data;
3444 rangetrans->exec_str = parse_current->next->next->data;
3445 rangetrans->obj_str = parse_current->next->next->next->data;
3449 if (parse_current->next->next->next->next->cl_head == NULL) {
3450 rangetrans->range_str = parse_current->next->next->next->next->data;
3454 rc = cil_fill_levelrange(parse_current->next->next->next->next->cl_head, rangetrans->range);
3466 cil_tree_log(parse_current, CIL_ERR, "Bad rangetransition declaration");
3484 int cil_gen_sensitivity(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3496 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3500 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3507 key = parse_current->next->data;
3517 cil_tree_log(parse_current, CIL_ERR, "Bad sensitivity declaration");
3536 int cil_gen_category(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3548 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3552 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3559 key = parse_current->next->data;
3569 cil_tree_log(parse_current, CIL_ERR, "Bad category declaration");
3585 int cil_gen_catset(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3598 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3602 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3609 key = parse_current->next->data;
3616 rc = cil_fill_cats(parse_current->next->next, &catset->cats);
3624 cil_tree_log(parse_current, CIL_ERR, "Bad categoryset declaration");
3643 int cil_gen_catorder(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3655 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3659 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3666 rc = cil_fill_list(parse_current->next->cl_head, CIL_CATORDER, &catorder->cat_list_str);
3685 cil_tree_log(parse_current, CIL_ERR, "Bad categoryorder declaration");
3703 int cil_gen_sensitivityorder(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3715 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3719 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3726 rc = cil_fill_list(parse_current->next->cl_head, CIL_SENSITIVITYORDER, &sensorder->sens_list_str);
3745 cil_tree_log(parse_current, CIL_ERR, "Bad sensitivityorder declaration");
3763 int cil_gen_senscat(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3775 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3779 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3786 senscat->sens_str = parse_current->next->data;
3788 rc = cil_fill_cats(parse_current->next->next, &senscat->cats);
3799 cil_tree_log(parse_current, CIL_ERR, "Bad sensitivitycategory declaration");
3815 int cil_gen_level(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3828 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3832 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3839 key = parse_current->next->data;
3846 rc = cil_fill_level(parse_current->next->next->cl_head, level);
3854 cil_tree_log(parse_current, CIL_ERR, "Bad level declaration");
3921 int cil_gen_levelrange(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
3934 if (db == NULL || parse_current == NULL || ast_node == NULL) {
3938 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
3945 key = parse_current->next->data;
3952 rc = cil_fill_levelrange(parse_current->next->next->cl_head, lvlrange);
3960 cil_tree_log(parse_current, CIL_ERR, "Bad levelrange declaration");
3985 int cil_gen_constrain(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor)
3997 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4001 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4008 rc = cil_fill_classperms_list(parse_current->next, &cons->classperms);
4013 rc = cil_gen_constraint_expr(parse_current->next->next, flavor, &cons->str_expr);
4024 cil_tree_log(parse_current, CIL_ERR, "Bad constrain declaration");
4042 int cil_gen_validatetrans(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor)
4054 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4058 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4065 validtrans->class_str = parse_current->next->data;
4067 rc = cil_gen_constraint_expr(parse_current->next->next, flavor, &validtrans->str_expr);
4078 cil_tree_log(parse_current, CIL_ERR, "Bad validatetrans declaration");
4143 int cil_gen_context(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4156 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4160 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4167 key = parse_current->next->data;
4174 rc = cil_fill_context(parse_current->next->next->cl_head, context);
4182 cil_tree_log(parse_current, CIL_ERR, "Bad context declaration");
4203 int cil_gen_filecon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4217 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4221 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4226 type = parse_current->next->next->data;
4229 filecon->path_str = parse_current->next->data;
4253 if (parse_current->next->next->next->cl_head == NULL) {
4254 filecon->context_str = parse_current->next->next->next->data;
4256 if (parse_current->next->next->next->cl_head->next == NULL) {
4261 rc = cil_fill_context(parse_current->next->next->next->cl_head, filecon->context);
4274 cil_tree_log(parse_current, CIL_ERR, "Bad filecon declaration");
4293 int cil_gen_ibpkeycon(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4306 if (!parse_current || !ast_node)
4309 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4315 ibpkeycon->subnet_prefix_str = parse_current->next->data;
4317 if (parse_current->next->next->cl_head) {
4318 if (parse_current->next->next->cl_head->next &&
4319 !parse_current->next->next->cl_head->next->next) {
4320 rc = cil_fill_integer(parse_current->next->next->cl_head, &ibpkeycon->pkey_low, 0);
4325 rc = cil_fill_integer(parse_current->next->next->cl_head->next, &ibpkeycon->pkey_high, 0);
4336 rc = cil_fill_integer(parse_current->next->next, &ibpkeycon->pkey_low, 0);
4344 if (!parse_current->next->next->next->cl_head) {
4345 ibpkeycon->context_str = parse_current->next->next->next->data;
4349 rc = cil_fill_context(parse_current->next->next->next->cl_head, ibpkeycon->context);
4359 cil_tree_log(parse_current, CIL_ERR, "Bad ibpkeycon declaration");
4376 int cil_gen_portcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4390 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4394 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4401 proto = parse_current->next->data;
4416 if (parse_current->next->next->cl_head != NULL) {
4417 if (parse_current->next->next->cl_head->next != NULL
4418 && parse_current->next->next->cl_head->next->next == NULL) {
4419 rc = cil_fill_integer(parse_current->next->next->cl_head, &portcon->port_low, 10);
4424 rc = cil_fill_integer(parse_current->next->next->cl_head->next, &portcon->port_high, 10);
4435 rc = cil_fill_integer(parse_current->next->next, &portcon->port_low, 10);
4443 if (parse_current->next->next->next->cl_head == NULL ) {
4444 portcon->context_str = parse_current->next->next->next->data;
4448 rc = cil_fill_context(parse_current->next->next->next->cl_head, portcon->context);
4460 cil_tree_log(parse_current, CIL_ERR, "Bad portcon declaration");
4478 int cil_gen_nodecon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4491 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4495 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4502 if (parse_current->next->cl_head == NULL ) {
4503 nodecon->addr_str = parse_current->next->data;
4507 rc = cil_fill_ipaddr(parse_current->next->cl_head, nodecon->addr);
4513 if (parse_current->next->next->cl_head == NULL ) {
4514 nodecon->mask_str = parse_current->next->next->data;
4518 rc = cil_fill_ipaddr(parse_current->next->next->cl_head, nodecon->mask);
4524 if (parse_current->next->next->next->cl_head == NULL ) {
4525 nodecon->context_str = parse_current->next->next->next->data;
4529 rc = cil_fill_context(parse_current->next->next->next->cl_head, nodecon->context);
4541 cil_tree_log(parse_current, CIL_ERR, "Bad nodecon declaration");
4567 int cil_gen_genfscon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4580 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4584 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4591 genfscon->fs_str = parse_current->next->data;
4592 genfscon->path_str = parse_current->next->next->data;
4594 if (parse_current->next->next->next->cl_head == NULL ) {
4595 genfscon->context_str = parse_current->next->next->next->data;
4599 rc = cil_fill_context(parse_current->next->next->next->cl_head, genfscon->context);
4611 cil_tree_log(parse_current, CIL_ERR, "Bad genfscon declaration");
4630 int cil_gen_netifcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4643 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4647 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4654 netifcon->interface_str = parse_current->next->data;
4656 if (parse_current->next->next->cl_head == NULL) {
4657 netifcon->if_context_str = parse_current->next->next->data;
4661 rc = cil_fill_context(parse_current->next->next->cl_head, netifcon->if_context);
4667 if (parse_current->next->next->next->cl_head == NULL) {
4668 netifcon->packet_context_str = parse_current->next->next->next->data;
4672 rc = cil_fill_context(parse_current->next->next->next->cl_head, netifcon->packet_context);
4684 cil_tree_log(parse_current, CIL_ERR, "Bad netifcon declaration");
4706 int cil_gen_ibendportcon(__attribute__((unused)) struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4719 if (!parse_current || !ast_node)
4722 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4728 ibendportcon->dev_name_str = parse_current->next->data;
4730 rc = cil_fill_integer(parse_current->next->next, &ibendportcon->port, 10);
4736 if (!parse_current->next->next->next->cl_head) {
4737 ibendportcon->context_str = parse_current->next->next->next->data;
4741 rc = cil_fill_context(parse_current->next->next->next->cl_head, ibendportcon->context);
4752 cil_tree_log(parse_current, CIL_ERR, "Bad ibendportcon declaration");
4768 int cil_gen_pirqcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4780 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4784 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4791 rc = cil_fill_integer(parse_current->next, &pirqcon->pirq, 10);
4796 if (parse_current->next->next->cl_head == NULL) {
4797 pirqcon->context_str = parse_current->next->next->data;
4801 rc = cil_fill_context(parse_current->next->next->cl_head, pirqcon->context);
4813 cil_tree_log(parse_current, CIL_ERR, "Bad pirqcon declaration");
4831 int cil_gen_iomemcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4843 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4847 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4854 if (parse_current->next->cl_head != NULL) {
4855 if (parse_current->next->cl_head->next != NULL &&
4856 parse_current->next->cl_head->next->next == NULL) {
4857 rc = cil_fill_integer64(parse_current->next->cl_head, &iomemcon->iomem_low, 0);
4862 rc = cil_fill_integer64(parse_current->next->cl_head->next, &iomemcon->iomem_high, 0);
4873 rc = cil_fill_integer64(parse_current->next, &iomemcon->iomem_low, 0);
4881 if (parse_current->next->next->cl_head == NULL ) {
4882 iomemcon->context_str = parse_current->next->next->data;
4886 rc = cil_fill_context(parse_current->next->next->cl_head, iomemcon->context);
4898 cil_tree_log(parse_current, CIL_ERR, "Bad iomemcon declaration");
4916 int cil_gen_ioportcon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
4928 if (db == NULL || parse_current == NULL || ast_node == NULL) {
4932 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
4939 if (parse_current->next->cl_head != NULL) {
4940 if (parse_current->next->cl_head->next != NULL &&
4941 parse_current->next->cl_head->next->next == NULL) {
4942 rc = cil_fill_integer(parse_current->next->cl_head, &ioportcon->ioport_low, 0);
4947 rc = cil_fill_integer(parse_current->next->cl_head->next, &ioportcon->ioport_high, 0);
4958 rc = cil_fill_integer(parse_current->next, &ioportcon->ioport_low, 0);
4966 if (parse_current->next->next->cl_head == NULL ) {
4967 ioportcon->context_str = parse_current->next->next->data;
4971 rc = cil_fill_context(parse_current->next->next->cl_head, ioportcon->context);
4983 cil_tree_log(parse_current, CIL_ERR, "Bad ioportcon declaration");
5001 int cil_gen_pcidevicecon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5013 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5017 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5024 rc = cil_fill_integer(parse_current->next, &pcidevicecon->dev, 0);
5029 if (parse_current->next->next->cl_head == NULL) {
5030 pcidevicecon->context_str = parse_current->next->next->data;
5034 rc = cil_fill_context(parse_current->next->next->cl_head, pcidevicecon->context);
5046 cil_tree_log(parse_current, CIL_ERR, "Bad pcidevicecon declaration");
5064 int cil_gen_devicetreecon(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5076 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5080 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5087 devicetreecon->path = parse_current->next->data;
5089 if (parse_current->next->next->cl_head == NULL) {
5090 devicetreecon->context_str = parse_current->next->next->data;
5094 rc = cil_fill_context(parse_current->next->next->cl_head, devicetreecon->context);
5106 cil_tree_log(parse_current, CIL_ERR, "Bad devicetreecon declaration");
5124 int cil_gen_fsuse(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5138 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5142 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5147 type = parse_current->next->data;
5162 fsuse->fs_str = parse_current->next->next->data;
5164 if (parse_current->next->next->next->cl_head == NULL) {
5165 fsuse->context_str = parse_current->next->next->next->data;
5169 rc = cil_fill_context(parse_current->next->next->next->cl_head, fsuse->context);
5181 cil_tree_log(parse_current, CIL_ERR, "Bad fsuse declaration");
5208 int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5223 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5227 rc =__cil_verify_syntax(parse_current, syntax, syntax_len);
5234 key = parse_current->next->data;
5236 struct cil_tree_node *current_item = parse_current->next->next->cl_head;
5322 macro_content = parse_current->next->next->next;
5323 cil_tree_subtree_destroy(parse_current->next->next);
5324 parse_current->next->next = macro_content;
5327 parse_current->parent->cl_tail = parse_current->next;
5338 cil_tree_log(parse_current, CIL_ERR, "Bad macro declaration");
5360 int cil_gen_call(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5372 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5376 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5383 call->macro_str = parse_current->next->data;
5385 if (parse_current->next->next != NULL) {
5387 cil_copy_ast(db, parse_current->next->next, call->args_tree->root);
5396 cil_tree_log(parse_current, CIL_ERR, "Bad macro call");
5465 int cil_gen_optional(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5478 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5482 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5489 key = parse_current->next->data;
5498 cil_tree_log(parse_current, CIL_ERR, "Bad optional");
5514 int cil_gen_policycap(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5526 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5530 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5537 key = parse_current->next->data;
5546 cil_tree_log(parse_current, CIL_ERR, "Bad policycap statement");
5562 int cil_gen_ipaddr(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5575 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5579 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5586 key = parse_current->next->data;
5588 rc = cil_fill_ipaddr(parse_current->next->next, ipaddr);
5601 cil_tree_log(parse_current, CIL_ERR, "Bad ipaddr statement");
5761 int cil_gen_bounds(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor)
5773 if (db == NULL || parse_current == NULL || ast_node == NULL) {
5777 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5784 bounds->parent_str = parse_current->next->data;
5785 bounds->child_str = parse_current->next->next->data;
5806 cil_tree_log(parse_current, CIL_ERR, "Bad bounds declaration");
5820 int cil_gen_default(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node, enum cil_flavor flavor)
5833 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5842 if (parse_current->next->cl_head == NULL) {
5844 cil_list_append(def->class_strs, CIL_STRING, parse_current->next->data);
5846 rc = cil_fill_list(parse_current->next->cl_head, CIL_CLASS, &def->class_strs);
5852 object = parse_current->next->next->data;
5869 cil_tree_log(parse_current, CIL_ERR, "Bad %s declaration", cil_node_to_string(parse_current));
5887 int cil_gen_defaultrange(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5902 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5909 if (parse_current->next->cl_head == NULL) {
5911 cil_list_append(def->class_strs, CIL_STRING, parse_current->next->data);
5913 rc = cil_fill_list(parse_current->next->cl_head, CIL_CLASS, &def->class_strs);
5919 object = parse_current->next->next->data;
5920 range = parse_current->next->next->next->data;
5933 } else if (parse_current->next->next->data == CIL_KEY_TARGET) {
5957 cil_tree_log(parse_current, CIL_ERR, "Bad defaultrange declaration");
5975 int cil_gen_handleunknown(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
5987 if (parse_current == NULL || ast_node == NULL) {
5991 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
5998 unknown_key = parse_current->next->data;
6017 cil_tree_log(parse_current, CIL_ERR, "Bad handleunknown");
6027 int cil_gen_mls(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
6038 if (parse_current == NULL || ast_node == NULL) {
6042 rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
6049 if (parse_current->next->data == CIL_KEY_CONDTRUE) {
6051 } else if (parse_current->next->data == CIL_KEY_CONDFALSE) {
6065 cil_tree_log(parse_current, CIL_ERR, "Bad mls");
6075 int cil_gen_src_info(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
6082 info->is_cil = (parse_current->next->data == CIL_KEY_SRC_CIL) ? CIL_TRUE : CIL_FALSE;
6083 info->path = parse_current->next->next->data;
6096 int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *finished, void *extra_args)
6108 if (parse_current == NULL || finished == NULL || extra_args == NULL) {
6120 if (parse_current->parent->cl_head != parse_current) {
6124 } else if (parse_current->data == NULL) {
6127 if (parse_current->parent->parent == NULL) {
6130 cil_tree_log(parse_current, CIL_ERR, "Keyword expected after open parenthesis");
6136 if (parse_current->data == CIL_KEY_MACRO ||
6137 parse_current->data == CIL_KEY_TUNABLE ||
6138 parse_current->data == CIL_KEY_IN ||
6139 parse_current->data == CIL_KEY_BLOCK ||
6140 parse_current->data == CIL_KEY_BLOCKINHERIT ||
6141 parse_current->data == CIL_KEY_BLOCKABSTRACT) {
6143 cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in macros", (char *)parse_current->data);
6149 if (parse_current->data != CIL_KEY_CONDTRUE &&
6150 parse_current->data != CIL_KEY_CONDFALSE &&
6151 parse_current->data != CIL_KEY_AUDITALLOW &&
6152 parse_current->data != CIL_KEY_TUNABLEIF &&
6153 parse_current->data != CIL_KEY_ALLOW &&
6154 parse_current->data != CIL_KEY_DONTAUDIT &&
6155 parse_current->data != CIL_KEY_TYPETRANSITION &&
6156 parse_current->data != CIL_KEY_TYPECHANGE &&
6157 parse_current->data != CIL_KEY_CALL) {
6159 cil_tree_log(parse_current, CIL_ERR, "Found %s", (char*)parse_current->data);
6162 (char*)parse_current->data);
6165 (char*)parse_current->data);
6172 if (parse_current->data == CIL_KEY_TUNABLE) {
6174 cil_tree_log(parse_current, CIL_ERR, "Found tunable");
6181 if (parse_current->data == CIL_KEY_IN) {
6183 cil_tree_log(parse_current, CIL_ERR, "Found in-statement");
6192 ast_node->line = parse_current->line;
6193 ast_node->hll_line = parse_current->hll_line;
6195 if (parse_current->data == CIL_KEY_BLOCK) {
6196 rc = cil_gen_block(db, parse_current, ast_node, 0);
6197 } else if (parse_current->data == CIL_KEY_BLOCKINHERIT) {
6198 rc = cil_gen_blockinherit(db, parse_current, ast_node);
6199 } else if (parse_current->data == CIL_KEY_BLOCKABSTRACT) {
6200 rc = cil_gen_blockabstract(db, parse_current, ast_node);
6201 } else if (parse_current->data == CIL_KEY_IN) {
6202 rc = cil_gen_in(db, parse_current, ast_node);
6203 } else if (parse_current->data == CIL_KEY_CLASS) {
6204 rc = cil_gen_class(db, parse_current, ast_node);
6207 } else if (parse_current->data == CIL_KEY_CLASSORDER) {
6208 rc = cil_gen_classorder(db, parse_current, ast_node);
6210 } else if (parse_current->data == CIL_KEY_MAP_CLASS) {
6211 rc = cil_gen_map_class(db, parse_current, ast_node);
6213 } else if (parse_current->data == CIL_KEY_CLASSMAPPING) {
6214 rc = cil_gen_classmapping(db, parse_current, ast_node);
6216 } else if (parse_current->data == CIL_KEY_CLASSPERMISSION) {
6217 rc = cil_gen_classpermission(db, parse_current, ast_node);
6219 } else if (parse_current->data == CIL_KEY_CLASSPERMISSIONSET) {
6220 rc = cil_gen_classpermissionset(db, parse_current, ast_node);
6222 } else if (parse_current->data == CIL_KEY_COMMON) {
6223 rc = cil_gen_common(db, parse_current, ast_node);
6225 } else if (parse_current->data == CIL_KEY_CLASSCOMMON) {
6226 rc = cil_gen_classcommon(db, parse_current, ast_node);
6227 } else if (parse_current->data == CIL_KEY_SID) {
6228 rc = cil_gen_sid(db, parse_current, ast_node);
6230 } else if (parse_current->data == CIL_KEY_SIDCONTEXT) {
6231 rc = cil_gen_sidcontext(db, parse_current, ast_node);
6233 } else if (parse_current->data == CIL_KEY_SIDORDER) {
6234 rc = cil_gen_sidorder(db, parse_current, ast_node);
6236 } else if (parse_current->data == CIL_KEY_USER) {
6237 rc = cil_gen_user(db, parse_current, ast_node);
6238 } else if (parse_current->data == CIL_KEY_USERATTRIBUTE) {
6239 rc = cil_gen_userattribute(db, parse_current, ast_node);
6240 } else if (parse_current->data == CIL_KEY_USERATTRIBUTESET) {
6241 rc = cil_gen_userattributeset(db, parse_current, ast_node);
6243 } else if (parse_current->data == CIL_KEY_USERLEVEL) {
6244 rc = cil_gen_userlevel(db, parse_current, ast_node);
6246 } else if (parse_current->data == CIL_KEY_USERRANGE) {
6247 rc = cil_gen_userrange(db, parse_current, ast_node);
6249 } else if (parse_current->data == CIL_KEY_USERBOUNDS) {
6250 rc = cil_gen_bounds(db, parse_current, ast_node, CIL_USER);
6251 } else if (parse_current->data == CIL_KEY_USERPREFIX) {
6252 rc = cil_gen_userprefix(db, parse_current, ast_node);
6253 } else if (parse_current->data == CIL_KEY_SELINUXUSER) {
6254 rc = cil_gen_selinuxuser(db, parse_current, ast_node);
6256 } else if (parse_current->data == CIL_KEY_SELINUXUSERDEFAULT) {
6257 rc = cil_gen_selinuxuserdefault(db, parse_current, ast_node);
6259 } else if (parse_current->data == CIL_KEY_TYPE) {
6260 rc = cil_gen_type(db, parse_current, ast_node);
6261 } else if (parse_current->data == CIL_KEY_TYPEATTRIBUTE) {
6262 rc = cil_gen_typeattribute(db, parse_current, ast_node);
6263 } else if (parse_current->data == CIL_KEY_TYPEATTRIBUTESET) {
6264 rc = cil_gen_typeattributeset(db, parse_current, ast_node);
6266 parse_current->data == CIL_KEY_EXPANDTYPEATTRIBUTE) {
6267 rc = cil_gen_expandtypeattribute(db, parse_current, ast_node);
6269 } else if (parse_current->data == CIL_KEY_TYPEALIAS) {
6270 rc = cil_gen_alias(db, parse_current, ast_node, CIL_TYPEALIAS);
6271 } else if (parse_current->data == CIL_KEY_TYPEALIASACTUAL) {
6272 rc = cil_gen_aliasactual(db, parse_current, ast_node, CIL_TYPEALIASACTUAL);
6273 } else if (parse_current->data == CIL_KEY_TYPEBOUNDS) {
6274 rc = cil_gen_bounds(db, parse_current, ast_node, CIL_TYPE);
6275 } else if (parse_current->data == CIL_KEY_TYPEPERMISSIVE) {
6276 rc = cil_gen_typepermissive(db, parse_current, ast_node);
6277 } else if (parse_current->data == CIL_KEY_RANGETRANSITION) {
6278 rc = cil_gen_rangetransition(db, parse_current, ast_node);
6280 } else if (parse_current->data == CIL_KEY_ROLE) {
6281 rc = cil_gen_role(db, parse_current, ast_node);
6282 } else if (parse_current->data == CIL_KEY_USERROLE) {
6283 rc = cil_gen_userrole(db, parse_current, ast_node);
6284 } else if (parse_current->data == CIL_KEY_ROLETYPE) {
6285 rc = cil_gen_roletype(db, parse_current, ast_node);
6286 } else if (parse_current->data == CIL_KEY_ROLETRANSITION) {
6287 rc = cil_gen_roletransition(parse_current, ast_node);
6288 } else if (parse_current->data == CIL_KEY_ROLEALLOW) {
6289 rc = cil_gen_roleallow(db, parse_current, ast_node);
6290 } else if (parse_current->data == CIL_KEY_ROLEATTRIBUTE) {
6291 rc = cil_gen_roleattribute(db, parse_current, ast_node);
6292 } else if (parse_current->data == CIL_KEY_ROLEATTRIBUTESET) {
6293 rc = cil_gen_roleattributeset(db, parse_current, ast_node);
6295 } else if (parse_current->data == CIL_KEY_ROLEBOUNDS) {
6296 rc = cil_gen_bounds(db, parse_current, ast_node, CIL_ROLE);
6297 } else if (parse_current->data == CIL_KEY_BOOL) {
6298 rc = cil_gen_bool(db, parse_current, ast_node, CIL_FALSE);
6299 } else if (parse_current->data == CIL_KEY_BOOLEANIF) {
6300 rc = cil_gen_boolif(db, parse_current, ast_node, CIL_FALSE);
6301 } else if(parse_current->data == CIL_KEY_TUNABLE) {
6303 rc = cil_gen_bool(db, parse_current, ast_node, CIL_TRUE);
6305 rc = cil_gen_tunable(db, parse_current, ast_node);
6307 } else if (parse_current->data == CIL_KEY_TUNABLEIF) {
6309 rc = cil_gen_boolif(db, parse_current, ast_node, CIL_TRUE);
6311 rc = cil_gen_tunif(db, parse_current, ast_node);
6313 } else if (parse_current->data == CIL_KEY_CONDTRUE) {
6314 rc = cil_gen_condblock(db, parse_current, ast_node, CIL_CONDTRUE);
6315 } else if (parse_current->data == CIL_KEY_CONDFALSE) {
6316 rc = cil_gen_condblock(db, parse_current, ast_node, CIL_CONDFALSE);
6317 } else if (parse_current->data == CIL_KEY_ALLOW) {
6318 rc = cil_gen_avrule(parse_current, ast_node, CIL_AVRULE_ALLOWED);
6321 } else if (parse_current->data == CIL_KEY_AUDITALLOW) {
6322 rc = cil_gen_avrule(parse_current, ast_node, CIL_AVRULE_AUDITALLOW);
6324 } else if (parse_current->data == CIL_KEY_DONTAUDIT) {
6325 rc = cil_gen_avrule(parse_current, ast_node, CIL_AVRULE_DONTAUDIT);
6327 } else if (parse_current->data == CIL_KEY_NEVERALLOW) {
6328 rc = cil_gen_avrule(parse_current, ast_node, CIL_AVRULE_NEVERALLOW);
6330 } else if (parse_current->data == CIL_KEY_ALLOWX) {
6331 rc = cil_gen_avrulex(parse_current, ast_node, CIL_AVRULE_ALLOWED);
6333 } else if (parse_current->data == CIL_KEY_AUDITALLOWX) {
6334 rc = cil_gen_avrulex(parse_current, ast_node, CIL_AVRULE_AUDITALLOW);
6336 } else if (parse_current->data == CIL_KEY_DONTAUDITX) {
6337 rc = cil_gen_avrulex(parse_current, ast_node, CIL_AVRULE_DONTAUDIT);
6339 } else if (parse_current->data == CIL_KEY_NEVERALLOWX) {
6340 rc = cil_gen_avrulex(parse_current, ast_node, CIL_AVRULE_NEVERALLOW);
6342 } else if (parse_current->data == CIL_KEY_PERMISSIONX) {
6343 rc = cil_gen_permissionx(db, parse_current, ast_node);
6345 } else if (parse_current->data == CIL_KEY_TYPETRANSITION) {
6346 rc = cil_gen_typetransition(db, parse_current, ast_node);
6347 } else if (parse_current->data == CIL_KEY_TYPECHANGE) {
6348 rc = cil_gen_type_rule(parse_current, ast_node, CIL_TYPE_CHANGE);
6349 } else if (parse_current->data == CIL_KEY_TYPEMEMBER) {
6350 rc = cil_gen_type_rule(parse_current, ast_node, CIL_TYPE_MEMBER);
6351 } else if (parse_current->data == CIL_KEY_SENSITIVITY) {
6352 rc = cil_gen_sensitivity(db, parse_current, ast_node);
6353 } else if (parse_current->data == CIL_KEY_SENSALIAS) {
6354 rc = cil_gen_alias(db, parse_current, ast_node, CIL_SENSALIAS);
6355 } else if (parse_current->data == CIL_KEY_SENSALIASACTUAL) {
6356 rc = cil_gen_aliasactual(db, parse_current, ast_node, CIL_SENSALIASACTUAL);
6357 } else if (parse_current->data == CIL_KEY_CATEGORY) {
6358 rc = cil_gen_category(db, parse_current, ast_node);
6359 } else if (parse_current->data == CIL_KEY_CATALIAS) {
6360 rc = cil_gen_alias(db, parse_current, ast_node, CIL_CATALIAS);
6361 } else if (parse_current->data == CIL_KEY_CATALIASACTUAL) {
6362 rc = cil_gen_aliasactual(db, parse_current, ast_node, CIL_CATALIASACTUAL);
6363 } else if (parse_current->data == CIL_KEY_CATSET) {
6364 rc = cil_gen_catset(db, parse_current, ast_node);
6366 } else if (parse_current->data == CIL_KEY_CATORDER) {
6367 rc = cil_gen_catorder(db, parse_current, ast_node);
6369 } else if (parse_current->data == CIL_KEY_SENSITIVITYORDER) {
6370 rc = cil_gen_sensitivityorder(db, parse_current, ast_node);
6372 } else if (parse_current->data == CIL_KEY_SENSCAT) {
6373 rc = cil_gen_senscat(db, parse_current, ast_node);
6375 } else if (parse_current->data == CIL_KEY_LEVEL) {
6376 rc = cil_gen_level(db, parse_current, ast_node);
6378 } else if (parse_current->data == CIL_KEY_LEVELRANGE) {
6379 rc = cil_gen_levelrange(db, parse_current, ast_node);
6381 } else if (parse_current->data == CIL_KEY_CONSTRAIN) {
6382 rc = cil_gen_constrain(db, parse_current, ast_node, CIL_CONSTRAIN);
6384 } else if (parse_current->data == CIL_KEY_MLSCONSTRAIN) {
6385 rc = cil_gen_constrain(db, parse_current, ast_node, CIL_MLSCONSTRAIN);
6387 } else if (parse_current->data == CIL_KEY_VALIDATETRANS) {
6388 rc = cil_gen_validatetrans(db, parse_current, ast_node, CIL_VALIDATETRANS);
6390 } else if (parse_current->data == CIL_KEY_MLSVALIDATETRANS) {
6391 rc = cil_gen_validatetrans(db, parse_current, ast_node, CIL_MLSVALIDATETRANS);
6393 } else if (parse_current->data == CIL_KEY_CONTEXT) {
6394 rc = cil_gen_context(db, parse_current, ast_node);
6396 } else if (parse_current->data == CIL_KEY_FILECON) {
6397 rc = cil_gen_filecon(db, parse_current, ast_node);
6399 } else if (parse_current->data == CIL_KEY_IBPKEYCON) {
6400 rc = cil_gen_ibpkeycon(db, parse_current, ast_node);
6402 } else if (parse_current->data == CIL_KEY_IBENDPORTCON) {
6403 rc = cil_gen_ibendportcon(db, parse_current, ast_node);
6405 } else if (parse_current->data == CIL_KEY_PORTCON) {
6406 rc = cil_gen_portcon(db, parse_current, ast_node);
6408 } else if (parse_current->data == CIL_KEY_NODECON) {
6409 rc = cil_gen_nodecon(db, parse_current, ast_node);
6411 } else if (parse_current->data == CIL_KEY_GENFSCON) {
6412 rc = cil_gen_genfscon(db, parse_current, ast_node);
6414 } else if (parse_current->data == CIL_KEY_NETIFCON) {
6415 rc = cil_gen_netifcon(db, parse_current, ast_node);
6417 } else if (parse_current->data == CIL_KEY_PIRQCON) {
6418 rc = cil_gen_pirqcon(db, parse_current, ast_node);
6420 } else if (parse_current->data == CIL_KEY_IOMEMCON) {
6421 rc = cil_gen_iomemcon(db, parse_current, ast_node);
6423 } else if (parse_current->data == CIL_KEY_IOPORTCON) {
6424 rc = cil_gen_ioportcon(db, parse_current, ast_node);
6426 } else if (parse_current->data == CIL_KEY_PCIDEVICECON) {
6427 rc = cil_gen_pcidevicecon(db, parse_current, ast_node);
6429 } else if (parse_current->data == CIL_KEY_DEVICETREECON) {
6430 rc = cil_gen_devicetreecon(db, parse_current, ast_node);
6432 } else if (parse_current->data == CIL_KEY_FSUSE) {
6433 rc = cil_gen_fsuse(db, parse_current, ast_node);
6435 } else if (parse_current->data == CIL_KEY_MACRO) {
6436 rc = cil_gen_macro(db, parse_current, ast_node);
6437 } else if (parse_current->data == CIL_KEY_CALL) {
6438 rc = cil_gen_call(db, parse_current, ast_node);
6440 } else if (parse_current->data == CIL_KEY_POLICYCAP) {
6441 rc = cil_gen_policycap(db, parse_current, ast_node);
6443 } else if (parse_current->data == CIL_KEY_OPTIONAL) {
6444 rc = cil_gen_optional(db, parse_current, ast_node);
6445 } else if (parse_current->data == CIL_KEY_IPADDR) {
6446 rc = cil_gen_ipaddr(db, parse_current, ast_node);
6447 } else if (parse_current->data == CIL_KEY_DEFAULTUSER) {
6448 rc = cil_gen_default(parse_current, ast_node, CIL_DEFAULTUSER);
6450 } else if (parse_current->data == CIL_KEY_DEFAULTROLE) {
6451 rc = cil_gen_default(parse_current, ast_node, CIL_DEFAULTROLE);
6453 } else if (parse_current->data == CIL_KEY_DEFAULTTYPE) {
6454 rc = cil_gen_default(parse_current, ast_node, CIL_DEFAULTTYPE);
6456 } else if (parse_current->data == CIL_KEY_DEFAULTRANGE) {
6457 rc = cil_gen_defaultrange(parse_current, ast_node);
6459 } else if (parse_current->data == CIL_KEY_HANDLEUNKNOWN) {
6460 rc = cil_gen_handleunknown(parse_current, ast_node);
6462 } else if (parse_current->data == CIL_KEY_MLS) {
6463 rc = cil_gen_mls(parse_current, ast_node);
6465 } else if (parse_current->data == CIL_KEY_SRC_INFO) {
6466 rc = cil_gen_src_info(parse_current, ast_node);
6468 cil_log(CIL_ERR, "Error: Unknown keyword %s\n", (char *)parse_current->data);
6505 int __cil_build_ast_last_child_helper(struct cil_tree_node *parse_current, void *extra_args)
6541 // At this point we no longer have any need for parse_current or any of its
6546 cil_tree_children_destroy(parse_current->parent);