policy_module(pkcs, 1.0.1)

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

type pkcs_slotd_t;
type pkcs_slotd_exec_t;
typealias pkcs_slotd_t alias pkcsslotd_t;
typealias pkcs_slotd_exec_t alias pkcsslotd_exec_t;
init_daemon_domain(pkcs_slotd_t, pkcs_slotd_exec_t)

type pkcs_slotd_initrc_exec_t;
init_script_file(pkcs_slotd_initrc_exec_t)

type pkcs_slotd_var_lib_t;
typealias pkcs_slotd_var_lib_t alias pkcsslotd_var_lib_t;
files_type(pkcs_slotd_var_lib_t)

type pkcs_slotd_lock_t;
typealias pkcs_slotd_lock_t alias pkcsslotd_lock_t;
files_lock_file(pkcs_slotd_lock_t)

type pkcs_slotd_log_t;
logging_log_file(pkcs_slotd_log_t)

type pkcs_slotd_var_run_t;
typealias pkcs_slotd_var_run_t alias pkcsslotd_var_run_t;
files_pid_file(pkcs_slotd_var_run_t)

type pkcs_slotd_tmp_t;
typealias pkcs_slotd_tmp_t alias pkcsslotd_tmp_t;
files_tmp_file(pkcs_slotd_tmp_t)

type pkcs_slotd_tmpfs_t;
typealias pkcs_slotd_tmpfs_t alias pkcsslotd_tmpfs_t;
files_tmpfs_file(pkcs_slotd_tmpfs_t)

type pkcs_slotd_unit_file_t;
systemd_unit_file(pkcs_slotd_unit_file_t)

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

allow pkcs_slotd_t self:capability { fsetid kill chown };
dontaudit pkcs_slotd_t self:capability sys_admin;
allow pkcs_slotd_t self:fifo_file rw_fifo_file_perms;
allow pkcs_slotd_t self:netlink_kobject_uevent_socket create_socket_perms;
allow pkcs_slotd_t self:sem create_sem_perms;
allow pkcs_slotd_t self:shm create_shm_perms;
allow pkcs_slotd_t self:unix_stream_socket { accept listen };

manage_dirs_pattern(pkcs_slotd_t, pkcs_slotd_var_lib_t, pkcs_slotd_var_lib_t)
manage_files_pattern(pkcs_slotd_t, pkcs_slotd_var_lib_t, pkcs_slotd_var_lib_t)
manage_lnk_files_pattern(pkcs_slotd_t, pkcs_slotd_var_lib_t, pkcs_slotd_var_lib_t)
files_var_lib_filetrans(pkcs_slotd_t, pkcs_slotd_var_lib_t, dir)

manage_files_pattern(pkcs_slotd_t, pkcs_slotd_lock_t, pkcs_slotd_lock_t)
manage_dirs_pattern(pkcs_slotd_t, pkcs_slotd_lock_t, pkcs_slotd_lock_t)
files_lock_filetrans(pkcs_slotd_t, pkcs_slotd_lock_t, dir)

manage_files_pattern(pkcs_slotd_t, pkcs_slotd_log_t, pkcs_slotd_log_t)
manage_dirs_pattern(pkcs_slotd_t, pkcs_slotd_log_t, pkcs_slotd_log_t)
logging_log_filetrans(pkcs_slotd_t, pkcs_slotd_log_t, dir)

manage_dirs_pattern(pkcs_slotd_t, pkcs_slotd_var_run_t, pkcs_slotd_var_run_t)
manage_files_pattern(pkcs_slotd_t, pkcs_slotd_var_run_t, pkcs_slotd_var_run_t)
manage_sock_files_pattern(pkcs_slotd_t, pkcs_slotd_var_run_t, pkcs_slotd_var_run_t)
files_pid_filetrans(pkcs_slotd_t, pkcs_slotd_var_run_t, { sock_file file dir })

manage_dirs_pattern(pkcs_slotd_t, pkcs_slotd_tmp_t, pkcs_slotd_tmp_t)
manage_files_pattern(pkcs_slotd_t, pkcs_slotd_tmp_t, pkcs_slotd_tmp_t)
files_tmp_filetrans(pkcs_slotd_t, pkcs_slotd_tmp_t, dir)

manage_dirs_pattern(pkcs_slotd_t, pkcs_slotd_tmpfs_t, pkcs_slotd_tmpfs_t)
manage_files_pattern(pkcs_slotd_t, pkcs_slotd_tmpfs_t, pkcs_slotd_tmpfs_t)
fs_tmpfs_filetrans(pkcs_slotd_t, pkcs_slotd_tmpfs_t, { file dir })

auth_use_nsswitch(pkcs_slotd_t)

files_search_locks(pkcs_slotd_t)

logging_send_syslog_msg(pkcs_slotd_t)

userdom_read_all_users_state(pkcs_slotd_t)
