policy_module(gatekeeper, 1.8.0)

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

type gatekeeper_t;
type gatekeeper_exec_t;
init_daemon_domain(gatekeeper_t, gatekeeper_exec_t)

type gatekeeper_initrc_exec_t;
init_script_file(gatekeeper_initrc_exec_t)

type gatekeeper_etc_t;
files_config_file(gatekeeper_etc_t)

type gatekeeper_log_t;
logging_log_file(gatekeeper_log_t)

type gatekeeper_tmp_t;
files_tmp_file(gatekeeper_tmp_t)

type gatekeeper_var_run_t;
files_pid_file(gatekeeper_var_run_t)

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

dontaudit gatekeeper_t self:capability sys_tty_config;
allow gatekeeper_t self:process { setsched signal_perms };
allow gatekeeper_t self:fifo_file rw_fifo_file_perms;
allow gatekeeper_t self:tcp_socket create_stream_socket_perms;
allow gatekeeper_t self:udp_socket create_socket_perms;

allow gatekeeper_t gatekeeper_etc_t:lnk_file read_lnk_file_perms;
allow gatekeeper_t gatekeeper_etc_t:file read_file_perms;

manage_dirs_pattern(gatekeeper_t, gatekeeper_log_t, gatekeeper_log_t)
append_files_pattern(gatekeeper_t, gatekeeper_log_t, gatekeeper_log_t)
create_files_pattern(gatekeeper_t, gatekeeper_log_t, gatekeeper_log_t)
setattr_files_pattern(gatekeeper_t, gatekeeper_log_t, gatekeeper_log_t)
logging_log_filetrans(gatekeeper_t, gatekeeper_log_t, { file dir })

manage_dirs_pattern(gatekeeper_t, gatekeeper_tmp_t, gatekeeper_tmp_t)
manage_files_pattern(gatekeeper_t, gatekeeper_tmp_t, gatekeeper_tmp_t)
files_tmp_filetrans(gatekeeper_t, gatekeeper_tmp_t, { file dir })

manage_dirs_pattern(gatekeeper_t, gatekeeper_var_run_t, gatekeeper_var_run_t)
manage_files_pattern(gatekeeper_t, gatekeeper_var_run_t, gatekeeper_var_run_t)
files_pid_filetrans(gatekeeper_t, gatekeeper_var_run_t, { dir file })

kernel_read_system_state(gatekeeper_t)
kernel_read_kernel_sysctls(gatekeeper_t)

corecmd_list_bin(gatekeeper_t)

corenet_all_recvfrom_netlabel(gatekeeper_t)
corenet_tcp_sendrecv_generic_if(gatekeeper_t)
corenet_udp_sendrecv_generic_if(gatekeeper_t)
corenet_tcp_sendrecv_generic_node(gatekeeper_t)
corenet_udp_sendrecv_generic_node(gatekeeper_t)
corenet_tcp_sendrecv_all_ports(gatekeeper_t)
corenet_udp_sendrecv_all_ports(gatekeeper_t)
corenet_tcp_bind_generic_node(gatekeeper_t)
corenet_udp_bind_generic_node(gatekeeper_t)

corenet_sendrecv_gatekeeper_server_packets(gatekeeper_t)
corenet_tcp_bind_gatekeeper_port(gatekeeper_t)
corenet_udp_bind_gatekeeper_port(gatekeeper_t)

dev_read_sysfs(gatekeeper_t)
dev_read_urand(gatekeeper_t)

domain_use_interactive_fds(gatekeeper_t)

fs_getattr_all_fs(gatekeeper_t)
fs_search_auto_mountpoints(gatekeeper_t)

logging_send_syslog_msg(gatekeeper_t)

sysnet_read_config(gatekeeper_t)

userdom_dontaudit_use_unpriv_user_fds(gatekeeper_t)
userdom_dontaudit_search_user_home_dirs(gatekeeper_t)

optional_policy(`
	nis_use_ypbind(gatekeeper_t)
')

optional_policy(`
	seutil_sigchld_newrole(gatekeeper_t)
')

optional_policy(`
	udev_read_db(gatekeeper_t)
')
