policy_module(aisexec, 1.8.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_runtime_t alias aisexec_var_run_t;
files_runtime_file(aisexec_runtime_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)

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

allow aisexec_t self:capability { ipc_lock ipc_owner sys_nice sys_resource };
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_runtime_t, aisexec_runtime_t)
manage_sock_files_pattern(aisexec_t, aisexec_runtime_t, aisexec_runtime_t)
files_runtime_filetrans(aisexec_t, aisexec_runtime_t, { file sock_file })

kernel_read_system_state(aisexec_t)

corecmd_exec_bin(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_sendrecv_generic_server_packets(aisexec_t)
corenet_tcp_bind_reserved_port(aisexec_t)

corenet_sendrecv_cluster_server_packets(aisexec_t)
corenet_udp_bind_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)

miscfiles_read_localization(aisexec_t)

userdom_rw_unpriv_user_semaphores(aisexec_t)
userdom_rw_unpriv_user_shared_mem(aisexec_t)
