1f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#include <selinux/selinux.h> 2f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#include <pthread.h> 3f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#include "dso.h" 4f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 5f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(selinux_mkload_policy) 6f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(set_selinuxmnt) 7f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_disable) 8f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_policyvers) 9f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_load_policy) 10f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_get_boolean_active) 11f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_get_boolean_names) 12f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_set_boolean) 13f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_commit_booleans) 14f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_check_context) 15f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_check_context_raw) 16f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_canonicalize_context) 17f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_canonicalize_context_raw) 18f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_av) 19f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_av_raw) 20f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_av_flags) 21f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_av_flags_raw) 22f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_user) 23f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_user_raw) 24f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_create) 25f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_create_raw) 26f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_member_raw) 27f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_compute_relabel_raw) 28f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(is_selinux_enabled) 29f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(is_selinux_mls_enabled) 30f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(freecon) 31f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(freeconary) 32f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getprevcon) 33f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getprevcon_raw) 34f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getcon) 35f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getcon_raw) 36f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(setcon_raw) 37f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getpeercon_raw) 38f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getpidcon_raw) 39f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getexeccon_raw) 40f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getfilecon) 41f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getfilecon_raw) 42f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(lgetfilecon_raw) 43f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(fgetfilecon_raw) 44f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(setfilecon_raw) 45f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(lsetfilecon_raw) 46f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(fsetfilecon_raw) 47f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(setexeccon) 48f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(setexeccon_raw) 49f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getfscreatecon_raw) 50f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getkeycreatecon_raw) 51f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(getsockcreatecon_raw) 52f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(setfscreatecon_raw) 53f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(setkeycreatecon_raw) 54f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(setsockcreatecon_raw) 55f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_getenforce) 56f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_setenforce) 57f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(security_deny_unknown) 58f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_binary_policy_path) 59f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_default_context_path) 60f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_securetty_types_path) 61f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_failsafe_context_path) 62f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_removable_context_path) 63f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_virtual_domain_context_path) 64f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_virtual_image_context_path) 65f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_file_context_path) 66f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_file_context_homedir_path) 67f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_file_context_local_path) 68f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_file_context_subs_path) 69f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_netfilter_context_path) 70f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_homedir_context_path) 71f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_user_contexts_path) 72f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_booleans_path) 73f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_customizable_types_path) 74f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_media_context_path) 75f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_x_context_path) 76f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_sepgsql_context_path) 77f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_path) 78f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_check_passwd_access) 79f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_check_securetty_context) 80f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(matchpathcon_init_prefix) 81f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_users_path) 82f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_usersconf_path); 83f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(selinux_translations_path); 84f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(selinux_colors_path); 85f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(selinux_getenforcemode); 86f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(selinux_getpolicytype); 87f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(selinux_raw_to_trans_context); 88f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(selinux_trans_to_raw_context); 89f074036424618c130dacb3464465a8b40bffef5Stephen Smalley hidden_proto(selinux_raw_context_to_color); 90f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(security_get_initial_context); 91f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(security_get_initial_context_raw); 92f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyhidden_proto(selinux_reset_config); 93f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 94f074036424618c130dacb3464465a8b40bffef5Stephen Smalleyextern int selinux_page_size hidden; 95f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 96f074036424618c130dacb3464465a8b40bffef5Stephen Smalley/* Make pthread_once optional */ 97f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#pragma weak pthread_once 98f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#pragma weak pthread_key_create 99f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#pragma weak pthread_key_delete 100f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#pragma weak pthread_setspecific 101f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 102f074036424618c130dacb3464465a8b40bffef5Stephen Smalley/* Call handler iff the first call. */ 103f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#define __selinux_once(ONCE_CONTROL, INIT_FUNCTION) \ 104f074036424618c130dacb3464465a8b40bffef5Stephen Smalley do { \ 105f074036424618c130dacb3464465a8b40bffef5Stephen Smalley if (pthread_once != NULL) \ 106f074036424618c130dacb3464465a8b40bffef5Stephen Smalley pthread_once (&(ONCE_CONTROL), (INIT_FUNCTION)); \ 107f074036424618c130dacb3464465a8b40bffef5Stephen Smalley else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) { \ 108f074036424618c130dacb3464465a8b40bffef5Stephen Smalley INIT_FUNCTION (); \ 109f074036424618c130dacb3464465a8b40bffef5Stephen Smalley (ONCE_CONTROL) = 2; \ 110f074036424618c130dacb3464465a8b40bffef5Stephen Smalley } \ 111f074036424618c130dacb3464465a8b40bffef5Stephen Smalley } while (0) 112f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 113f074036424618c130dacb3464465a8b40bffef5Stephen Smalley/* Pthread key macros */ 114f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#define __selinux_key_create(KEY, DESTRUCTOR) \ 115f074036424618c130dacb3464465a8b40bffef5Stephen Smalley do { \ 116f074036424618c130dacb3464465a8b40bffef5Stephen Smalley if (pthread_key_create != NULL) \ 117f074036424618c130dacb3464465a8b40bffef5Stephen Smalley pthread_key_create(KEY, DESTRUCTOR); \ 118f074036424618c130dacb3464465a8b40bffef5Stephen Smalley } while (0) 119f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 120f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#define __selinux_key_delete(KEY) \ 121f074036424618c130dacb3464465a8b40bffef5Stephen Smalley do { \ 122f074036424618c130dacb3464465a8b40bffef5Stephen Smalley if (pthread_key_delete != NULL) \ 123f074036424618c130dacb3464465a8b40bffef5Stephen Smalley pthread_key_delete(KEY); \ 124f074036424618c130dacb3464465a8b40bffef5Stephen Smalley } while (0) 125f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 126f074036424618c130dacb3464465a8b40bffef5Stephen Smalley#define __selinux_setspecific(KEY, VALUE) \ 127f074036424618c130dacb3464465a8b40bffef5Stephen Smalley do { \ 128f074036424618c130dacb3464465a8b40bffef5Stephen Smalley if (pthread_setspecific != NULL) \ 129f074036424618c130dacb3464465a8b40bffef5Stephen Smalley pthread_setspecific(KEY, VALUE); \ 130f074036424618c130dacb3464465a8b40bffef5Stephen Smalley } while (0) 131f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 132f074036424618c130dacb3464465a8b40bffef5Stephen Smalley 133