16cd6a6acSopenharmony_ci/* 26cd6a6acSopenharmony_ci * Copyright 2011 Tresys Technology, LLC. All rights reserved. 36cd6a6acSopenharmony_ci * 46cd6a6acSopenharmony_ci * Redistribution and use in source and binary forms, with or without 56cd6a6acSopenharmony_ci * modification, are permitted provided that the following conditions are met: 66cd6a6acSopenharmony_ci * 76cd6a6acSopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, 86cd6a6acSopenharmony_ci * this list of conditions and the following disclaimer. 96cd6a6acSopenharmony_ci * 106cd6a6acSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, 116cd6a6acSopenharmony_ci * this list of conditions and the following disclaimer in the documentation 126cd6a6acSopenharmony_ci * and/or other materials provided with the distribution. 136cd6a6acSopenharmony_ci * 146cd6a6acSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY TRESYS TECHNOLOGY, LLC ``AS IS'' AND ANY EXPRESS 156cd6a6acSopenharmony_ci * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 166cd6a6acSopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 176cd6a6acSopenharmony_ci * EVENT SHALL TRESYS TECHNOLOGY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 186cd6a6acSopenharmony_ci * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 196cd6a6acSopenharmony_ci * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 206cd6a6acSopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 216cd6a6acSopenharmony_ci * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 226cd6a6acSopenharmony_ci * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 236cd6a6acSopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 246cd6a6acSopenharmony_ci * 256cd6a6acSopenharmony_ci * The views and conclusions contained in the software and documentation are those 266cd6a6acSopenharmony_ci * of the authors and should not be interpreted as representing official policies, 276cd6a6acSopenharmony_ci * either expressed or implied, of Tresys Technology, LLC. 286cd6a6acSopenharmony_ci */ 296cd6a6acSopenharmony_ci 306cd6a6acSopenharmony_ci#ifndef CIL_H_ 316cd6a6acSopenharmony_ci#define CIL_H_ 326cd6a6acSopenharmony_ci 336cd6a6acSopenharmony_ci#include <sepol/policydb/policydb.h> 346cd6a6acSopenharmony_ci 356cd6a6acSopenharmony_ci#ifdef __cplusplus 366cd6a6acSopenharmony_ciextern "C" { 376cd6a6acSopenharmony_ci#endif 386cd6a6acSopenharmony_ci 396cd6a6acSopenharmony_cistruct cil_db; 406cd6a6acSopenharmony_citypedef struct cil_db cil_db_t; 416cd6a6acSopenharmony_ci 426cd6a6acSopenharmony_ciextern void cil_db_init(cil_db_t **db); 436cd6a6acSopenharmony_ciextern void cil_db_destroy(cil_db_t **db); 446cd6a6acSopenharmony_ci 456cd6a6acSopenharmony_ciextern int cil_add_file(cil_db_t *db, const char *name, const char *data, size_t size); 466cd6a6acSopenharmony_ci 476cd6a6acSopenharmony_ciextern int cil_compile(cil_db_t *db); 486cd6a6acSopenharmony_ciextern int cil_build_policydb(cil_db_t *db, sepol_policydb_t **sepol_db); 496cd6a6acSopenharmony_ciextern int cil_userprefixes_to_string(cil_db_t *db, char **out, size_t *size); 506cd6a6acSopenharmony_ciextern int cil_selinuxusers_to_string(cil_db_t *db, char **out, size_t *size); 516cd6a6acSopenharmony_ciextern int cil_filecons_to_string(cil_db_t *db, char **out, size_t *size); 526cd6a6acSopenharmony_ciextern void cil_set_disable_dontaudit(cil_db_t *db, int disable_dontaudit); 536cd6a6acSopenharmony_ciextern void cil_set_multiple_decls(cil_db_t *db, int multiple_decls); 546cd6a6acSopenharmony_ciextern void cil_set_qualified_names(struct cil_db *db, int qualified_names); 556cd6a6acSopenharmony_ciextern void cil_set_disable_neverallow(cil_db_t *db, int disable_neverallow); 566cd6a6acSopenharmony_ciextern void cil_set_preserve_tunables(cil_db_t *db, int preserve_tunables); 576cd6a6acSopenharmony_ciextern int cil_set_handle_unknown(cil_db_t *db, int handle_unknown); 586cd6a6acSopenharmony_ciextern void cil_set_mls(cil_db_t *db, int mls); 596cd6a6acSopenharmony_ciextern void cil_set_attrs_expand_generated(struct cil_db *db, int attrs_expand_generated); 606cd6a6acSopenharmony_ciextern void cil_set_attrs_expand_size(struct cil_db *db, unsigned attrs_expand_size); 616cd6a6acSopenharmony_ciextern void cil_set_target_platform(cil_db_t *db, int target_platform); 626cd6a6acSopenharmony_ciextern void cil_set_policy_version(cil_db_t *db, int policy_version); 636cd6a6acSopenharmony_ciextern void cil_write_policy_conf(FILE *out, struct cil_db *db); 646cd6a6acSopenharmony_ciextern int cil_write_parse_ast(FILE *out, cil_db_t *db); 656cd6a6acSopenharmony_ciextern int cil_write_build_ast(FILE *out, cil_db_t *db); 666cd6a6acSopenharmony_ciextern int cil_write_resolve_ast(FILE *out, cil_db_t *db); 676cd6a6acSopenharmony_ci 686cd6a6acSopenharmony_cienum cil_log_level { 696cd6a6acSopenharmony_ci CIL_ERR = 1, 706cd6a6acSopenharmony_ci CIL_WARN, 716cd6a6acSopenharmony_ci CIL_INFO 726cd6a6acSopenharmony_ci}; 736cd6a6acSopenharmony_ciextern void cil_set_log_level(enum cil_log_level lvl); 746cd6a6acSopenharmony_ciextern void cil_set_log_handler(void (*handler)(int lvl, const char *msg)); 756cd6a6acSopenharmony_ci 766cd6a6acSopenharmony_ci#ifdef __GNUC__ 776cd6a6acSopenharmony_ci__attribute__ ((format(printf, 2, 3))) 786cd6a6acSopenharmony_ci#endif 796cd6a6acSopenharmony_ciextern void cil_log(enum cil_log_level lvl, const char *msg, ...); 806cd6a6acSopenharmony_ci 816cd6a6acSopenharmony_ciextern void cil_set_malloc_error_handler(void (*handler)(void)); 826cd6a6acSopenharmony_ci 836cd6a6acSopenharmony_ci#ifdef __cplusplus 846cd6a6acSopenharmony_ci} 856cd6a6acSopenharmony_ci#endif 866cd6a6acSopenharmony_ci#endif 87