Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 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@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, struct selinux_opt *opts, |
| 21 | unsigned nopts) hidden; |
| 22 | int selabel_media_init(struct selabel_handle *rec, struct selinux_opt *opts, |
| 23 | unsigned nopts) hidden; |
| 24 | int selabel_x_init(struct selabel_handle *rec, struct selinux_opt *opts, |
| 25 | unsigned nopts) hidden; |
Eamon Walsh | 70aeeb9 | 2010-03-15 18:38:35 -0400 | [diff] [blame] | 26 | int selabel_db_init(struct selabel_handle *rec, |
| 27 | struct selinux_opt *opts, unsigned nopts) hidden; |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * Labeling internal structures |
| 31 | */ |
Eamon Walsh | a00fd94 | 2010-12-02 19:21:10 -0500 | [diff] [blame] | 32 | struct selabel_sub { |
| 33 | char *src; |
| 34 | int slen; |
| 35 | char *dst; |
| 36 | struct selabel_sub *next; |
| 37 | }; |
| 38 | |
Richard Haines | 441cf2e | 2011-04-18 16:41:40 +0100 | [diff] [blame^] | 39 | extern struct selabel_sub *selabel_subs_init(const char *path, |
| 40 | struct selabel_sub *list); |
| 41 | |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 42 | struct selabel_lookup_rec { |
| 43 | security_context_t ctx_raw; |
| 44 | security_context_t ctx_trans; |
| 45 | int validated; |
| 46 | }; |
| 47 | |
| 48 | struct selabel_handle { |
| 49 | /* arguments that were passed to selabel_open */ |
| 50 | unsigned int backend; |
| 51 | int validating; |
| 52 | |
| 53 | /* labeling operations */ |
| 54 | struct selabel_lookup_rec *(*func_lookup) (struct selabel_handle *h, |
| 55 | const char *key, int type); |
| 56 | void (*func_close) (struct selabel_handle *h); |
| 57 | void (*func_stats) (struct selabel_handle *h); |
| 58 | |
| 59 | /* supports backend-specific state information */ |
| 60 | void *data; |
Eamon Walsh | a00fd94 | 2010-12-02 19:21:10 -0500 | [diff] [blame] | 61 | |
| 62 | /* substitution support */ |
| 63 | struct selabel_sub *subs; |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | /* |
| 67 | * Validation function |
| 68 | */ |
| 69 | extern int |
| 70 | selabel_validate(struct selabel_handle *rec, |
| 71 | struct selabel_lookup_rec *contexts) hidden; |
| 72 | |
| 73 | /* |
| 74 | * Compatibility support |
| 75 | */ |
| 76 | extern int myprintf_compat; |
| 77 | extern void __attribute__ ((format(printf, 1, 2))) |
| 78 | (*myprintf) (const char *fmt,...); |
| 79 | |
| 80 | #define COMPAT_LOG(type, fmt...) if (myprintf_compat) \ |
| 81 | myprintf(fmt); \ |
| 82 | else \ |
| 83 | selinux_log(type, fmt); |
| 84 | |
| 85 | extern int |
| 86 | compat_validate(struct selabel_handle *rec, |
| 87 | struct selabel_lookup_rec *contexts, |
| 88 | const char *path, unsigned lineno) hidden; |
| 89 | |
| 90 | #endif /* _SELABEL_INTERNAL_H_ */ |