1*2d543d20SAndroid Build Coastguard Worker /* 2*2d543d20SAndroid Build Coastguard Worker * Copyright 2011 Tresys Technology, LLC. All rights reserved. 3*2d543d20SAndroid Build Coastguard Worker * 4*2d543d20SAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without 5*2d543d20SAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions are met: 6*2d543d20SAndroid Build Coastguard Worker * 7*2d543d20SAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright notice, 8*2d543d20SAndroid Build Coastguard Worker * this list of conditions and the following disclaimer. 9*2d543d20SAndroid Build Coastguard Worker * 10*2d543d20SAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright notice, 11*2d543d20SAndroid Build Coastguard Worker * this list of conditions and the following disclaimer in the documentation 12*2d543d20SAndroid Build Coastguard Worker * and/or other materials provided with the distribution. 13*2d543d20SAndroid Build Coastguard Worker * 14*2d543d20SAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY TRESYS TECHNOLOGY, LLC ``AS IS'' AND ANY EXPRESS 15*2d543d20SAndroid Build Coastguard Worker * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16*2d543d20SAndroid Build Coastguard Worker * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17*2d543d20SAndroid Build Coastguard Worker * EVENT SHALL TRESYS TECHNOLOGY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18*2d543d20SAndroid Build Coastguard Worker * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 19*2d543d20SAndroid Build Coastguard Worker * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20*2d543d20SAndroid Build Coastguard Worker * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 21*2d543d20SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 22*2d543d20SAndroid Build Coastguard Worker * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23*2d543d20SAndroid Build Coastguard Worker * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24*2d543d20SAndroid Build Coastguard Worker * 25*2d543d20SAndroid Build Coastguard Worker * The views and conclusions contained in the software and documentation are those 26*2d543d20SAndroid Build Coastguard Worker * of the authors and should not be interpreted as representing official policies, 27*2d543d20SAndroid Build Coastguard Worker * either expressed or implied, of Tresys Technology, LLC. 28*2d543d20SAndroid Build Coastguard Worker */ 29*2d543d20SAndroid Build Coastguard Worker 30*2d543d20SAndroid Build Coastguard Worker #ifndef _CIL_BINARY_H_ 31*2d543d20SAndroid Build Coastguard Worker #define _CIL_BINARY_H_ 32*2d543d20SAndroid Build Coastguard Worker 33*2d543d20SAndroid Build Coastguard Worker #include <sepol/policydb/policydb.h> 34*2d543d20SAndroid Build Coastguard Worker 35*2d543d20SAndroid Build Coastguard Worker #include "cil_internal.h" 36*2d543d20SAndroid Build Coastguard Worker #include "cil_tree.h" 37*2d543d20SAndroid Build Coastguard Worker #include "cil_list.h" 38*2d543d20SAndroid Build Coastguard Worker 39*2d543d20SAndroid Build Coastguard Worker /** 40*2d543d20SAndroid Build Coastguard Worker * Create a binary policydb from the cil db. 41*2d543d20SAndroid Build Coastguard Worker * 42*2d543d20SAndroid Build Coastguard Worker * @param[in] db The cil database. 43*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database. 44*2d543d20SAndroid Build Coastguard Worker * 45*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 46*2d543d20SAndroid Build Coastguard Worker */ 47*2d543d20SAndroid Build Coastguard Worker int cil_binary_create(const struct cil_db *db, sepol_policydb_t **pdb); 48*2d543d20SAndroid Build Coastguard Worker 49*2d543d20SAndroid Build Coastguard Worker /** 50*2d543d20SAndroid Build Coastguard Worker * Create a pre allocated binary policydb from the cil db. 51*2d543d20SAndroid Build Coastguard Worker * 52*2d543d20SAndroid Build Coastguard Worker * It is assumed that pdb has been allocated and initialized so that fields such 53*2d543d20SAndroid Build Coastguard Worker * as policy type and version are set appropriately. It is recommended that 54*2d543d20SAndroid Build Coastguard Worker * instead of calling this, one instead calls cil_binary_create, which will 55*2d543d20SAndroid Build Coastguard Worker * properly allocate and initialize the pdb and then calls this function. This 56*2d543d20SAndroid Build Coastguard Worker * function is used to maintain binary backwards compatibility. 57*2d543d20SAndroid Build Coastguard Worker * 58*2d543d20SAndroid Build Coastguard Worker * @param[in] db The cil database. 59*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database. 60*2d543d20SAndroid Build Coastguard Worker * 61*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 62*2d543d20SAndroid Build Coastguard Worker */ 63*2d543d20SAndroid Build Coastguard Worker int cil_binary_create_allocated_pdb(const struct cil_db *db, sepol_policydb_t *pdb); 64*2d543d20SAndroid Build Coastguard Worker 65*2d543d20SAndroid Build Coastguard Worker /** 66*2d543d20SAndroid Build Coastguard Worker * Insert cil common structure into sepol policydb. 67*2d543d20SAndroid Build Coastguard Worker * 68*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the common into. 69*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_common datum. 70*2d543d20SAndroid Build Coastguard Worker * @param[out] common_out The sepol common to send back. 71*2d543d20SAndroid Build Coastguard Worker * 72*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 73*2d543d20SAndroid Build Coastguard Worker */ 74*2d543d20SAndroid Build Coastguard Worker int cil_common_to_policydb(policydb_t *pdb, struct cil_class *cil_common, common_datum_t **common_out); 75*2d543d20SAndroid Build Coastguard Worker 76*2d543d20SAndroid Build Coastguard Worker /** 77*2d543d20SAndroid Build Coastguard Worker * Insert cil class structure into sepol policydb. 78*2d543d20SAndroid Build Coastguard Worker * 79*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the class into. 80*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_class datum. 81*2d543d20SAndroid Build Coastguard Worker * 82*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 83*2d543d20SAndroid Build Coastguard Worker */ 84*2d543d20SAndroid Build Coastguard Worker int cil_class_to_policydb(policydb_t *pdb, struct cil_class *cil_class); 85*2d543d20SAndroid Build Coastguard Worker 86*2d543d20SAndroid Build Coastguard Worker /** 87*2d543d20SAndroid Build Coastguard Worker * Insert cil role structure into sepol policydb. 88*2d543d20SAndroid Build Coastguard Worker * 89*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the role into. 90*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_role datum. 91*2d543d20SAndroid Build Coastguard Worker * 92*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 93*2d543d20SAndroid Build Coastguard Worker */ 94*2d543d20SAndroid Build Coastguard Worker int cil_role_to_policydb(policydb_t *pdb, struct cil_role *cil_role); 95*2d543d20SAndroid Build Coastguard Worker 96*2d543d20SAndroid Build Coastguard Worker /** 97*2d543d20SAndroid Build Coastguard Worker * Insert cil roletype structure into sepol policydb. 98*2d543d20SAndroid Build Coastguard Worker * 99*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the roletype into. 100*2d543d20SAndroid Build Coastguard Worker * @param[in] db The cil database 101*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_roletype datum. 102*2d543d20SAndroid Build Coastguard Worker * 103*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or SEPOL_ERR otherwise. 104*2d543d20SAndroid Build Coastguard Worker */ 105*2d543d20SAndroid Build Coastguard Worker int cil_roletype_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_role *role); 106*2d543d20SAndroid Build Coastguard Worker 107*2d543d20SAndroid Build Coastguard Worker /** 108*2d543d20SAndroid Build Coastguard Worker * Insert cil type structure into sepol policydb. 109*2d543d20SAndroid Build Coastguard Worker * 110*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the type into. 111*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_type datum. 112*2d543d20SAndroid Build Coastguard Worker * 113*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 114*2d543d20SAndroid Build Coastguard Worker */ 115*2d543d20SAndroid Build Coastguard Worker int cil_type_to_policydb(policydb_t *pdb, struct cil_type *cil_type, void *type_value_to_cil[]); 116*2d543d20SAndroid Build Coastguard Worker 117*2d543d20SAndroid Build Coastguard Worker /** 118*2d543d20SAndroid Build Coastguard Worker * Insert cil typealias structure into sepol policydb. 119*2d543d20SAndroid Build Coastguard Worker * 120*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the typealias into. 121*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_typealias datum. 122*2d543d20SAndroid Build Coastguard Worker * 123*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 124*2d543d20SAndroid Build Coastguard Worker */ 125*2d543d20SAndroid Build Coastguard Worker int cil_typealias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alias); 126*2d543d20SAndroid Build Coastguard Worker 127*2d543d20SAndroid Build Coastguard Worker /** 128*2d543d20SAndroid Build Coastguard Worker * Insert cil typepermissive structure into sepol policydb. 129*2d543d20SAndroid Build Coastguard Worker * The function looks up the previously inserted type and flips the bit 130*2d543d20SAndroid Build Coastguard Worker * in the permssive types bitmap that corresponds to that type's value. 131*2d543d20SAndroid Build Coastguard Worker * 132*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the typepermissive into. 133*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_typepermissive datum. 134*2d543d20SAndroid Build Coastguard Worker * 135*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 136*2d543d20SAndroid Build Coastguard Worker */ 137*2d543d20SAndroid Build Coastguard Worker int cil_typepermissive_to_policydb(policydb_t *pdb, struct cil_typepermissive *cil_typeperm); 138*2d543d20SAndroid Build Coastguard Worker 139*2d543d20SAndroid Build Coastguard Worker /** 140*2d543d20SAndroid Build Coastguard Worker * Insert cil attribute structure into sepol policydb. 141*2d543d20SAndroid Build Coastguard Worker * 142*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the attribute into. 143*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_attribute datum. 144*2d543d20SAndroid Build Coastguard Worker * 145*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 146*2d543d20SAndroid Build Coastguard Worker */ 147*2d543d20SAndroid Build Coastguard Worker int cil_typeattribute_to_policydb(policydb_t *pdb, struct cil_typeattribute *cil_attr, void *type_value_to_cil[]); 148*2d543d20SAndroid Build Coastguard Worker 149*2d543d20SAndroid Build Coastguard Worker /** 150*2d543d20SAndroid Build Coastguard Worker * Insert cil attribute structure into sepol type->attribute bitmap. 151*2d543d20SAndroid Build Coastguard Worker * The function calls helper functions to loop over the attributes lists 152*2d543d20SAndroid Build Coastguard Worker * of types and negative types. If either of the lists contain an attribute, 153*2d543d20SAndroid Build Coastguard Worker * the helper functions will recurse into the attribute and record the 154*2d543d20SAndroid Build Coastguard Worker * attribute's types and negative types. There is no minimum depth. 155*2d543d20SAndroid Build Coastguard Worker * 156*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database that contains the type->attribute bitmap. 157*2d543d20SAndroid Build Coastguard Worker * @param[in] db The cil database 158*2d543d20SAndroid Build Coastguard Worker * @param[in] node The tree node that contains the cil_attribute. 159*2d543d20SAndroid Build Coastguard Worker * 160*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 161*2d543d20SAndroid Build Coastguard Worker */ 162*2d543d20SAndroid Build Coastguard Worker int cil_typeattribute_to_bitmap(policydb_t *pdb, const struct cil_db *cdb, struct cil_typeattribute *cil_attr); 163*2d543d20SAndroid Build Coastguard Worker 164*2d543d20SAndroid Build Coastguard Worker /** 165*2d543d20SAndroid Build Coastguard Worker * Insert cil policycap structure into sepol policydb. 166*2d543d20SAndroid Build Coastguard Worker * 167*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the policycap into. 168*2d543d20SAndroid Build Coastguard Worker * @param[in] node The tree node that contains the cil_policycap. 169*2d543d20SAndroid Build Coastguard Worker * 170*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or SEPOL_ERR upon error. 171*2d543d20SAndroid Build Coastguard Worker */ 172*2d543d20SAndroid Build Coastguard Worker int cil_policycap_to_policydb(policydb_t *pdb, struct cil_policycap *cil_polcap); 173*2d543d20SAndroid Build Coastguard Worker 174*2d543d20SAndroid Build Coastguard Worker /** 175*2d543d20SAndroid Build Coastguard Worker * Insert cil user structure into sepol policydb. 176*2d543d20SAndroid Build Coastguard Worker * 177*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb THe policy database to insert the user into. 178*2d543d20SAndroid Build Coastguard Worker * @param[in] node The tree node that contains the cil_user. 179*2d543d20SAndroid Build Coastguard Worker * 180*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 181*2d543d20SAndroid Build Coastguard Worker */ 182*2d543d20SAndroid Build Coastguard Worker int cil_user_to_policydb(policydb_t *pdb, struct cil_user *cil_user); 183*2d543d20SAndroid Build Coastguard Worker 184*2d543d20SAndroid Build Coastguard Worker /** 185*2d543d20SAndroid Build Coastguard Worker * Insert cil userrole structure into sepol policydb. 186*2d543d20SAndroid Build Coastguard Worker * 187*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the userrole into. 188*2d543d20SAndroid Build Coastguard Worker * @param[in] db The cil database 189*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_user 190*2d543d20SAndroid Build Coastguard Worker * 191*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or SEPOL_ERR otherwise. 192*2d543d20SAndroid Build Coastguard Worker */ 193*2d543d20SAndroid Build Coastguard Worker int cil_userrole_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_user *user); 194*2d543d20SAndroid Build Coastguard Worker 195*2d543d20SAndroid Build Coastguard Worker /** 196*2d543d20SAndroid Build Coastguard Worker * Insert cil bool structure into sepol policydb. 197*2d543d20SAndroid Build Coastguard Worker * 198*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb THe policy database to insert the bool into. 199*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_bool datum. 200*2d543d20SAndroid Build Coastguard Worker * 201*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 202*2d543d20SAndroid Build Coastguard Worker */ 203*2d543d20SAndroid Build Coastguard Worker int cil_bool_to_policydb(policydb_t *pdb, struct cil_bool *cil_bool); 204*2d543d20SAndroid Build Coastguard Worker 205*2d543d20SAndroid Build Coastguard Worker /** 206*2d543d20SAndroid Build Coastguard Worker * Insert all ordered cil category structures into sepol policydb. 207*2d543d20SAndroid Build Coastguard Worker * 208*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the categories into. 209*2d543d20SAndroid Build Coastguard Worker * @param[in] db The cil database that contains the category order list. 210*2d543d20SAndroid Build Coastguard Worker * 211*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 212*2d543d20SAndroid Build Coastguard Worker */ 213*2d543d20SAndroid Build Coastguard Worker int cil_catorder_to_policydb(policydb_t *pdb, const struct cil_db *db); 214*2d543d20SAndroid Build Coastguard Worker 215*2d543d20SAndroid Build Coastguard Worker /** 216*2d543d20SAndroid Build Coastguard Worker * Insert cil category alias structure into sepol policydb. 217*2d543d20SAndroid Build Coastguard Worker * 218*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the category alias into. 219*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_catalias datum. 220*2d543d20SAndroid Build Coastguard Worker * 221*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 222*2d543d20SAndroid Build Coastguard Worker */ 223*2d543d20SAndroid Build Coastguard Worker int cil_catalias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alias); 224*2d543d20SAndroid Build Coastguard Worker 225*2d543d20SAndroid Build Coastguard Worker /** 226*2d543d20SAndroid Build Coastguard Worker * Insert the cil sensitivityorder into sepol policydb. 227*2d543d20SAndroid Build Coastguard Worker * 228*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the sensitivityorder into. 229*2d543d20SAndroid Build Coastguard Worker * @param[in] db the cil database that contains the sensitivityorder list. 230*2d543d20SAndroid Build Coastguard Worker * 231*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 232*2d543d20SAndroid Build Coastguard Worker */ 233*2d543d20SAndroid Build Coastguard Worker int cil_sensitivityorder_to_policydb(policydb_t *pdb, const struct cil_db *db); 234*2d543d20SAndroid Build Coastguard Worker 235*2d543d20SAndroid Build Coastguard Worker /** 236*2d543d20SAndroid Build Coastguard Worker * Insert cil type rule structure into sepol policydb. This includes 237*2d543d20SAndroid Build Coastguard Worker * typetransition, typechange, and typemember. 238*2d543d20SAndroid Build Coastguard Worker * 239*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the type rule into. 240*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_type_rule datum. 241*2d543d20SAndroid Build Coastguard Worker * 242*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 243*2d543d20SAndroid Build Coastguard Worker */ 244*2d543d20SAndroid Build Coastguard Worker int cil_type_rule_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_type_rule *cil_rule); 245*2d543d20SAndroid Build Coastguard Worker 246*2d543d20SAndroid Build Coastguard Worker /** 247*2d543d20SAndroid Build Coastguard Worker * Insert cil avrule structure into sepol policydb. 248*2d543d20SAndroid Build Coastguard Worker * 249*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the avrule into. 250*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_avrule datum. 251*2d543d20SAndroid Build Coastguard Worker * 252*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 253*2d543d20SAndroid Build Coastguard Worker */ 254*2d543d20SAndroid Build Coastguard Worker int cil_avrule_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_avrule *cil_avrule); 255*2d543d20SAndroid Build Coastguard Worker 256*2d543d20SAndroid Build Coastguard Worker /** 257*2d543d20SAndroid Build Coastguard Worker * Insert cil booleanif structure into sepol policydb. This populates the 258*2d543d20SAndroid Build Coastguard Worker * policydb conditional list. Each conditional node contains an expression 259*2d543d20SAndroid Build Coastguard Worker * and true/false avtab_ptr lists that point into te_cond_avtab. 260*2d543d20SAndroid Build Coastguard Worker * 261*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the booleanif into. 262*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_booleanif node. 263*2d543d20SAndroid Build Coastguard Worker * 264*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 265*2d543d20SAndroid Build Coastguard Worker */ 266*2d543d20SAndroid Build Coastguard Worker int cil_booleanif_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_tree_node *node); 267*2d543d20SAndroid Build Coastguard Worker 268*2d543d20SAndroid Build Coastguard Worker /** 269*2d543d20SAndroid Build Coastguard Worker * Insert cil role transition structure into sepol policydb. 270*2d543d20SAndroid Build Coastguard Worker * 271*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the role transition into. 272*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_role_trans datum. 273*2d543d20SAndroid Build Coastguard Worker * 274*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or SEPOL_ERR upon error. 275*2d543d20SAndroid Build Coastguard Worker */ 276*2d543d20SAndroid Build Coastguard Worker int cil_roletrans_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_roletransition *roletrans, hashtab_t role_trans_table); 277*2d543d20SAndroid Build Coastguard Worker 278*2d543d20SAndroid Build Coastguard Worker /** 279*2d543d20SAndroid Build Coastguard Worker * Insert cil role allow structure into sepol policydb. 280*2d543d20SAndroid Build Coastguard Worker * 281*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the role allow into. 282*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_role_allow datum. 283*2d543d20SAndroid Build Coastguard Worker * 284*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or SEPOL_ERR upon error. 285*2d543d20SAndroid Build Coastguard Worker */ 286*2d543d20SAndroid Build Coastguard Worker int cil_roleallow_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_roleallow *roleallow); 287*2d543d20SAndroid Build Coastguard Worker 288*2d543d20SAndroid Build Coastguard Worker /** 289*2d543d20SAndroid Build Coastguard Worker * Insert cil file transition structure into sepol policydb. 290*2d543d20SAndroid Build Coastguard Worker * 291*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the file transition into. 292*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_nametypetransition datum. 293*2d543d20SAndroid Build Coastguard Worker * 294*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or SEPOL_ERR upon error. 295*2d543d20SAndroid Build Coastguard Worker */ 296*2d543d20SAndroid Build Coastguard Worker int cil_typetransition_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_nametypetransition *typetrans); 297*2d543d20SAndroid Build Coastguard Worker 298*2d543d20SAndroid Build Coastguard Worker /** 299*2d543d20SAndroid Build Coastguard Worker * Insert cil constrain/mlsconstrain structure(s) into sepol policydb. 300*2d543d20SAndroid Build Coastguard Worker * 301*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the (mls)constrain into. 302*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_(mls)constrain datum. 303*2d543d20SAndroid Build Coastguard Worker * 304*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or SEPOL_ERR upon error. 305*2d543d20SAndroid Build Coastguard Worker */ 306*2d543d20SAndroid Build Coastguard Worker int cil_constrain_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_constrain *cil_constrain); 307*2d543d20SAndroid Build Coastguard Worker 308*2d543d20SAndroid Build Coastguard Worker /** 309*2d543d20SAndroid Build Coastguard Worker * Define sepol level. 310*2d543d20SAndroid Build Coastguard Worker * Associates the sepol level (sensitivity) with categories. 311*2d543d20SAndroid Build Coastguard Worker * Looks at the cil_sens structure for a list of cil_cats to 312*2d543d20SAndroid Build Coastguard Worker * associate the sensitivity with. 313*2d543d20SAndroid Build Coastguard Worker * Sets the sepol level as defined in the sepol policy database. 314*2d543d20SAndroid Build Coastguard Worker * 315*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database that holds the sepol level. 316*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_sens datum. 317*2d543d20SAndroid Build Coastguard Worker * 318*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or SEPOL_ERR upon error. 319*2d543d20SAndroid Build Coastguard Worker */ 320*2d543d20SAndroid Build Coastguard Worker int cil_sepol_level_define(policydb_t *pdb, struct cil_sens *cil_sens); 321*2d543d20SAndroid Build Coastguard Worker 322*2d543d20SAndroid Build Coastguard Worker /** 323*2d543d20SAndroid Build Coastguard Worker * Insert cil rangetransition structure into sepol policydb. 324*2d543d20SAndroid Build Coastguard Worker * 325*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the rangetransition into. 326*2d543d20SAndroid Build Coastguard Worker * @param[in] datum The cil_rangetransition datum. 327*2d543d20SAndroid Build Coastguard Worker * 328*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 329*2d543d20SAndroid Build Coastguard Worker */ 330*2d543d20SAndroid Build Coastguard Worker int cil_rangetransition_to_policydb(policydb_t *pdb, const struct cil_db *db, struct cil_rangetransition *rangetrans); 331*2d543d20SAndroid Build Coastguard Worker 332*2d543d20SAndroid Build Coastguard Worker /** 333*2d543d20SAndroid Build Coastguard Worker * Insert cil ibpkeycon structure into sepol policydb. 334*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted ibpkeycons and 335*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 336*2d543d20SAndroid Build Coastguard Worker * 337*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the ibpkeycon into. 338*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted ibpkeycons. 339*2d543d20SAndroid Build Coastguard Worker * 340*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 341*2d543d20SAndroid Build Coastguard Worker */ 342*2d543d20SAndroid Build Coastguard Worker int cil_ibpkeycon_to_policydb(policydb_t *pdb, struct cil_sort *ibpkeycons); 343*2d543d20SAndroid Build Coastguard Worker 344*2d543d20SAndroid Build Coastguard Worker /** 345*2d543d20SAndroid Build Coastguard Worker * Insert cil idbev structure into sepol policydb. 346*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted ibendportcons and 347*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 348*2d543d20SAndroid Build Coastguard Worker * 349*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the pkeycon into. 350*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted ibendportcons. 351*2d543d20SAndroid Build Coastguard Worker * 352*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 353*2d543d20SAndroid Build Coastguard Worker */ 354*2d543d20SAndroid Build Coastguard Worker int cil_ibendportcon_to_policydb(policydb_t *pdb, struct cil_sort *pkeycons); 355*2d543d20SAndroid Build Coastguard Worker 356*2d543d20SAndroid Build Coastguard Worker /** 357*2d543d20SAndroid Build Coastguard Worker * Insert cil portcon structure into sepol policydb. 358*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted portcons and 359*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 360*2d543d20SAndroid Build Coastguard Worker * 361*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the portcon into. 362*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted portcons. 363*2d543d20SAndroid Build Coastguard Worker * 364*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 365*2d543d20SAndroid Build Coastguard Worker */ 366*2d543d20SAndroid Build Coastguard Worker int cil_portcon_to_policydb(policydb_t *pdb, struct cil_sort *portcons); 367*2d543d20SAndroid Build Coastguard Worker 368*2d543d20SAndroid Build Coastguard Worker /** 369*2d543d20SAndroid Build Coastguard Worker * Insert cil netifcon structure into sepol policydb. 370*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted netifcons and 371*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 372*2d543d20SAndroid Build Coastguard Worker * 373*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the netifcon into. 374*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted netifcons. 375*2d543d20SAndroid Build Coastguard Worker * 376*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 377*2d543d20SAndroid Build Coastguard Worker */ 378*2d543d20SAndroid Build Coastguard Worker int cil_netifcon_to_policydb(policydb_t *pdb, struct cil_sort *netifcons); 379*2d543d20SAndroid Build Coastguard Worker 380*2d543d20SAndroid Build Coastguard Worker /** 381*2d543d20SAndroid Build Coastguard Worker * Insert cil nodecon structure into sepol policydb. 382*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted nodecons and 383*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 384*2d543d20SAndroid Build Coastguard Worker * 385*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the nodecon into. 386*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted nodecons. 387*2d543d20SAndroid Build Coastguard Worker * 388*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 389*2d543d20SAndroid Build Coastguard Worker */ 390*2d543d20SAndroid Build Coastguard Worker int cil_nodecon_to_policydb(policydb_t *pdb, struct cil_sort *nodecons); 391*2d543d20SAndroid Build Coastguard Worker 392*2d543d20SAndroid Build Coastguard Worker /** 393*2d543d20SAndroid Build Coastguard Worker * Insert cil fsuse structure into sepol policydb. 394*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted fsuses and 395*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 396*2d543d20SAndroid Build Coastguard Worker * 397*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the fsuse into. 398*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted fsuses. 399*2d543d20SAndroid Build Coastguard Worker * 400*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 401*2d543d20SAndroid Build Coastguard Worker */ 402*2d543d20SAndroid Build Coastguard Worker int cil_fsuse_to_policydb(policydb_t *pdb, struct cil_sort *fsuses); 403*2d543d20SAndroid Build Coastguard Worker 404*2d543d20SAndroid Build Coastguard Worker /** 405*2d543d20SAndroid Build Coastguard Worker * Insert cil genfscon structure into sepol policydb. 406*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted genfscons and 407*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 408*2d543d20SAndroid Build Coastguard Worker * 409*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the genfscon into. 410*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted genfscons. 411*2d543d20SAndroid Build Coastguard Worker * 412*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 413*2d543d20SAndroid Build Coastguard Worker */ 414*2d543d20SAndroid Build Coastguard Worker int cil_genfscon_to_policydb(policydb_t *pdb, struct cil_sort *genfscons); 415*2d543d20SAndroid Build Coastguard Worker 416*2d543d20SAndroid Build Coastguard Worker /** 417*2d543d20SAndroid Build Coastguard Worker * Insert cil pirqcon structure into sepol policydb. 418*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted pirqcons and 419*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 420*2d543d20SAndroid Build Coastguard Worker * 421*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the pirqcon into. 422*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted pirqcons. 423*2d543d20SAndroid Build Coastguard Worker * 424*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 425*2d543d20SAndroid Build Coastguard Worker */ 426*2d543d20SAndroid Build Coastguard Worker int cil_pirqcon_to_policydb(policydb_t *pdb, struct cil_sort *pirqcons); 427*2d543d20SAndroid Build Coastguard Worker 428*2d543d20SAndroid Build Coastguard Worker /** 429*2d543d20SAndroid Build Coastguard Worker * Insert cil iomemcon structure into sepol policydb. 430*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted iomemcons and 431*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 432*2d543d20SAndroid Build Coastguard Worker * 433*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the iomemcon into. 434*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted iomemcons. 435*2d543d20SAndroid Build Coastguard Worker * 436*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 437*2d543d20SAndroid Build Coastguard Worker */ 438*2d543d20SAndroid Build Coastguard Worker int cil_iomemcon_to_policydb(policydb_t *pdb, struct cil_sort *iomemcons); 439*2d543d20SAndroid Build Coastguard Worker 440*2d543d20SAndroid Build Coastguard Worker /** 441*2d543d20SAndroid Build Coastguard Worker * Insert cil ioportcon structure into sepol policydb. 442*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted ioportcons and 443*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 444*2d543d20SAndroid Build Coastguard Worker * 445*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the ioportcon into. 446*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted ioportcons. 447*2d543d20SAndroid Build Coastguard Worker * 448*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 449*2d543d20SAndroid Build Coastguard Worker */ 450*2d543d20SAndroid Build Coastguard Worker int cil_ioportcon_to_policydb(policydb_t *pdb, struct cil_sort *ioportcons); 451*2d543d20SAndroid Build Coastguard Worker 452*2d543d20SAndroid Build Coastguard Worker /** 453*2d543d20SAndroid Build Coastguard Worker * Insert cil pcidevicecon structure into sepol policydb. 454*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the sorted pcidevicecons and 455*2d543d20SAndroid Build Coastguard Worker * loops over this structure inserting them into the policy database. 456*2d543d20SAndroid Build Coastguard Worker * 457*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to insert the pcidevicecon into. 458*2d543d20SAndroid Build Coastguard Worker * @param[in] node The cil_sort structure that contains the sorted pcidevicecons. 459*2d543d20SAndroid Build Coastguard Worker * 460*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 461*2d543d20SAndroid Build Coastguard Worker */ 462*2d543d20SAndroid Build Coastguard Worker int cil_pcidevicecon_to_policydb(policydb_t *pdb, struct cil_sort *pcidevicecons); 463*2d543d20SAndroid Build Coastguard Worker 464*2d543d20SAndroid Build Coastguard Worker /** 465*2d543d20SAndroid Build Coastguard Worker * Create an mls level using a cil level. 466*2d543d20SAndroid Build Coastguard Worker * The function is given a structure containing the a cil_level and 467*2d543d20SAndroid Build Coastguard Worker * outputs a created mls_level_t. 468*2d543d20SAndroid Build Coastguard Worker * 469*2d543d20SAndroid Build Coastguard Worker * @param[in] pdb The policy database to use to get sepol level from cil_level's sensitivity. 470*2d543d20SAndroid Build Coastguard Worker * @param[in] cil_level The cil_level that will be used to create an mls_level_t. 471*2d543d20SAndroid Build Coastguard Worker * @param[out] mls_level The mls_level that is created. 472*2d543d20SAndroid Build Coastguard Worker * 473*2d543d20SAndroid Build Coastguard Worker * @return SEPOL_OK upon success or an error otherwise. 474*2d543d20SAndroid Build Coastguard Worker */ 475*2d543d20SAndroid Build Coastguard Worker int cil_level_to_mls_level(policydb_t *pdb, struct cil_level *cil_level, mls_level_t *mls_level); 476*2d543d20SAndroid Build Coastguard Worker 477*2d543d20SAndroid Build Coastguard Worker #endif //_CIL_BINARY_H_ 478