1 /* 2 * This file describes the internal interface used by the labeler 3 * for calling the user-supplied memory allocation, validation, 4 * and locking routine. 5 * 6 * Author : Eamon Walsh <ewalsh (at) epoch.ncsc.mil> 7 */ 8 #ifndef _SELABEL_INTERNAL_H_ 9 #define _SELABEL_INTERNAL_H_ 10 11 #include <stdlib.h> 12 #include <stdarg.h> 13 #include <selinux/selinux.h> 14 #include <selinux/label.h> 15 #include "dso.h" 16 17 /* 18 * Installed backends 19 */ 20 int selabel_file_init(struct selabel_handle *rec, const struct selinux_opt *opts, 21 unsigned nopts) hidden; 22 int selabel_media_init(struct selabel_handle *rec, const struct selinux_opt *opts, 23 unsigned nopts) hidden; 24 int selabel_x_init(struct selabel_handle *rec, const struct selinux_opt *opts, 25 unsigned nopts) hidden; 26 int selabel_db_init(struct selabel_handle *rec, 27 const struct selinux_opt *opts, unsigned nopts) hidden; 28 int selabel_property_init(struct selabel_handle *rec, 29 const struct selinux_opt *opts, unsigned nopts) hidden; 30 31 /* 32 * Labeling internal structures 33 */ 34 struct selabel_sub { 35 char *src; 36 int slen; 37 char *dst; 38 struct selabel_sub *next; 39 }; 40 41 struct selabel_lookup_rec { 42 security_context_t ctx_raw; 43 security_context_t ctx_trans; 44 int validated; 45 }; 46 47 struct selabel_handle { 48 /* arguments that were passed to selabel_open */ 49 unsigned int backend; 50 int validating; 51 52 /* labeling operations */ 53 struct selabel_lookup_rec *(*func_lookup) (struct selabel_handle *h, 54 const char *key, int type); 55 void (*func_close) (struct selabel_handle *h); 56 void (*func_stats) (struct selabel_handle *h); 57 58 /* supports backend-specific state information */ 59 void *data; 60 61 /* substitution support */ 62 struct selabel_sub *subs; 63 }; 64 65 /* 66 * Validation function 67 */ 68 extern int 69 selabel_validate(struct selabel_handle *rec, 70 struct selabel_lookup_rec *contexts) hidden; 71 72 #endif /* _SELABEL_INTERNAL_H_ */ 73