16cd6a6acSopenharmony_ci/* Authors: Jason Tang <jtang@tresys.com> 26cd6a6acSopenharmony_ci * Joshua Brindle <jbrindle@tresys.com> 36cd6a6acSopenharmony_ci * Karl MacMillan <kmacmillan@tresys.com> 46cd6a6acSopenharmony_ci * 56cd6a6acSopenharmony_ci * A set of utility functions that aid policy decision when dealing 66cd6a6acSopenharmony_ci * with hierarchal items. 76cd6a6acSopenharmony_ci * 86cd6a6acSopenharmony_ci * Copyright (C) 2005 Tresys Technology, LLC 96cd6a6acSopenharmony_ci * 106cd6a6acSopenharmony_ci * This library is free software; you can redistribute it and/or 116cd6a6acSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 126cd6a6acSopenharmony_ci * License as published by the Free Software Foundation; either 136cd6a6acSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 146cd6a6acSopenharmony_ci * 156cd6a6acSopenharmony_ci * This library is distributed in the hope that it will be useful, 166cd6a6acSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 176cd6a6acSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 186cd6a6acSopenharmony_ci * Lesser General Public License for more details. 196cd6a6acSopenharmony_ci * 206cd6a6acSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 216cd6a6acSopenharmony_ci * License along with this library; if not, write to the Free Software 226cd6a6acSopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 236cd6a6acSopenharmony_ci */ 246cd6a6acSopenharmony_ci 256cd6a6acSopenharmony_ci#ifndef _SEPOL_POLICYDB_EXPAND_H 266cd6a6acSopenharmony_ci#define _SEPOL_POLICYDB_EXPAND_H 276cd6a6acSopenharmony_ci 286cd6a6acSopenharmony_ci#include <stddef.h> 296cd6a6acSopenharmony_ci#include <sepol/handle.h> 306cd6a6acSopenharmony_ci#include <sepol/policydb/conditional.h> 316cd6a6acSopenharmony_ci 326cd6a6acSopenharmony_ci#ifdef __cplusplus 336cd6a6acSopenharmony_ciextern "C" { 346cd6a6acSopenharmony_ci#endif 356cd6a6acSopenharmony_ci 366cd6a6acSopenharmony_ci/* 376cd6a6acSopenharmony_ci * Expand only the avrules for a module. It is valid for this function 386cd6a6acSopenharmony_ci * to expand base into itself (i.e. base == out); the typemap for 396cd6a6acSopenharmony_ci * this special case should map type[i] to i+1. Likewise the boolmap 406cd6a6acSopenharmony_ci * should map bool[i] to i + 1. This function optionally expands 416cd6a6acSopenharmony_ci * neverallow rules. If neverallow rules are expanded, there is no 426cd6a6acSopenharmony_ci * need to copy them and doing so could cause duplicate entries when 436cd6a6acSopenharmony_ci * base == out. If the neverallow rules are not expanded, they are 446cd6a6acSopenharmony_ci * just copied to the destination policy so that assertion checking 456cd6a6acSopenharmony_ci * can be performed after expand. No assertion or hierarchy checking 466cd6a6acSopenharmony_ci * is performed by this function. 476cd6a6acSopenharmony_ci */ 486cd6a6acSopenharmony_ciextern int expand_module_avrules(sepol_handle_t * handle, policydb_t * base, 496cd6a6acSopenharmony_ci policydb_t * out, uint32_t * typemap, uint32_t * boolmap, 506cd6a6acSopenharmony_ci uint32_t * rolemap, uint32_t * usermap, 516cd6a6acSopenharmony_ci int verbose, int expand_neverallow); 526cd6a6acSopenharmony_ci/* 536cd6a6acSopenharmony_ci * Expand all parts of a module. Neverallow rules are not expanded (only 546cd6a6acSopenharmony_ci * copied). It is not valid to expand base into itself. If check is non-zero, 556cd6a6acSopenharmony_ci * performs hierarchy and assertion checking. 566cd6a6acSopenharmony_ci */ 576cd6a6acSopenharmony_ciextern int expand_module(sepol_handle_t * handle, 586cd6a6acSopenharmony_ci policydb_t * base, policydb_t * out, 596cd6a6acSopenharmony_ci int verbose, int check); 606cd6a6acSopenharmony_ciextern int convert_type_ebitmap(ebitmap_t * src, ebitmap_t * dst, 616cd6a6acSopenharmony_ci uint32_t * typemap); 626cd6a6acSopenharmony_ciextern int expand_convert_type_set(policydb_t * p, uint32_t * typemap, 636cd6a6acSopenharmony_ci type_set_t * set, ebitmap_t * types, 646cd6a6acSopenharmony_ci unsigned char alwaysexpand); 656cd6a6acSopenharmony_ciextern int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p, 666cd6a6acSopenharmony_ci unsigned char alwaysexpand); 676cd6a6acSopenharmony_ciextern int role_set_expand(role_set_t * x, ebitmap_t * r, policydb_t * out, policydb_t * base, uint32_t * rolemap); 686cd6a6acSopenharmony_ciextern int mls_semantic_level_expand(mls_semantic_level_t *sl, mls_level_t *l, 696cd6a6acSopenharmony_ci policydb_t *p, sepol_handle_t *h); 706cd6a6acSopenharmony_ciextern int mls_semantic_range_expand(mls_semantic_range_t *sr, mls_range_t *r, 716cd6a6acSopenharmony_ci policydb_t *p, sepol_handle_t *h); 726cd6a6acSopenharmony_ciextern int expand_rule(sepol_handle_t * handle, 736cd6a6acSopenharmony_ci policydb_t * source_pol, 746cd6a6acSopenharmony_ci avrule_t * source_rule, avtab_t * dest_avtab, 756cd6a6acSopenharmony_ci cond_av_list_t ** cond, cond_av_list_t ** other, 766cd6a6acSopenharmony_ci int enabled); 776cd6a6acSopenharmony_ci 786cd6a6acSopenharmony_ciextern int expand_avtab(policydb_t * p, avtab_t * a, avtab_t * expa); 796cd6a6acSopenharmony_ci 806cd6a6acSopenharmony_ciextern int expand_cond_av_list(policydb_t * p, cond_av_list_t * l, 816cd6a6acSopenharmony_ci cond_av_list_t ** newl, avtab_t * expa); 826cd6a6acSopenharmony_ci 836cd6a6acSopenharmony_ci#ifdef __cplusplus 846cd6a6acSopenharmony_ci} 856cd6a6acSopenharmony_ci#endif 866cd6a6acSopenharmony_ci 876cd6a6acSopenharmony_ci#endif 88