Select Git revision
check_seapp.c
check_seapp.c 28.17 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>
#include <pcre.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__); }
/**
* Initializes an empty, static list.
*/
#define list_init(free_fn) { .head = NULL, .tail = NULL, .freefn = free_fn }
/**
* given an item in the list, finds the offset for the container
* it was stored in.
*
* @element The element from the list
* @type The container type ie what you allocated that has the list_element structure in it.
* @name The name of the field that is the list_element
*
*/
#define list_entry(element, type, name) \
(type *)(((uint8_t *)element) - (uint8_t *)&(((type *)NULL)->name))
/**
* Iterates over the list, do not free elements from the list when using this.
* @list The list head to walk
* @var The variable name for the cursor
*/
#define list_for_each(list, var) \
for(var = (list)->head; var != NULL; var = var->next)
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;
typedef struct list_element list_element;
typedef struct list list;
typedef struct key_map_regex key_map_regex;
typedef struct file_info file_info;
enum map_match {
map_no_matches,
map_input_matched,
map_matched
};
const char *map_match_str[] = {
"do not match",