Home | History | Annotate | Download | only in src

Lines Matching full:state

128 	link_state_t *state = (link_state_t *) data;
130 class_datum_t *src_class = state->src_class;
131 class_datum_t *dest_class = state->dest_class;
132 policy_module_t *mod = state->cur;
147 if (state->dest_class_req) {
151 ERR(state->handle, "Memory error");
158 ERR(state->handle, "Memory error");
166 ERR(state->handle,
174 ERR(state->handle,
176 state->cur_mod_name, perm_id,
177 state->dest_class_name);
190 ERR(state->handle, "Out of memory!");
213 link_state_t *state = (link_state_t *) data;
218 state->dest_class_req = 0;
220 new_class = hashtab_search(state->base->p_classes.table, id);
228 hashtab_search(state->cur->policy->p_classes_scope.table,
236 ERR(state->handle,
238 state->cur_mod_name);
251 state->dest_class_req = 1;
255 ERR(state->handle, "Memory error\n");
266 ERR(state->handle, "Memory error\n");
270 ret = hashtab_insert(state->base->p_classes.table,
274 ERR(state->handle,
278 new_class->s.value = ++(state->base->p_classes.nprim);
282 state->cur->map[SYM_CLASSES][cladatum->s.value - 1] =
286 state->src_class = cladatum;
287 state->dest_class = new_class;
288 state->dest_class_name = (char *)key;
292 state);
310 link_state_t *state = (link_state_t *) data;
314 base_role = hashtab_search(state->base->p_roles.table, id);
322 ERR(state->handle,
324 state->cur_mod_name, id);
328 ERR(state->handle,
330 state->cur_mod_name, id);
334 if (state->verbose)
335 INFO(state->handle, "copying role %s", id);
350 new_role->s.value = state->base->p_roles.nprim + 1;
352 ret = hashtab_insert(state->base->p_roles.table,
358 state->base->p_roles.nprim++;
362 if (state->dest_decl) {
374 (state->dest_decl->p_roles.table, new_id, new_role)) {
377 state->dest_decl->p_roles.nprim++;
380 state->cur->map[SYM_ROLES][role->s.value - 1] = base_role->s.value;
384 ERR(state->handle, "Out of memory!");
400 link_state_t *state = (link_state_t *) data;
409 base_type = hashtab_search(state->base->p_types.table, id);
417 ERR(state->handle,
419 state->cur_mod_name, id);
423 ERR(state->handle,
425 state->cur_mod_name, id);
431 if (state->verbose)
432 INFO(state->handle, "copying type %s", id);
448 new_type->s.value = state->base->p_types.nprim + 1;
450 ret = hashtab_insert(state->base->p_types.table,
456 state->base->p_types.nprim++;
460 if (state->dest_decl) {
473 (state->dest_decl->p_types.table, new_id, new_type)) {
476 state->dest_decl->p_types.nprim++;
479 state->cur->map[SYM_TYPES][type->s.value - 1] = base_type->s.value;
483 ERR(state->handle, "Out of memory!");
495 link_state_t *state = (link_state_t *) data;
499 base_user = hashtab_search(state->base->p_users.table, id);
501 if (state->verbose)
502 INFO(state->handle, "copying user %s", id);
516 new_user->s.value = state->base->p_users.nprim + 1;
518 ret = hashtab_insert(state->base->p_users.table,
524 state->base->p_users.nprim++;
528 if (state->dest_decl) {
539 (state->dest_decl->p_users.table, new_id, new_user)) {
542 state->dest_decl->p_users.nprim++;
545 state->cur->map[SYM_USERS][user->s.value - 1] = base_user->s.value;
549 ERR(state->handle, "Out of memory!");
562 link_state_t *state = (link_state_t *) data;
567 base_bool = hashtab_search(state->base->p_bools.table, id);
569 if (state->verbose)
570 INFO(state->handle, "copying boolean %s", id);
580 new_bool->s.value = state->base->p_bools.nprim + 1;
582 ret = hashtab_insert(state->base->p_bools.table,
588 state->base->p_bools.nprim++;
598 ERR(state->handle,
600 "and usage for %s", state->cur_mod_name, id);
605 * if so set the state */
606 scope = hashtab_search(state->cur->policy->p_bools_scope.table, id);
610 base_bool->state = booldatum->state;
615 state->cur->map[SYM_BOOLS][booldatum->s.value - 1] = base_bool->s.value;
619 ERR(state->handle, "Out of memory!");
629 link_state_t *state = (link_state_t *) data;
634 base_level = hashtab_search(state->base->p_levels.table, id);
637 hashtab_search(state->cur->policy->p_sens_scope.table, id);
642 ERR(state->handle,
644 state->cur_mod_name);
649 ERR(state->handle,
651 state->cur_mod_name, id);
656 state->cur->map[SYM_LEVELS][level->level->sens - 1] =
667 link_state_t *state = (link_state_t *) data;
672 base_cat = hashtab_search(state->base->p_cats.table, id);
675 hashtab_search(state->cur->policy->p_cat_scope.table, id);
680 ERR(state->handle,
682 state->cur_mod_name);
687 ERR(state->handle,
689 state->cur_mod_name, id);
694 state->cur->map[SYM_CATS][cat->s.value - 1] = base_cat->s.value;
712 link_state_t *state = (link_state_t *) data;
720 bounds_val = state->cur->map[SYM_TYPES][type->bounds - 1];
722 dest = hashtab_search(state->base->p_types.table, key);
724 ERR(state->handle,
729 ERR(state->handle,
741 link_state_t *state = (link_state_t *) data;
749 bounds_val = state->cur->map[SYM_ROLES][role->bounds - 1];
751 dest = hashtab_search(state->base->p_roles.table, key);
753 ERR(state->handle,
758 ERR(state->handle,
770 link_state_t *state = (link_state_t *) data;
778 bounds_val = state->cur->map[SYM_USERS][user->bounds - 1];
780 dest = hashtab_search(state->base->p_users.table, key);
782 ERR(state->handle,
787 ERR(state->handle,
807 link_state_t *state = (link_state_t *) data;
808 policy_module_t *mod = state->cur;
829 target_type = hashtab_search(state->base->p_types.table, target_id);
831 ERR(state->handle, "%s: Could not find type %s for alias %s.",
832 state->cur_mod_name, target_id, id);
837 ERR(state->handle, "%s: Self aliasing of %s.",
838 state->cur_mod_name, id);
844 base_type = hashtab_search(state->base->p_types.table, id);
846 if (state->verbose)
847 INFO(state->handle, "copying alias %s", id);
857 new_type->s.value = state->base->p_types.nprim + 1;
862 (state->base->p_types.table, new_id, new_type)) {
865 state->base->p_types.nprim++;
883 ERR(state->handle,
900 ERR(state->handle, "Out of memory!");
909 policy_module_t * mod, link_state_t * state
943 policy_module_t * mod, link_state_t * state)
948 if (type_set_convert(types, &ts_tmp, mod, state) == -1) {
958 ERR(state->handle, "Out of memory!");
964 policy_module_t * mod, link_state_t * state)
987 ERR(state->handle, "Out of memory!");
993 policy_module_t * mod, link_state_t * state)
1011 ERR(state->handle, "Out of memory");
1029 policy_module_t * mod, link_state_t * state)
1032 ret = mls_level_convert(&src->level[0], &dst->level[0], mod, state);
1035 ret = mls_level_convert(&src->level[1], &dst->level[1], mod, state);
1047 link_state_t *state = (link_state_t *) data;
1049 policy_module_t *mod = state->cur;
1054 if (state->dest_decl == NULL)
1055 role_tab = state->base->p_roles.table;
1057 role_tab = state->dest_decl->p_roles.table;
1062 if (state->verbose) {
1063 INFO(state->handle, "fixing role %s", id);
1079 if (type_set_or_convert(&role->types, &dest_role->types, mod, state)) {
1104 ERR(state->handle, "Out of memory!");
1115 link_state_t *state = (link_state_t *) data;
1117 policy_module_t *mod = state->cur;
1123 if (state->dest_decl == NULL)
1124 typetab = &state->base->p_types;
1126 typetab = &state->dest_decl->p_types;
1136 if (state->verbose) {
1137 INFO(state->handle, "fixing attribute %s", id);
1157 ERR(state->handle, "Out of memory!");
1167 link_state_t *state = (link_state_t *) data;
1168 policy_module_t *mod = state->cur;
1173 if (state->dest_decl == NULL)
1174 usertab = &state->base->p_users;
1176 usertab = &state->dest_decl->p_users;
1181 if (state->verbose) {
1182 INFO(state->handle, "fixing user %s", id);
1185 if (role_set_or_convert(&user->roles, &new_user->roles, mod, state)) {
1189 if (mls_range_convert(&user->range, &new_user->range, mod, state))
1192 if (mls_level_convert(&user->dfltlevel, &new_user->dfltlevel, mod, state))
1198 ERR(state->handle, "Out of memory!");
1210 policy_module_t * module, link_state_t * state)
1231 (&cur->stypes, &new_rule->stypes, module, state) == -1
1233 state) == -1) {
1290 ERR(state->handle, "Out of memory!");
1298 policy_module_t * module, link_state_t * state)
1318 (&cur->roles, &new_rule->roles, module, state)
1320 module, state)) {
1348 ERR(state->handle, "Out of memory!");
1355 policy_module_t * module, link_state_t * state)
1374 (&cur->roles, &new_rule->roles, module, state)
1377 state)) {
1390 ERR(state->handle, "Out of memory!");
1398 link_state_t * state)
1424 if (type_set_or_convert(&cur->stypes, &new_rule->stypes, module, state) ||
1425 type_set_or_convert(&cur->ttypes, &new_rule->ttypes, module, state))
1435 ERR(state->handle, "Out of memory!");
1441 policy_module_t * mod, link_state_t * state)
1459 mod, state))
1463 mod, state))
1477 if (mls_range_convert(&rule->trange, &new_rule->trange, mod, state))
1483 ERR(state->handle, "Out of memory!");
1489 policy_module_t * module, link_state_t * state)
1531 (cur->avtrue_list, &new_node->avtrue_list, module, state)
1534 state)) {
1548 ERR(state->handle, "Out of memory!");
1557 static int copy_identifiers(link_state_t * state, symtab_t * src_symtab,
1562 state->dest_decl = dest_decl;
1567 state);
1575 type_bounds_copy_callback, state))
1579 alias_copy_callback, state))
1583 role_bounds_copy_callback, state))
1587 user_bounds_copy_callback, state))
1594 state)) {
1602 policy_module_t * module, link_state_t * state)
1658 ERR(state->handle, "Out of memory!");
1662 static int copy_avrule_decl(link_state_t * state, policy_module_t * module,
1669 (src_decl->avrules, &dest_decl->avrules, module, state) == -1
1672 state) == -1
1675 state) == -1
1677 module, state) == -1) {
1683 module, state))
1687 &dest_decl->range_tr_rules, module, state))
1691 ret = copy_identifiers(state, src_decl->symtab, dest_decl);
1698 module, state) == -1 ||
1700 module, state) == -1) {
1707 static int copy_avrule_block(link_state_t * state, policy_module_t * module,
1715 ERR(state->handle, "Out of memory!");
1724 avrule_decl_create(state->next_decl_id);
1726 ERR(state->handle, "Out of memory!");
1734 ERR(state->handle, "Out of memory\n");
1746 state->base->decl_val_to_struct[state->next_decl_id - 1] =
1748 state->decl_to_mod[state->next_decl_id] = module->policy;
1752 ret = copy_avrule_decl(state, module, decl, new_decl);
1757 state->next_decl_id++;
1759 state->last_avrule_block->next = new_block;
1760 state->last_avrule_block = new_block;
1775 link_state_t *state = (link_state_t *) data;
1776 uint32_t symbol_num = state->symbol_num;
1777 uint32_t *avdecl_map = state->cur->avdecl_map;
1782 base_scope = hashtab_search(state->base->scope[symbol_num].table, id);
1794 ret = hashtab_insert(state->base->scope[symbol_num].table,
1836 ERR(state->handle,
1838 state->cur_mod_name,
1839 symtab_names[state->symbol_num], id);
1853 ERR(state->handle, "Out of memory!");
1860 static int copy_module(link_state_t * state, policy_module_t * module)
1864 state->cur = module;
1865 state->cur_mod_name = module->policy->name;
1868 ret = copy_identifiers(state, module->policy->symtab, NULL);
1875 ret = copy_avrule_block(state, module, cur);
1883 state->symbol_num = i;
1886 state)) {
1924 static int is_decl_requires_met(link_state_t * state,
1935 policydb_t *pol = state->base;
1953 if (!is_id_enabled(id, state->base, i)) {
1980 hashtab_search(state->base->p_classes_scope.table,
1983 ERR(state->handle,
2000 if (!is_perm_enabled(id, perm_id, state->base)) {
2015 static int debug_requirements(link_state_t * state, policydb_t * p)
2025 ret = is_decl_requires_met(state, cur->branch_list, &req);
2046 ERR(state->handle,
2054 ERR(state->handle,
2064 ERR(state->handle,
2074 ERR(state->handle,
2090 static void print_missing_requirements(link_state_t * state,
2094 policydb_t *p = state->base;
2109 ERR(state->handle,
2114 ERR(state->handle,
2138 static int enable_avrules(link_state_t * state, policydb_t * pol)
2146 if (state->verbose) {
2147 INFO(state->handle, "Determining which avrules to enable.");
2167 if (state->verbose) {
2170 INFO(state->handle, "check module %s decl %d\n",
2173 rc = is_decl_requires_met(state, decl, &req);
2182 print_missing_requirements(state, block,
2210 if (state->verbose)
2211 debug_requirements(state, pol);
2238 static int prepare_module(link_state_t * state, policy_module_t * module)
2250 ERR(state->handle, "Out of memory!");
2259 ERR(state->handle, "Out of memory!");
2264 ERR(state->handle, "Out of memory!");
2279 ERR(state->handle, "Out of memory!");
2286 ERR(state->handle,
2294 static int prepare_base(link_state_t * state, uint32_t num_mod_decls)
2296 avrule_block_t *cur = state->base->global;
2298 state->next_decl_id = 0;
2305 if (decl->decl_id > state->next_decl_id) {
2306 state->next_decl_id = decl->decl_id;
2309 state->last_avrule_block = cur;
2312 state->last_base_avrule_block = state->last_avrule_block;
2313 state->next_decl_id++;
2317 free(state->base->decl_val_to_struct);
2318 if ((state->base->decl_val_to_struct =
2319 calloc(state->next_decl_id + num_mod_decls,
2320 sizeof(*(state->base->decl_val_to_struct)))) == NULL) {
2321 ERR(state->handle, "Out of memory!");
2325 if ((state->decl_to_mod = calloc(state->next_decl_id + num_mod_decls,
2326 sizeof(*(state->decl_to_mod)))) ==
2328 ERR(state->handle, "Out of memory!");
2331 cur = state->base->global;
2335 state->base->decl_val_to_struct[decl->decl_id - 1] =
2337 state->decl_to_mod[decl->decl_id] = state->base;
2344 if (cond_normalize(state->base) < 0) {
2345 ERR(state->handle,
2357 link_state_t *state;
2363 state = (link_state_t *)data;
2373 if (state->verbose)
2374 INFO(state->handle, "expanding role attribute %s", id);
2379 sub_attr = state->base->role_val_to_struct[i];
2395 ERR(state->handle, "Out of memory!");
2417 link_state_t *state = (link_state_t *)data;
2429 base_role = (role_datum_t *)hashtab_search(state->base->p_roles.table,
2434 ERR(state->handle, "Out of memory!");
2441 static int populate_roleattributes(link_state_t *state, policydb_t *pol)
2446 if (state->verbose)
2447 INFO(state->handle, "Populating role-attribute relationship "
2461 populate_decl_roleattributes, state))
2478 link_state_t state;
2481 memset(&state, 0, sizeof(state));
2482 state.base = b;
2483 state.verbose = verbose;
2484 state.handle = handle;
2487 ERR(state.handle, "Target of link was not a base policy.");
2496 ERR(state.handle, "Out of memory!");
2501 ERR(state.handle,
2508 ERR(state.handle,
2511 ERR(state.handle,
2520 ERR(state.handle, "Out of memory!");
2524 if (prepare_module(&state, modules[i]) == -1) {
2529 if (prepare_base(&state, num_mod_decls) == -1) {
2535 state.cur = modules[i];
2536 state.cur_mod_name = modules[i]->policy->name;
2539 type_copy_callback, &state);
2548 state.cur = modules[i];
2549 state.cur_mod_name = modules[i]->policy->name;
2551 copy_identifiers(&state, modules[i]->policy->symtab, NULL);
2558 if (policydb_index_others(state.handle, state.base, 0)) {
2559 ERR(state.handle, "Error while indexing others");
2565 state.cur = modules[i];
2566 ret = copy_module(&state, modules[i]);
2574 if (policydb_index_classes(state.base)) {
2575 ERR(state.handle, "Error while indexing classes");
2578 if (policydb_index_others(state.handle, state.base, 0)) {
2579 ERR(state.handle, "Error while indexing others");
2583 if (enable_avrules(&state, state.base)) {
2594 if (populate_roleattributes(&state, state.base)) {
2600 if (hashtab_map(state.base->p_roles.table, expand_role_attributes,
2601 &state))
2610 free(state.decl_to_mod);