policy_module(rasdaemon, 1.0.0)

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

type rasdaemon_t;
type rasdaemon_exec_t;
init_daemon_domain(rasdaemon_t, rasdaemon_exec_t)

type rasdaemon_var_lib_t;
files_type(rasdaemon_var_lib_t)

type rasdaemon_unit_file_t;
systemd_unit_file(rasdaemon_unit_file_t)

########################################
#
# rasdaemon local policy
#
allow rasdaemon_t self:fifo_file rw_fifo_file_perms;
allow rasdaemon_t self:unix_stream_socket create_stream_socket_perms;

manage_dirs_pattern(rasdaemon_t, rasdaemon_var_lib_t, rasdaemon_var_lib_t)
manage_files_pattern(rasdaemon_t, rasdaemon_var_lib_t, rasdaemon_var_lib_t)
files_var_lib_filetrans(rasdaemon_t, rasdaemon_var_lib_t, { dir file  })

kernel_read_system_state(rasdaemon_t)
kernel_manage_debugfs(rasdaemon_t)

dev_read_raw_memory(rasdaemon_t)
dev_read_sysfs(rasdaemon_t)
dev_read_urand(rasdaemon_t)
dev_rw_cpu_microcode(rasdaemon_t)

corecmd_exec_bin(rasdaemon_t)

fs_rw_tracefs_files(rasdaemon_t)
fs_manage_tracefs_dirs(rasdaemon_t)
fs_mount_tracefs(rasdaemon_t)
fs_unmount_tracefs(rasdaemon_t)

modutils_dontaudit_exec_kmod(rasdaemon_t) # more info here #1030277

auth_use_nsswitch(rasdaemon_t)

logging_send_syslog_msg(rasdaemon_t)

optional_policy(`
    dmidecode_exec(rasdaemon_t)
')

