1 /* Author: Joshua Brindle <jbrindle@tresys.com>
2  *         Jason Tang     <jtang@tresys.com>
3  *
4  * Copyright (C) 2005 Tresys Technology, LLC
5  * Copyright (C) 2005 Red Hat Inc.
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Lesser General Public
9  *  License as published by the Free Software Foundation; either
10  *  version 2.1 of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public
18  *  License along with this library; if not, write to the Free Software
19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef _SEMANAGE_POLICY_INTERNAL_H_
23 #define _SEMANAGE_POLICY_INTERNAL_H_
24 
25 #include "modules.h"
26 
27 /* Circular dependency */
28 struct semanage_handle;
29 
30 /* Backend dependent portion */
31 struct semanage_policy_table {
32 
33 	/* Returns the current policy serial/commit number
34 	 * A negative number is returned in case of failre */
35 	int (*get_serial) (struct semanage_handle *);
36 
37 	/* Destroy a connection */
38 	void (*destroy) (struct semanage_handle *);
39 
40 	/* Disconnect from policy */
41 	int (*disconnect) (struct semanage_handle *);
42 
43 	/* Begin a policy transaction */
44 	int (*begin_trans) (struct semanage_handle *);
45 
46 	/* Commit a policy transaction */
47 	int (*commit) (struct semanage_handle *);
48 
49 	/* Install a policy module */
50 	int (*install) (struct semanage_handle *, char *, size_t, const char *, const char *);
51 
52 	/* Install a policy module */
53 	int (*install_file) (struct semanage_handle *, const char *);
54 
55 	/* Remove a policy module */
56 	int (*remove) (struct semanage_handle *, char *);
57 
58 	/* List policy modules */
59 	int (*list) (struct semanage_handle *, semanage_module_info_t **,
60 		     int *);
61 
62 	/* Get module enabled status */
63 	int (*get_enabled) (struct semanage_handle *sh,
64 			    const semanage_module_key_t *key,
65 			    int *enabled);
66 
67 	/* Set module enabled status */
68 	int (*set_enabled) (struct semanage_handle *sh,
69 			    const semanage_module_key_t *key,
70 			    int enabled);
71 
72 	/* Get a module info */
73 	int (*get_module_info) (struct semanage_handle *,
74 				const semanage_module_key_t *,
75 				semanage_module_info_t **);
76 
77 	/* List all policy modules */
78 	int (*list_all) (struct semanage_handle *,
79 			 semanage_module_info_t **,
80 			 int *);
81 
82 	/* Install via module info */
83 	int (*install_info) (struct semanage_handle *,
84 			     const semanage_module_info_t *,
85 			     char *,
86 			     size_t);
87 
88 	/* Remove via module key */
89 	int (*remove_key) (struct semanage_handle *,
90 			   const semanage_module_key_t *);
91 };
92 
93 /* Should be backend independent */
94 extern int semanage_base_merge_components(struct semanage_handle *handle);
95 
96 extern int semanage_commit_components(struct semanage_handle *handle);
97 
98 #endif
99