policy_module(consolesetup)

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

type consolesetup_t;
type consolesetup_exec_t;
init_daemon_domain(consolesetup_t, consolesetup_exec_t)

type consolesetup_conf_t;
files_config_file(consolesetup_conf_t)

type consolesetup_runtime_t;
files_runtime_file(consolesetup_runtime_t)

type consolesetup_tmp_t;
files_tmp_file(consolesetup_tmp_t)

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

allow consolesetup_t self:capability sys_tty_config;
allow consolesetup_t self:fifo_file rw_inherited_fifo_file_perms;

can_exec(consolesetup_t, consolesetup_conf_t)

manage_files_pattern(consolesetup_t, consolesetup_conf_t, consolesetup_conf_t)

manage_dirs_pattern(consolesetup_t, consolesetup_runtime_t, consolesetup_runtime_t)
manage_files_pattern(consolesetup_t, consolesetup_runtime_t, consolesetup_runtime_t)
files_runtime_filetrans(consolesetup_t, consolesetup_runtime_t, dir, "console-setup")

manage_files_pattern(consolesetup_t, consolesetup_tmp_t, consolesetup_tmp_t)
files_tmp_filetrans(consolesetup_t, consolesetup_tmp_t, file)

kernel_read_system_state(consolesetup_t)

corecmd_exec_bin(consolesetup_t)
corecmd_exec_shell(consolesetup_t)

files_read_etc_files(consolesetup_t)
files_read_usr_files(consolesetup_t)
files_search_tmp(consolesetup_t)

term_use_console(consolesetup_t)
term_use_unallocated_ttys(consolesetup_t)

miscfiles_read_localization(consolesetup_t)

xserver_read_xkb_libs(consolesetup_t)

loadkeys_domtrans(consolesetup_t)
