• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _SEMANAGE_USER_INTERNAL_H_
2 #define _SEMANAGE_USER_INTERNAL_H_
3 
4 #include <sepol/user_record.h>
5 #include <semanage/user_record.h>
6 #include <semanage/users_local.h>
7 #include <semanage/users_policy.h>
8 #include "database.h"
9 #include "handle.h"
10 #include "dso.h"
11 
12 hidden_proto(semanage_user_add_role)
13     hidden_proto(semanage_user_clone)
14     hidden_proto(semanage_user_compare)
15     hidden_proto(semanage_user_compare2)
16     hidden_proto(semanage_user_create)
17     hidden_proto(semanage_user_free)
18     hidden_proto(semanage_user_get_mlslevel)
19     hidden_proto(semanage_user_get_mlsrange)
20     hidden_proto(semanage_user_get_name)
21     hidden_proto(semanage_user_get_roles)
22     hidden_proto(semanage_user_key_create)
23     hidden_proto(semanage_user_key_extract)
24     hidden_proto(semanage_user_key_free)
25     hidden_proto(semanage_user_set_mlslevel)
26     hidden_proto(semanage_user_set_mlsrange)
27     hidden_proto(semanage_user_set_name)
28     hidden_proto(semanage_user_exists)
29     hidden_proto(semanage_user_query)
30 
31 /* USER record: metod table */
32 extern record_table_t SEMANAGE_USER_RTABLE;
33 
34 /* USER BASE record: method table */
35 extern record_table_t SEMANAGE_USER_BASE_RTABLE;
36 
37 /* USER EXTRA record: method table */
38 extern record_table_t SEMANAGE_USER_EXTRA_RTABLE;
39 
40 /* ============ Init/Release functions ========== */
41 
42 /* USER BASE record, FILE backend */
43 extern int user_base_file_dbase_init(semanage_handle_t * handle,
44 				     const char *path_ro,
45 				     const char *path_rw,
46 				     dbase_config_t * dconfig);
47 
48 extern void user_base_file_dbase_release(dbase_config_t * dconfig);
49 
50 /* USER EXTRA record, FILE backend */
51 extern int user_extra_file_dbase_init(semanage_handle_t * handle,
52 				      const char *path_ro,
53 				      const char *path_rw,
54 				      dbase_config_t * dconfig);
55 
56 extern void user_extra_file_dbase_release(dbase_config_t * dconfig);
57 
58 /* USER BASE record, POLICYDB backend */
59 extern int user_base_policydb_dbase_init(semanage_handle_t * handle,
60 					 dbase_config_t * dconfig);
61 
62 extern void user_base_policydb_dbase_release(dbase_config_t * dconfig);
63 
64 /* USER record, JOIN backend */
65 extern int user_join_dbase_init(semanage_handle_t * handle,
66 				dbase_config_t * join1,
67 				dbase_config_t * join2,
68 				dbase_config_t * dconfig);
69 
70 extern void user_join_dbase_release(dbase_config_t * dconfig);
71 
72 /*======= Internal API: Base (Policy) User record ====== */
73 
74 #ifndef _SEMANAGE_USER_BASE_DEFINED_
75 struct semanage_user_base;
76 typedef struct semanage_user_base semanage_user_base_t;
77 #define _SEMANAGE_USER_BASE_DEFINED_
78 #endif
79 
80 hidden int semanage_user_base_create(semanage_handle_t * handle,
81 				     semanage_user_base_t ** user_ptr);
82 
83 hidden int semanage_user_base_clone(semanage_handle_t * handle,
84 				    const semanage_user_base_t * user,
85 				    semanage_user_base_t ** user_ptr);
86 
87 hidden int semanage_user_base_key_extract(semanage_handle_t * handle,
88 					  const semanage_user_base_t * user,
89 					  semanage_user_key_t ** key);
90 
91 hidden const char *semanage_user_base_get_name(const semanage_user_base_t *
92 					       user);
93 
94 hidden int semanage_user_base_set_name(semanage_handle_t * handle,
95 				       semanage_user_base_t * user,
96 				       const char *name);
97 
98 hidden const char *semanage_user_base_get_mlslevel(const semanage_user_base_t *
99 						   user);
100 
101 hidden int semanage_user_base_set_mlslevel(semanage_handle_t * handle,
102 					   semanage_user_base_t * user,
103 					   const char *mls_level);
104 
105 hidden const char *semanage_user_base_get_mlsrange(const semanage_user_base_t *
106 						   user);
107 
108 hidden int semanage_user_base_set_mlsrange(semanage_handle_t * handle,
109 					   semanage_user_base_t * user,
110 					   const char *mls_range);
111 
112 hidden int semanage_user_base_get_num_roles(const semanage_user_base_t * user);
113 
114 hidden int semanage_user_base_add_role(semanage_handle_t * handle,
115 				       semanage_user_base_t * user,
116 				       const char *role);
117 
118 hidden void semanage_user_base_del_role(semanage_user_base_t * user,
119 					const char *role);
120 
121 hidden int semanage_user_base_has_role(const semanage_user_base_t * user,
122 				       const char *role);
123 
124 hidden int semanage_user_base_get_roles(semanage_handle_t * handle,
125 					const semanage_user_base_t * user,
126 					const char ***roles_arr,
127 					unsigned int *num_roles);
128 
129 hidden int semanage_user_base_set_roles(semanage_handle_t * handle,
130 					semanage_user_base_t * user,
131 					const char **roles_arr,
132 					unsigned int num_roles);
133 
134 hidden void semanage_user_base_free(semanage_user_base_t * user);
135 
136 /*=========== Internal API: Extra User record ==========*/
137 struct semanage_user_extra;
138 typedef struct semanage_user_extra semanage_user_extra_t;
139 
140 hidden int semanage_user_extra_create(semanage_handle_t * handle,
141 				      semanage_user_extra_t ** user_extra_ptr);
142 
143 hidden int semanage_user_extra_clone(semanage_handle_t * handle,
144 				     const semanage_user_extra_t * user_extra,
145 				     semanage_user_extra_t ** user_extra_ptr);
146 
147 hidden const char *semanage_user_extra_get_name(const semanage_user_extra_t *
148 						user_extra);
149 
150 hidden int semanage_user_extra_set_name(semanage_handle_t * handle,
151 					semanage_user_extra_t * user_extra,
152 					const char *name);
153 
154 hidden const char *semanage_user_extra_get_prefix(const semanage_user_extra_t *
155 						  user_extra);
156 
157 hidden int semanage_user_extra_set_prefix(semanage_handle_t * handle,
158 					  semanage_user_extra_t * user_extra,
159 					  const char *prefix);
160 
161 hidden void semanage_user_extra_free(semanage_user_extra_t * user_extra);
162 
163 /*======== Internal API: Join record ========== */
164 hidden void semanage_user_key_unpack(const semanage_user_key_t * key,
165 				     const char **name);
166 
167 hidden int semanage_user_join(semanage_handle_t * handle,
168 			      const semanage_user_base_t * record1,
169 			      const semanage_user_extra_t * record2,
170 			      semanage_user_t ** result);
171 
172 hidden int semanage_user_split(semanage_handle_t * handle,
173 			       const semanage_user_t * record,
174 			       semanage_user_base_t ** split1,
175 			       semanage_user_extra_t ** split2);
176 
177 #endif
178