1 /* Copyright (C) 2005 Red Hat, Inc. */ 2 3 #ifndef _SEMANAGE_FCONTEXT_RECORD_H_ 4 #define _SEMANAGE_FCONTEXT_RECORD_H_ 5 6 #include <semanage/context_record.h> 7 #include <semanage/handle.h> 8 9 #ifndef _SEMANAGE_FCONTEXT_DEFINED_ 10 struct semanage_fcontext; 11 struct semanage_fcontext_key; 12 typedef struct semanage_fcontext semanage_fcontext_t; 13 typedef struct semanage_fcontext_key semanage_fcontext_key_t; 14 #define _SEMANAGE_FCONTEXT_DEFINED_ 15 #endif 16 17 /* Key */ 18 extern int semanage_fcontext_compare(const semanage_fcontext_t * fcontext, 19 const semanage_fcontext_key_t * key); 20 21 extern int semanage_fcontext_compare2(const semanage_fcontext_t * fcontext, 22 const semanage_fcontext_t * fcontext2); 23 24 extern int semanage_fcontext_key_create(semanage_handle_t * handle, 25 const char *expr, 26 int type, 27 semanage_fcontext_key_t ** key_ptr); 28 29 extern int semanage_fcontext_key_extract(semanage_handle_t * handle, 30 const semanage_fcontext_t * fcontext, 31 semanage_fcontext_key_t ** key_ptr); 32 33 extern void semanage_fcontext_key_free(semanage_fcontext_key_t * key); 34 35 /* Regexp */ 36 extern const char *semanage_fcontext_get_expr(const semanage_fcontext_t * 37 fcontext); 38 39 extern int semanage_fcontext_set_expr(semanage_handle_t * handle, 40 semanage_fcontext_t * fcontext, 41 const char *expr); 42 43 /* Type */ 44 #define SEMANAGE_FCONTEXT_ALL 0 45 #define SEMANAGE_FCONTEXT_REG 1 46 #define SEMANAGE_FCONTEXT_DIR 2 47 #define SEMANAGE_FCONTEXT_CHAR 3 48 #define SEMANAGE_FCONTEXT_BLOCK 4 49 #define SEMANAGE_FCONTEXT_SOCK 5 50 #define SEMANAGE_FCONTEXT_LINK 6 51 #define SEMANAGE_FCONTEXT_PIPE 7 52 53 extern int semanage_fcontext_get_type(const semanage_fcontext_t * fcontext); 54 55 extern const char *semanage_fcontext_get_type_str(int type); 56 57 extern void semanage_fcontext_set_type(semanage_fcontext_t * fcontext, 58 int type); 59 60 /* Context */ 61 extern semanage_context_t *semanage_fcontext_get_con(const semanage_fcontext_t * 62 fcontext); 63 64 extern int semanage_fcontext_set_con(semanage_handle_t * handle, 65 semanage_fcontext_t * fcontext, 66 semanage_context_t * con); 67 68 /* Create/Clone/Destroy */ 69 extern int semanage_fcontext_create(semanage_handle_t * handle, 70 semanage_fcontext_t ** fcontext_ptr); 71 72 extern int semanage_fcontext_clone(semanage_handle_t * handle, 73 const semanage_fcontext_t * fcontext, 74 semanage_fcontext_t ** fcontext_ptr); 75 76 extern void semanage_fcontext_free(semanage_fcontext_t * fcontext); 77 78 #endif 79