policy_module(rhsmcertd, 1.6.0)

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

type rhsmcertd_t;
type rhsmcertd_exec_t;
init_daemon_domain(rhsmcertd_t, rhsmcertd_exec_t)

type rhsmcertd_initrc_exec_t;
init_script_file(rhsmcertd_initrc_exec_t)

type rhsmcertd_log_t;
logging_log_file(rhsmcertd_log_t)

type rhsmcertd_lock_t;
files_lock_file(rhsmcertd_lock_t)

type rhsmcertd_runtime_t alias rhsmcertd_var_run_t;
files_runtime_file(rhsmcertd_runtime_t)

type rhsmcertd_var_lib_t;
files_type(rhsmcertd_var_lib_t)

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

allow rhsmcertd_t self:capability sys_nice;
allow rhsmcertd_t self:process { signal setsched };
allow rhsmcertd_t self:fifo_file rw_fifo_file_perms;
allow rhsmcertd_t self:unix_stream_socket create_stream_socket_perms;

manage_dirs_pattern(rhsmcertd_t, rhsmcertd_log_t, rhsmcertd_log_t)
append_files_pattern(rhsmcertd_t, rhsmcertd_log_t, rhsmcertd_log_t)
create_files_pattern(rhsmcertd_t, rhsmcertd_log_t, rhsmcertd_log_t)
setattr_files_pattern(rhsmcertd_t, rhsmcertd_log_t, rhsmcertd_log_t)

manage_files_pattern(rhsmcertd_t, rhsmcertd_lock_t, rhsmcertd_lock_t)
files_lock_filetrans(rhsmcertd_t, rhsmcertd_lock_t, file)

manage_dirs_pattern(rhsmcertd_t, rhsmcertd_var_lib_t, rhsmcertd_var_lib_t)
manage_files_pattern(rhsmcertd_t, rhsmcertd_var_lib_t, rhsmcertd_var_lib_t)

manage_dirs_pattern(rhsmcertd_t, rhsmcertd_runtime_t, rhsmcertd_runtime_t)
manage_files_pattern(rhsmcertd_t, rhsmcertd_runtime_t, rhsmcertd_runtime_t)
files_runtime_filetrans(rhsmcertd_t, rhsmcertd_runtime_t, { file dir })

kernel_read_network_state(rhsmcertd_t)
kernel_read_system_state(rhsmcertd_t)

corecmd_exec_bin(rhsmcertd_t)

dev_read_sysfs(rhsmcertd_t)
dev_read_rand(rhsmcertd_t)
dev_read_urand(rhsmcertd_t)

files_list_tmp(rhsmcertd_t)
files_read_etc_files(rhsmcertd_t)
files_read_usr_files(rhsmcertd_t)

init_read_state(rhsmcertd_t)

miscfiles_read_localization(rhsmcertd_t)
miscfiles_read_generic_certs(rhsmcertd_t)

sysnet_dns_name_resolve(rhsmcertd_t)

optional_policy(`
	rpm_read_db(rhsmcertd_t)
')
