policy_module(aisexec, 1.2.0)

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

type aisexec_t;
type aisexec_exec_t;
init_daemon_domain(aisexec_t, aisexec_exec_t)

type aisexec_initrc_exec_t;
init_script_file(aisexec_initrc_exec_t)

type aisexec_tmp_t;
files_tmp_file(aisexec_tmp_t)

type aisexec_tmpfs_t;
files_tmpfs_file(aisexec_tmpfs_t)

type aisexec_var_lib_t;
files_type(aisexec_var_lib_t)

type aisexec_var_log_t;
logging_log_file(aisexec_var_log_t)

type aisexec_var_run_t;
files_pid_file(aisexec_var_run_t)

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

allow aisexec_t self:capability { sys_nice sys_resource ipc_lock ipc_owner };
allow aisexec_t self:process { setrlimit setsched signal };
allow aisexec_t self:fifo_file rw_fifo_file_perms;
allow aisexec_t self:sem create_sem_perms;
allow aisexec_t self:unix_stream_socket { accept listen connectto };

manage_dirs_pattern(aisexec_t, aisexec_tmp_t, aisexec_tmp_t)
manage_files_pattern(aisexec_t, aisexec_tmp_t, aisexec_tmp_t)
files_tmp_filetrans(aisexec_t, aisexec_tmp_t, { dir file })

manage_dirs_pattern(aisexec_t, aisexec_tmpfs_t, aisexec_tmpfs_t)
manage_files_pattern(aisexec_t, aisexec_tmpfs_t, aisexec_tmpfs_t)
fs_tmpfs_filetrans(aisexec_t, aisexec_tmpfs_t, { dir file })

manage_files_pattern(aisexec_t, aisexec_var_lib_t, aisexec_var_lib_t)
manage_dirs_pattern(aisexec_t, aisexec_var_lib_t, aisexec_var_lib_t)
manage_sock_files_pattern(aisexec_t, aisexec_var_lib_t, aisexec_var_lib_t)
files_var_lib_filetrans(aisexec_t, aisexec_var_lib_t, dir)

append_files_pattern(aisexec_t, aisexec_var_log_t, aisexec_var_log_t)
create_files_pattern(aisexec_t, aisexec_var_log_t, aisexec_var_log_t)
setattr_files_pattern(aisexec_t, aisexec_var_log_t, aisexec_var_log_t)
logging_log_filetrans(aisexec_t, aisexec_var_log_t, file)

manage_files_pattern(aisexec_t, aisexec_var_run_t, aisexec_var_run_t)
manage_sock_files_pattern(aisexec_t, aisexec_var_run_t, aisexec_var_run_t)
files_pid_filetrans(aisexec_t, aisexec_var_run_t, { file sock_file })

kernel_read_system_state(aisexec_t)

corecmd_exec_bin(aisexec_t)
corecmd_exec_shell(aisexec_t)

corenet_all_recvfrom_unlabeled(aisexec_t)
corenet_all_recvfrom_netlabel(aisexec_t)
corenet_tcp_sendrecv_generic_if(aisexec_t)
corenet_udp_sendrecv_generic_if(aisexec_t)
corenet_tcp_sendrecv_generic_node(aisexec_t)
corenet_udp_sendrecv_generic_node(aisexec_t)
corenet_tcp_bind_generic_node(aisexec_t)
corenet_udp_bind_generic_node(aisexec_t)

corenet_sendrecv_netsupport_server_packets(aisexec_t)
corenet_udp_bind_netsupport_port(aisexec_t)
corenet_udp_sendrecv_netsupport_port(aisexec_t)

corenet_sendrecv_generic_server_packets(aisexec_t)
corenet_tcp_bind_reserved_port(aisexec_t)
corenet_tcp_sendrecv_reserved_port(aisexec_t)

corenet_sendrecv_cluster_server_packets(aisexec_t)
corenet_udp_bind_cluster_port(aisexec_t)
corenet_udp_sendrecv_cluster_port(aisexec_t)

dev_read_urand(aisexec_t)

files_manage_mounttab(aisexec_t)

auth_use_nsswitch(aisexec_t)

init_rw_script_tmp_files(aisexec_t)

logging_send_syslog_msg(aisexec_t)

userdom_rw_unpriv_user_semaphores(aisexec_t)
userdom_rw_unpriv_user_shared_mem(aisexec_t)

optional_policy(`
	ccs_stream_connect(aisexec_t)
')

optional_policy(`
	corosync_domtrans(aisexec_t)
')

optional_policy(`
	# to communication with RHCS
	rhcs_rw_dlm_controld_semaphores(aisexec_t)

	rhcs_rw_fenced_semaphores(aisexec_t)

	rhcs_rw_gfs_controld_semaphores(aisexec_t)
	rhcs_rw_gfs_controld_shm(aisexec_t)

	rhcs_rw_groupd_semaphores(aisexec_t)
	rhcs_rw_groupd_shm(aisexec_t)
')
