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