Skip to content
Snippets Groups Projects
Select Git revision
  • 4caa6d4b89ddb2d21f9ac31242ba15c8771b51d1
  • test default
2 results

check_seapp.c

Blame
  • check_seapp.c 24.47 KiB
    #include <stdio.h>
    #include <stdarg.h>
    #include <ctype.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>
    #include <errno.h>
    #include <stdint.h>
    #include <search.h>
    #include <stdbool.h>
    #include <sepol/sepol.h>
    #include <sepol/policydb/policydb.h>
    
    #define TABLE_SIZE 1024
    #define KVP_NUM_OF_RULES (sizeof(rules) / sizeof(key_map))
    #define log_set_verbose() do { logging_verbose = 1; log_info("Enabling verbose\n"); } while(0)
    #define log_error(fmt, ...) log_msg(stderr, "Error: ", fmt, ##__VA_ARGS__)
    #define log_warn(fmt, ...) log_msg(stderr, "Warning: ", fmt, ##__VA_ARGS__)
    #define log_info(fmt, ...) if (logging_verbose ) { log_msg(stdout, "Info: ", fmt, ##__VA_ARGS__); }
    
    typedef struct line_order_list line_order_list;
    typedef struct hash_entry hash_entry;
    typedef enum key_dir key_dir;
    typedef enum data_type data_type;
    typedef enum rule_map_switch rule_map_switch;
    typedef enum map_match map_match;
    typedef struct key_map key_map;
    typedef struct kvp kvp;
    typedef struct rule_map rule_map;
    typedef struct policy_info policy_info;
    
    enum map_match {
    	map_no_matches,
    	map_input_matched,
    	map_matched
    };
    
    /**
     * Whether or not the "key" from a key vaue pair is considered an
     * input or an output.
     */
    enum key_dir {
    	dir_in, dir_out
    };
    
    /**
     * Used as options to rule_map_free()
     *
     * This is needed to get around the fact that GNU C's hash_map doesn't copy the key, so
     * we cannot free a key when overrding rule_map's in the table.
     */
    enum rule_map_switch {
    	rule_map_preserve_key, /** Used to preserve the key in the rule_map, ie don't free it*/
    	rule_map_destroy_key   /** Used when you need a full free of the rule_map structure*/
    };
    
    /**
     * The expected "type" of data the value in the key
     * value pair should be.
     */
    enum data_type {
    	dt_bool, dt_string
    };
    
    /**
     * This list is used to store a double pointer to each
     * hash table / line rule combination. This way a replacement
     * in the hash table automatically updates the list. The list
     * is also used to keep "first encountered" ordering amongst