Home | History | Annotate | Download | only in src
      1 #include <stdlib.h>
      2 #include <assert.h>
      3 #include "handle.h"
      4 #include "debug.h"
      5 
      6 sepol_handle_t *sepol_handle_create(void)
      7 {
      8 
      9 	sepol_handle_t *sh = malloc(sizeof(sepol_handle_t));
     10 	if (sh == NULL)
     11 		return NULL;
     12 
     13 	/* Set callback */
     14 	sh->msg_callback = sepol_msg_default_handler;
     15 	sh->msg_callback_arg = NULL;
     16 
     17 	/* by default do not disable dontaudits */
     18 	sh->disable_dontaudit = 0;
     19 	sh->expand_consume_base = 0;
     20 
     21 	/* by default needless unused branch of tunables would be discarded  */
     22 	sh->preserve_tunables = 0;
     23 
     24 	return sh;
     25 }
     26 
     27 int sepol_get_preserve_tunables(sepol_handle_t *sh)
     28 {
     29 	assert(sh != NULL);
     30 	return sh->preserve_tunables;
     31 }
     32 
     33 void sepol_set_preserve_tunables(sepol_handle_t * sh, int preserve_tunables)
     34 {
     35 	assert(sh !=NULL);
     36 	sh->preserve_tunables = preserve_tunables;
     37 }
     38 
     39 int sepol_get_disable_dontaudit(sepol_handle_t *sh)
     40 {
     41 	assert(sh !=NULL);
     42 	return sh->disable_dontaudit;
     43 }
     44 
     45 void sepol_set_disable_dontaudit(sepol_handle_t * sh, int disable_dontaudit)
     46 {
     47 	assert(sh !=NULL);
     48 	sh->disable_dontaudit = disable_dontaudit;
     49 }
     50 
     51 void sepol_set_expand_consume_base(sepol_handle_t *sh, int consume_base)
     52 {
     53 	assert(sh != NULL);
     54 	sh->expand_consume_base = consume_base;
     55 }
     56 
     57 void sepol_handle_destroy(sepol_handle_t * sh)
     58 {
     59 	free(sh);
     60 }
     61