Lines Matching refs:sh
65 semanage_handle_t *sh = NULL; in semanage_handle_create() local
69 if ((sh = calloc(1, sizeof(semanage_handle_t))) == NULL) in semanage_handle_create()
75 if ((sh->conf = semanage_conf_parse(conf_name)) == NULL) in semanage_handle_create()
79 sh->sepolh = sepol_handle_create(); in semanage_handle_create()
80 if (!sh->sepolh) in semanage_handle_create()
82 sepol_msg_set_callback(sh->sepolh, semanage_msg_relay_handler, sh); in semanage_handle_create()
85 sh->priority = 400; in semanage_handle_create()
89 sh->do_rebuild = 0; in semanage_handle_create()
91 sh->commit_err = 0; in semanage_handle_create()
94 sh->do_reload = (is_selinux_enabled() > 0); in semanage_handle_create()
97 sh->do_check_contexts = 1; in semanage_handle_create()
100 sh->create_store = 0; in semanage_handle_create()
103 sh->timeout = SEMANAGE_COMMIT_READ_WAIT; in semanage_handle_create()
106 sh->msg_callback = semanage_msg_default_handler; in semanage_handle_create()
107 sh->msg_callback_arg = NULL; in semanage_handle_create()
111 return sh; in semanage_handle_create()
115 semanage_handle_destroy(sh); in semanage_handle_create()
119 void semanage_set_rebuild(semanage_handle_t * sh, int do_rebuild) in semanage_set_rebuild() argument
122 assert(sh != NULL); in semanage_set_rebuild()
124 sh->do_rebuild = do_rebuild; in semanage_set_rebuild()
128 void semanage_set_reload(semanage_handle_t * sh, int do_reload) in semanage_set_reload() argument
131 assert(sh != NULL); in semanage_set_reload()
133 sh->do_reload = do_reload; in semanage_set_reload()
137 int semanage_get_hll_compiler_path(semanage_handle_t *sh, in semanage_get_hll_compiler_path() argument
141 assert(sh != NULL); in semanage_get_hll_compiler_path()
153 ERR(sh, "Could not create copy of lang_ext. Out of memory.\n"); in semanage_get_hll_compiler_path()
162 len = strlen(sh->conf->compiler_directory_path) + strlen("/") + strlen(lower_lang_ext) + 1; in semanage_get_hll_compiler_path()
166 ERR(sh, "Error allocating space for compiler path."); in semanage_get_hll_compiler_path()
171 num_printed = snprintf(compiler, len, "%s/%s", sh->conf->compiler_directory_path, lower_lang_ext); in semanage_get_hll_compiler_path()
173 ERR(sh, "Error creating compiler path."); in semanage_get_hll_compiler_path()
190 void semanage_set_create_store(semanage_handle_t * sh, int create_store) in semanage_set_create_store() argument
193 assert(sh != NULL); in semanage_set_create_store()
195 sh->create_store = create_store; in semanage_set_create_store()
199 int semanage_get_disable_dontaudit(semanage_handle_t * sh) in semanage_get_disable_dontaudit() argument
201 assert(sh != NULL); in semanage_get_disable_dontaudit()
203 return sepol_get_disable_dontaudit(sh->sepolh); in semanage_get_disable_dontaudit()
206 void semanage_set_disable_dontaudit(semanage_handle_t * sh, int disable_dontaudit) in semanage_set_disable_dontaudit() argument
208 assert(sh != NULL); in semanage_set_disable_dontaudit()
210 sepol_set_disable_dontaudit(sh->sepolh, disable_dontaudit); in semanage_set_disable_dontaudit()
214 int semanage_get_preserve_tunables(semanage_handle_t * sh) in semanage_get_preserve_tunables() argument
216 assert(sh != NULL); in semanage_get_preserve_tunables()
217 return sepol_get_preserve_tunables(sh->sepolh); in semanage_get_preserve_tunables()
220 void semanage_set_preserve_tunables(semanage_handle_t * sh, in semanage_set_preserve_tunables() argument
223 assert(sh != NULL); in semanage_set_preserve_tunables()
224 sepol_set_preserve_tunables(sh->sepolh, preserve_tunables); in semanage_set_preserve_tunables()
227 int semanage_get_ignore_module_cache(semanage_handle_t *sh) in semanage_get_ignore_module_cache() argument
229 assert(sh != NULL); in semanage_get_ignore_module_cache()
230 return sh->conf->ignore_module_cache; in semanage_get_ignore_module_cache()
233 void semanage_set_ignore_module_cache(semanage_handle_t *sh, in semanage_set_ignore_module_cache() argument
236 assert(sh != NULL); in semanage_set_ignore_module_cache()
237 sh->conf->ignore_module_cache = ignore_module_cache; in semanage_set_ignore_module_cache()
240 void semanage_set_check_contexts(semanage_handle_t * sh, int do_check_contexts) in semanage_set_check_contexts() argument
243 assert(sh != NULL); in semanage_set_check_contexts()
245 sh->do_check_contexts = do_check_contexts; in semanage_set_check_contexts()
249 uint16_t semanage_get_default_priority(semanage_handle_t *sh) in semanage_get_default_priority() argument
251 assert(sh != NULL); in semanage_get_default_priority()
252 return sh->priority; in semanage_get_default_priority()
255 int semanage_set_default_priority(semanage_handle_t *sh, uint16_t priority) in semanage_set_default_priority() argument
257 assert(sh != NULL); in semanage_set_default_priority()
261 ERR(sh, "Priority %d is invalid.", priority); in semanage_set_default_priority()
265 sh->priority = priority; in semanage_set_default_priority()
269 int semanage_is_connected(semanage_handle_t * sh) in semanage_is_connected() argument
271 assert(sh != NULL); in semanage_is_connected()
272 return sh->is_connected; in semanage_is_connected()
275 void semanage_select_store(semanage_handle_t * sh, char *storename, in semanage_select_store() argument
279 assert(sh != NULL); in semanage_select_store()
283 free(sh->conf->store_path); in semanage_select_store()
284 sh->conf->store_path = strdup(storename); in semanage_select_store()
285 assert(sh->conf->store_path); /* no way to return failure */ in semanage_select_store()
286 sh->conf->store_type = storetype; in semanage_select_store()
291 void semanage_set_store_root(semanage_handle_t *sh, const char *store_root) in semanage_set_store_root() argument
293 assert(sh != NULL); in semanage_set_store_root()
295 free(sh->conf->store_root_path); in semanage_set_store_root()
296 sh->conf->store_root_path = strdup(store_root); in semanage_set_store_root()
297 assert(sh->conf->store_root_path); /* no way to return failure */ in semanage_set_store_root()
302 int semanage_is_managed(semanage_handle_t * sh) in semanage_is_managed() argument
304 assert(sh != NULL); in semanage_is_managed()
305 if (sh->is_connected) { in semanage_is_managed()
306 ERR(sh, "Already connected."); in semanage_is_managed()
309 switch (sh->conf->store_type) { in semanage_is_managed()
311 return semanage_direct_is_managed(sh); in semanage_is_managed()
313 ERR(sh, in semanage_is_managed()
320 int semanage_mls_enabled(semanage_handle_t * sh) in semanage_mls_enabled() argument
322 assert(sh != NULL); in semanage_mls_enabled()
323 switch (sh->conf->store_type) { in semanage_mls_enabled()
325 return semanage_direct_mls_enabled(sh); in semanage_mls_enabled()
327 ERR(sh, in semanage_mls_enabled()
334 int semanage_connect(semanage_handle_t * sh) in semanage_connect() argument
336 assert(sh != NULL); in semanage_connect()
337 switch (sh->conf->store_type) { in semanage_connect()
339 if (semanage_direct_connect(sh) < 0) { in semanage_connect()
345 ERR(sh, in semanage_connect()
350 sh->is_connected = 1; in semanage_connect()
354 int semanage_access_check(semanage_handle_t * sh) in semanage_access_check() argument
356 assert(sh != NULL); in semanage_access_check()
357 switch (sh->conf->store_type) { in semanage_access_check()
359 return semanage_direct_access_check(sh); in semanage_access_check()
369 int semanage_disconnect(semanage_handle_t * sh) in hidden_def()
371 assert(sh != NULL && sh->funcs != NULL in hidden_def()
372 && sh->funcs->disconnect != NULL); in hidden_def()
373 if (!sh->is_connected) { in hidden_def()
376 if (sh->funcs->disconnect(sh) < 0) { in hidden_def()
379 sh->is_in_transaction = 0; in hidden_def()
380 sh->is_connected = 0; in hidden_def()
381 sh->modules_modified = 0; in hidden_def()
385 void semanage_handle_destroy(semanage_handle_t * sh) in semanage_handle_destroy() argument
387 if (sh == NULL) in semanage_handle_destroy()
390 if (sh->funcs != NULL && sh->funcs->destroy != NULL) in semanage_handle_destroy()
391 sh->funcs->destroy(sh); in semanage_handle_destroy()
392 semanage_conf_destroy(sh->conf); in semanage_handle_destroy()
393 sepol_handle_destroy(sh->sepolh); in semanage_handle_destroy()
394 free(sh); in semanage_handle_destroy()
400 int semanage_begin_transaction(semanage_handle_t * sh) in hidden_def()
402 assert(sh != NULL && sh->funcs != NULL in hidden_def()
403 && sh->funcs->begin_trans != NULL); in hidden_def()
404 if (!sh->is_connected) { in hidden_def()
405 ERR(sh, "Not connected."); in hidden_def()
408 if (sh->is_in_transaction) { in hidden_def()
412 if (sh->funcs->begin_trans(sh) < 0) { in hidden_def()
415 sh->is_in_transaction = 1; in hidden_def()
421 int semanage_commit(semanage_handle_t * sh) in hidden_def()
424 assert(sh != NULL && sh->funcs != NULL && sh->funcs->commit != NULL); in hidden_def()
425 if (!sh->is_in_transaction) { in hidden_def()
426 ERR(sh, in hidden_def()
430 retval = sh->funcs->commit(sh); in hidden_def()
431 sh->is_in_transaction = 0; in hidden_def()
432 sh->modules_modified = 0; in hidden_def()