policy_module(keystone)

########################################
#
# Declarations
#

type keystone_t;
type keystone_exec_t;
init_daemon_domain(keystone_t, keystone_exec_t)

type keystone_initrc_exec_t;
init_script_file(keystone_initrc_exec_t)

type keystone_log_t;
logging_log_file(keystone_log_t)

type keystone_var_lib_t;
files_type(keystone_var_lib_t)

type keystone_tmp_t;
files_tmp_file(keystone_tmp_t)

########################################
#
# Local policy
#

allow keystone_t self:fifo_file rw_fifo_file_perms;
allow keystone_t self:unix_stream_socket { accept listen };
allow keystone_t self:tcp_socket { accept listen };

manage_dirs_pattern(keystone_t, keystone_log_t, keystone_log_t)
append_files_pattern(keystone_t, keystone_log_t, keystone_log_t)
create_files_pattern(keystone_t, keystone_log_t, keystone_log_t)
setattr_files_pattern(keystone_t, keystone_log_t, keystone_log_t)
logging_log_filetrans(keystone_t, keystone_log_t, dir)

manage_dirs_pattern(keystone_t, keystone_tmp_t, keystone_tmp_t)
manage_files_pattern(keystone_t, keystone_tmp_t, keystone_tmp_t)
manage_lnk_files_pattern(keystone_t, keystone_tmp_t, keystone_tmp_t)
files_tmp_filetrans(keystone_t, keystone_tmp_t, { dir file lnk_file })

manage_dirs_pattern(keystone_t, keystone_var_lib_t, keystone_var_lib_t)
manage_files_pattern(keystone_t, keystone_var_lib_t, keystone_var_lib_t)
files_var_lib_filetrans(keystone_t, keystone_var_lib_t, dir)

can_exec(keystone_t, keystone_tmp_t)

kernel_read_system_state(keystone_t)

corecmd_exec_bin(keystone_t)
corecmd_exec_shell(keystone_t)

corenet_all_recvfrom_netlabel(keystone_t)
corenet_tcp_sendrecv_generic_if(keystone_t)
corenet_tcp_sendrecv_generic_node(keystone_t)
corenet_tcp_bind_generic_node(keystone_t)

corenet_sendrecv_commplex_main_server_packets(keystone_t)
corenet_tcp_bind_commplex_main_port(keystone_t)

files_read_usr_files(keystone_t)

auth_use_pam(keystone_t)

libs_exec_ldconfig(keystone_t)

miscfiles_read_localization(keystone_t)

optional_policy(`
	mysql_stream_connect(keystone_t)
	mysql_tcp_connect(keystone_t)
')
