policy_module(wdmd, 1.1.0)

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

type wdmd_t;
type wdmd_exec_t;
init_daemon_domain(wdmd_t, wdmd_exec_t)

type wdmd_initrc_exec_t;
init_script_file(wdmd_initrc_exec_t)

type wdmd_tmpfs_t;
files_tmpfs_file(wdmd_tmpfs_t)

type wdmd_var_run_t;
files_pid_file(wdmd_var_run_t)

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

allow wdmd_t self:capability { chown sys_nice ipc_lock };
allow wdmd_t self:process { setsched signal };
allow wdmd_t self:fifo_file rw_fifo_file_perms;
allow wdmd_t self:unix_stream_socket { accept listen };

manage_dirs_pattern(wdmd_t, wdmd_var_run_t, wdmd_var_run_t)
manage_files_pattern(wdmd_t, wdmd_var_run_t, wdmd_var_run_t)
manage_sock_files_pattern(wdmd_t, wdmd_var_run_t, wdmd_var_run_t)
files_pid_filetrans(wdmd_t, wdmd_var_run_t, { file dir sock_file })

manage_dirs_pattern(wdmd_t, wdmd_tmpfs_t, wdmd_tmpfs_t)
manage_files_pattern(wdmd_t, wdmd_tmpfs_t, wdmd_tmpfs_t)
fs_tmpfs_filetrans(wdmd_t, wdmd_tmpfs_t, { dir file })

kernel_read_system_state(wdmd_t)

corecmd_exec_bin(wdmd_t)
corecmd_exec_shell(wdmd_t)

dev_read_watchdog(wdmd_t)
dev_write_watchdog(wdmd_t)

fs_getattr_all_fs(wdmd_t)
fs_read_anon_inodefs_files(wdmd_t)

auth_use_nsswitch(wdmd_t)

logging_send_syslog_msg(wdmd_t)

optional_policy(`
	rhcs_initrc_domtrans_cluster(wdmd_t)
	rhcs_stream_connect_cluster(wdmd_t)
	rhcs_rw_cluster_tmpfs(wdmd_t)
')
