policy_module(pacemaker, 1.1.0)

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

## <desc>
## <p>
## Allow pacemaker memcheck-amd64- to use executable memory
## </p>
## </desc>
gen_tunable(pacemaker_use_execmem, false)

type pacemaker_t;
type pacemaker_exec_t;
init_daemon_domain(pacemaker_t, pacemaker_exec_t)

type pacemaker_initrc_exec_t;
init_script_file(pacemaker_initrc_exec_t)

type pacemaker_var_lib_t;
files_type(pacemaker_var_lib_t)

type pacemaker_var_run_t;
files_pid_file(pacemaker_var_run_t)

type pacemaker_tmp_t;
files_tmp_file(pacemaker_tmp_t)

type pacemaker_tmpfs_t;
files_tmpfs_file(pacemaker_tmpfs_t)

type pacemaker_unit_file_t;
systemd_unit_file(pacemaker_unit_file_t)

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

allow pacemaker_t self:capability { fowner fsetid kill chown dac_read_search  setuid };
allow pacemaker_t self:capability2 block_suspend;
allow pacemaker_t self:process { setrlimit signal setpgid };
allow pacemaker_t self:fifo_file rw_fifo_file_perms;
allow pacemaker_t self:unix_stream_socket { connectto accept listen };

manage_dirs_pattern(pacemaker_t, pacemaker_tmp_t, pacemaker_tmp_t)
manage_files_pattern(pacemaker_t, pacemaker_tmp_t, pacemaker_tmp_t)
manage_fifo_files_pattern(pacemaker_t, pacemaker_tmp_t, pacemaker_tmp_t)
files_tmp_filetrans(pacemaker_t, pacemaker_tmp_t, { fifo_file file dir })

manage_dirs_pattern(pacemaker_t, pacemaker_tmpfs_t, pacemaker_tmpfs_t)
manage_files_pattern(pacemaker_t, pacemaker_tmpfs_t, pacemaker_tmpfs_t)
fs_tmpfs_filetrans(pacemaker_t, pacemaker_tmpfs_t, { dir file })

manage_dirs_pattern(pacemaker_t, pacemaker_var_lib_t, pacemaker_var_lib_t)
manage_files_pattern(pacemaker_t, pacemaker_var_lib_t, pacemaker_var_lib_t)
files_var_lib_filetrans(pacemaker_t, pacemaker_var_lib_t, { dir file })

manage_dirs_pattern(pacemaker_t, pacemaker_var_run_t, pacemaker_var_run_t)
manage_files_pattern(pacemaker_t, pacemaker_var_run_t, pacemaker_var_run_t)
files_pid_filetrans(pacemaker_t, pacemaker_var_run_t, { dir file })

kernel_getattr_core_if(pacemaker_t)
kernel_read_all_sysctls(pacemaker_t)
kernel_read_messages(pacemaker_t)
kernel_read_network_state(pacemaker_t)
kernel_read_software_raid_state(pacemaker_t)
kernel_read_system_state(pacemaker_t)

corecmd_exec_bin(pacemaker_t)
corecmd_exec_shell(pacemaker_t)

domain_use_interactive_fds(pacemaker_t)
domain_read_all_domains_state(pacemaker_t)

dev_getattr_mtrr_dev(pacemaker_t)
dev_read_rand(pacemaker_t)
dev_read_urand(pacemaker_t)

files_read_kernel_symbol_table(pacemaker_t)

fs_getattr_all_fs(pacemaker_t)

auth_use_nsswitch(pacemaker_t)

logging_send_syslog_msg(pacemaker_t)

sysnet_domtrans_ifconfig(pacemaker_t)

tunable_policy(`pacemaker_use_execmem',`
    allow pacemaker_t self:process { execmem };
')

optional_policy(`
	corosync_read_log(pacemaker_t)
	corosync_setattr_log(pacemaker_t)
	corosync_stream_connect(pacemaker_t)
	corosync_rw_tmpfs(pacemaker_t)
')

optional_policy(`
	#executes heartbeat lib files
	rgmanager_execute_lib(pacemaker_t)
')
