| 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; | 
| rpcraig | cfc492c | 2012-05-31 17:09:29 -0400 | [diff] [blame] | 28 | int selabel_property_init(struct selabel_handle *rec, | 
 | 29 | 			  struct selinux_opt *opts, unsigned nopts) hidden; | 
| Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 30 |  | 
 | 31 | /* | 
 | 32 |  * Labeling internal structures | 
 | 33 |  */ | 
| Eamon Walsh | a00fd94 | 2010-12-02 19:21:10 -0500 | [diff] [blame] | 34 | struct selabel_sub { | 
 | 35 | 	char *src; | 
 | 36 | 	int slen; | 
 | 37 | 	char *dst; | 
 | 38 | 	struct selabel_sub *next; | 
 | 39 | }; | 
 | 40 |  | 
| Richard Haines | 441cf2e | 2011-04-18 16:41:40 +0100 | [diff] [blame] | 41 | extern struct selabel_sub *selabel_subs_init(const char *path, | 
 | 42 | 					     struct selabel_sub *list); | 
 | 43 |  | 
| Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 44 | struct selabel_lookup_rec { | 
| Stephen Smalley | 9eb9c93 | 2014-02-19 09:16:17 -0500 | [diff] [blame] | 45 | 	char * ctx_raw; | 
 | 46 | 	char * ctx_trans; | 
| Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 47 | 	int validated; | 
 | 48 | }; | 
 | 49 |  | 
 | 50 | struct selabel_handle { | 
 | 51 | 	/* arguments that were passed to selabel_open */ | 
 | 52 | 	unsigned int backend; | 
 | 53 | 	int validating; | 
 | 54 |  | 
 | 55 | 	/* labeling operations */ | 
 | 56 | 	struct selabel_lookup_rec *(*func_lookup) (struct selabel_handle *h, | 
 | 57 | 						   const char *key, int type); | 
 | 58 | 	void (*func_close) (struct selabel_handle *h); | 
 | 59 | 	void (*func_stats) (struct selabel_handle *h); | 
 | 60 |  | 
 | 61 | 	/* supports backend-specific state information */ | 
 | 62 | 	void *data; | 
| Eamon Walsh | a00fd94 | 2010-12-02 19:21:10 -0500 | [diff] [blame] | 63 |  | 
| Richard Haines | 16a37c9 | 2011-12-19 16:51:29 +0000 | [diff] [blame] | 64 | 	/* | 
 | 65 | 	 * The main spec file used. Note for file contexts the local and/or | 
 | 66 | 	 * homedirs could also have been used to resolve a context. | 
 | 67 | 	 */ | 
 | 68 | 	char *spec_file; | 
 | 69 |  | 
| Eamon Walsh | a00fd94 | 2010-12-02 19:21:10 -0500 | [diff] [blame] | 70 | 	/* substitution support */ | 
| Dan Walsh | fd56c52 | 2013-10-09 15:22:54 -0400 | [diff] [blame] | 71 | 	struct selabel_sub *dist_subs; | 
| Eamon Walsh | a00fd94 | 2010-12-02 19:21:10 -0500 | [diff] [blame] | 72 | 	struct selabel_sub *subs; | 
| Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 73 | }; | 
 | 74 |  | 
 | 75 | /* | 
 | 76 |  * Validation function | 
 | 77 |  */ | 
 | 78 | extern int | 
 | 79 | selabel_validate(struct selabel_handle *rec, | 
 | 80 | 		 struct selabel_lookup_rec *contexts) hidden; | 
 | 81 |  | 
 | 82 | /* | 
 | 83 |  * Compatibility support | 
 | 84 |  */ | 
 | 85 | extern int myprintf_compat; | 
 | 86 | extern void __attribute__ ((format(printf, 1, 2))) | 
 | 87 | (*myprintf) (const char *fmt,...); | 
 | 88 |  | 
 | 89 | #define COMPAT_LOG(type, fmt...) if (myprintf_compat)	  \ | 
 | 90 | 		myprintf(fmt);				  \ | 
 | 91 | 	else						  \ | 
 | 92 | 		selinux_log(type, fmt); | 
 | 93 |  | 
 | 94 | extern int | 
 | 95 | compat_validate(struct selabel_handle *rec, | 
 | 96 | 		struct selabel_lookup_rec *contexts, | 
 | 97 | 		const char *path, unsigned lineno) hidden; | 
 | 98 |  | 
 | 99 | #endif				/* _SELABEL_INTERNAL_H_ */ |