1*2d543d20SAndroid Build Coastguard Worker /* Authors: Jason Tang <[email protected]> 2*2d543d20SAndroid Build Coastguard Worker * Joshua Brindle <[email protected]> 3*2d543d20SAndroid Build Coastguard Worker * Karl MacMillan <[email protected]> 4*2d543d20SAndroid Build Coastguard Worker * 5*2d543d20SAndroid Build Coastguard Worker * A set of utility functions that aid policy decision when dealing 6*2d543d20SAndroid Build Coastguard Worker * with hierarchal items. 7*2d543d20SAndroid Build Coastguard Worker * 8*2d543d20SAndroid Build Coastguard Worker * Copyright (C) 2005 Tresys Technology, LLC 9*2d543d20SAndroid Build Coastguard Worker * 10*2d543d20SAndroid Build Coastguard Worker * This library is free software; you can redistribute it and/or 11*2d543d20SAndroid Build Coastguard Worker * modify it under the terms of the GNU Lesser General Public 12*2d543d20SAndroid Build Coastguard Worker * License as published by the Free Software Foundation; either 13*2d543d20SAndroid Build Coastguard Worker * version 2.1 of the License, or (at your option) any later version. 14*2d543d20SAndroid Build Coastguard Worker * 15*2d543d20SAndroid Build Coastguard Worker * This library is distributed in the hope that it will be useful, 16*2d543d20SAndroid Build Coastguard Worker * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*2d543d20SAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18*2d543d20SAndroid Build Coastguard Worker * Lesser General Public License for more details. 19*2d543d20SAndroid Build Coastguard Worker * 20*2d543d20SAndroid Build Coastguard Worker * You should have received a copy of the GNU Lesser General Public 21*2d543d20SAndroid Build Coastguard Worker * License along with this library; if not, write to the Free Software 22*2d543d20SAndroid Build Coastguard Worker * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23*2d543d20SAndroid Build Coastguard Worker */ 24*2d543d20SAndroid Build Coastguard Worker 25*2d543d20SAndroid Build Coastguard Worker #ifndef _SEPOL_POLICYDB_EXPAND_H 26*2d543d20SAndroid Build Coastguard Worker #define _SEPOL_POLICYDB_EXPAND_H 27*2d543d20SAndroid Build Coastguard Worker 28*2d543d20SAndroid Build Coastguard Worker #include <stddef.h> 29*2d543d20SAndroid Build Coastguard Worker #include <sepol/handle.h> 30*2d543d20SAndroid Build Coastguard Worker #include <sepol/policydb/conditional.h> 31*2d543d20SAndroid Build Coastguard Worker 32*2d543d20SAndroid Build Coastguard Worker #ifdef __cplusplus 33*2d543d20SAndroid Build Coastguard Worker extern "C" { 34*2d543d20SAndroid Build Coastguard Worker #endif 35*2d543d20SAndroid Build Coastguard Worker 36*2d543d20SAndroid Build Coastguard Worker /* 37*2d543d20SAndroid Build Coastguard Worker * Expand only the avrules for a module. It is valid for this function 38*2d543d20SAndroid Build Coastguard Worker * to expand base into itself (i.e. base == out); the typemap for 39*2d543d20SAndroid Build Coastguard Worker * this special case should map type[i] to i+1. Likewise the boolmap 40*2d543d20SAndroid Build Coastguard Worker * should map bool[i] to i + 1. This function optionally expands 41*2d543d20SAndroid Build Coastguard Worker * neverallow rules. If neverallow rules are expanded, there is no 42*2d543d20SAndroid Build Coastguard Worker * need to copy them and doing so could cause duplicate entries when 43*2d543d20SAndroid Build Coastguard Worker * base == out. If the neverallow rules are not expanded, they are 44*2d543d20SAndroid Build Coastguard Worker * just copied to the destination policy so that assertion checking 45*2d543d20SAndroid Build Coastguard Worker * can be performed after expand. No assertion or hierarchy checking 46*2d543d20SAndroid Build Coastguard Worker * is performed by this function. 47*2d543d20SAndroid Build Coastguard Worker */ 48*2d543d20SAndroid Build Coastguard Worker extern int expand_module_avrules(sepol_handle_t * handle, policydb_t * base, 49*2d543d20SAndroid Build Coastguard Worker policydb_t * out, uint32_t * typemap, uint32_t * boolmap, 50*2d543d20SAndroid Build Coastguard Worker uint32_t * rolemap, uint32_t * usermap, 51*2d543d20SAndroid Build Coastguard Worker int verbose, int expand_neverallow); 52*2d543d20SAndroid Build Coastguard Worker /* 53*2d543d20SAndroid Build Coastguard Worker * Expand all parts of a module. Neverallow rules are not expanded (only 54*2d543d20SAndroid Build Coastguard Worker * copied). It is not valid to expand base into itself. If check is non-zero, 55*2d543d20SAndroid Build Coastguard Worker * performs hierarchy and assertion checking. 56*2d543d20SAndroid Build Coastguard Worker */ 57*2d543d20SAndroid Build Coastguard Worker extern int expand_module(sepol_handle_t * handle, 58*2d543d20SAndroid Build Coastguard Worker policydb_t * base, policydb_t * out, 59*2d543d20SAndroid Build Coastguard Worker int verbose, int check); 60*2d543d20SAndroid Build Coastguard Worker extern int convert_type_ebitmap(ebitmap_t * src, ebitmap_t * dst, 61*2d543d20SAndroid Build Coastguard Worker uint32_t * typemap); 62*2d543d20SAndroid Build Coastguard Worker extern int expand_convert_type_set(policydb_t * p, uint32_t * typemap, 63*2d543d20SAndroid Build Coastguard Worker type_set_t * set, ebitmap_t * types, 64*2d543d20SAndroid Build Coastguard Worker unsigned char alwaysexpand); 65*2d543d20SAndroid Build Coastguard Worker extern int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p, 66*2d543d20SAndroid Build Coastguard Worker unsigned char alwaysexpand); 67*2d543d20SAndroid Build Coastguard Worker extern int role_set_expand(role_set_t * x, ebitmap_t * r, policydb_t * out, policydb_t * base, uint32_t * rolemap); 68*2d543d20SAndroid Build Coastguard Worker extern int mls_semantic_level_expand(mls_semantic_level_t *sl, mls_level_t *l, 69*2d543d20SAndroid Build Coastguard Worker policydb_t *p, sepol_handle_t *h); 70*2d543d20SAndroid Build Coastguard Worker extern int mls_semantic_range_expand(mls_semantic_range_t *sr, mls_range_t *r, 71*2d543d20SAndroid Build Coastguard Worker policydb_t *p, sepol_handle_t *h); 72*2d543d20SAndroid Build Coastguard Worker extern int expand_rule(sepol_handle_t * handle, 73*2d543d20SAndroid Build Coastguard Worker policydb_t * source_pol, 74*2d543d20SAndroid Build Coastguard Worker avrule_t * source_rule, avtab_t * dest_avtab, 75*2d543d20SAndroid Build Coastguard Worker cond_av_list_t ** cond, cond_av_list_t ** other, 76*2d543d20SAndroid Build Coastguard Worker int enabled); 77*2d543d20SAndroid Build Coastguard Worker 78*2d543d20SAndroid Build Coastguard Worker extern int expand_avtab(policydb_t * p, avtab_t * a, avtab_t * expa); 79*2d543d20SAndroid Build Coastguard Worker 80*2d543d20SAndroid Build Coastguard Worker extern int expand_cond_av_list(policydb_t * p, cond_av_list_t * l, 81*2d543d20SAndroid Build Coastguard Worker cond_av_list_t ** newl, avtab_t * expa); 82*2d543d20SAndroid Build Coastguard Worker 83*2d543d20SAndroid Build Coastguard Worker #ifdef __cplusplus 84*2d543d20SAndroid Build Coastguard Worker } 85*2d543d20SAndroid Build Coastguard Worker #endif 86*2d543d20SAndroid Build Coastguard Worker 87*2d543d20SAndroid Build Coastguard Worker #endif 88