1 #ifndef _SEPOL_BOOLEANS_H_ 2 #define _SEPOL_BOOLEANS_H_ 3 4 #include <stddef.h> 5 #include <sepol/policydb.h> 6 #include <sepol/boolean_record.h> 7 #include <sepol/handle.h> 8 9 /*--------------compatibility--------------*/ 10 11 /* Given an existing binary policy (starting at 'data', with length 'len') 12 and a boolean configuration file named by 'boolpath', rewrite the binary 13 policy for the boolean settings in the boolean configuration file. 14 The binary policy is rewritten in place in memory. 15 Returns 0 upon success, or -1 otherwise. */ 16 extern int sepol_genbools(void *data, size_t len, char *boolpath); 17 18 /* Given an existing binary policy (starting at 'data', with length 'len') 19 and boolean settings specified by the parallel arrays ('names', 'values') 20 with 'nel' elements, rewrite the binary policy for the boolean settings. 21 The binary policy is rewritten in place in memory. 22 Returns 0 upon success or -1 otherwise. */ 23 extern int sepol_genbools_array(void *data, size_t len, 24 char **names, int *values, int nel); 25 /*---------------end compatbility------------*/ 26 27 /* Set the specified boolean */ 28 extern int sepol_bool_set(sepol_handle_t * handle, 29 sepol_policydb_t * policydb, 30 const sepol_bool_key_t * key, 31 const sepol_bool_t * data); 32 33 /* Return the number of booleans */ 34 extern int sepol_bool_count(sepol_handle_t * handle, 35 const sepol_policydb_t * p, unsigned int *response); 36 37 /* Check if the specified boolean exists */ 38 extern int sepol_bool_exists(sepol_handle_t * handle, 39 const sepol_policydb_t * policydb, 40 const sepol_bool_key_t * key, int *response); 41 42 /* Query a boolean - returns the boolean, or NULL if not found */ 43 extern int sepol_bool_query(sepol_handle_t * handle, 44 const sepol_policydb_t * p, 45 const sepol_bool_key_t * key, 46 sepol_bool_t ** response); 47 48 /* Iterate the booleans 49 * The handler may return: 50 * -1 to signal an error condition, 51 * 1 to signal successful exit 52 * 0 to signal continue */ 53 54 extern int sepol_bool_iterate(sepol_handle_t * handle, 55 const sepol_policydb_t * policydb, 56 int (*fn) (const sepol_bool_t * boolean, 57 void *fn_arg), void *arg); 58 59 #endif 60