policy_module(kdumpgui, 1.2.0)

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

## <desc>
## <p>
## Allow s-c-kdump to run bootloader in bootloader_t.
## </p>
## </desc>
gen_tunable(kdumpgui_run_bootloader, false)

type kdumpgui_t;
type kdumpgui_exec_t;
init_daemon_domain(kdumpgui_t, kdumpgui_exec_t)

type kdumpgui_tmp_t;
files_tmp_file(kdumpgui_tmp_t)

######################################
#
# system-config-kdump local policy
#

allow kdumpgui_t self:capability { net_admin sys_admin sys_nice sys_rawio };
allow kdumpgui_t self:fifo_file rw_fifo_file_perms;
allow kdumpgui_t self:netlink_kobject_uevent_socket create_socket_perms;
allow kdumpgui_t self:process { setsched sigkill };

manage_dirs_pattern(kdumpgui_t, kdumpgui_tmp_t, kdumpgui_tmp_t)
manage_files_pattern(kdumpgui_t, kdumpgui_tmp_t, kdumpgui_tmp_t)
exec_files_pattern(kdumpgui_t, kdumpgui_tmp_t, kdumpgui_tmp_t)
files_tmp_filetrans(kdumpgui_t, kdumpgui_tmp_t, { dir file })
allow kdumpgui_t kdumpgui_tmp_t:file map;

kernel_read_system_state(kdumpgui_t)
kernel_read_network_state(kdumpgui_t)
kernel_getattr_core_if(kdumpgui_t)

corecmd_exec_bin(kdumpgui_t)
corecmd_exec_shell(kdumpgui_t)

dev_dontaudit_getattr_all_chr_files(kdumpgui_t)
dev_read_sysfs(kdumpgui_t)
dev_read_urand(kdumpgui_t)
dev_getattr_all_blk_files(kdumpgui_t)

files_manage_boot_files(kdumpgui_t)
files_manage_boot_symlinks(kdumpgui_t)
# Needed for running chkconfig
files_manage_etc_symlinks(kdumpgui_t)
# for blkid.tab
files_manage_etc_runtime_files(kdumpgui_t)
files_etc_filetrans_etc_runtime(kdumpgui_t, file)
files_dontaudit_write_all_files(kdumpgui_t)

fs_manage_dos_files(kdumpgui_t)
fs_getattr_all_fs(kdumpgui_t)
fs_list_hugetlbfs(kdumpgui_t)

storage_raw_write_fixed_disk(kdumpgui_t)
storage_raw_read_removable_device(kdumpgui_t)
storage_raw_read_fixed_disk(kdumpgui_t)
storage_getattr_removable_dev(kdumpgui_t)

auth_use_nsswitch(kdumpgui_t)

logging_send_syslog_msg(kdumpgui_t)
logging_list_logs(kdumpgui_t)
logging_read_generic_logs(kdumpgui_t)

mount_exec(kdumpgui_t)

init_dontaudit_read_all_script_files(kdumpgui_t)
init_access_check(kdumpgui_t)

userdom_dontaudit_search_admin_dir(kdumpgui_t)

optional_policy(`
    tunable_policy(`kdumpgui_run_bootloader',`
        bootloader_domtrans(kdumpgui_t)
        #if s-c-kdump is involved
        bootloader_manage_config(kdumpgui_t)
    ',`
        bootloader_exec(kdumpgui_t)
        bootloader_manage_config(kdumpgui_t)
    ')
')

optional_policy(`
	dbus_system_domain(kdumpgui_t, kdumpgui_exec_t)
')

optional_policy(`
	dev_rw_lvm_control(kdumpgui_t)
')

optional_policy(`
	kdump_manage_config(kdumpgui_t)
	kdump_initrc_domtrans(kdumpgui_t)
	kdump_systemctl(kdumpgui_t)
	kdumpctl_domtrans(kdumpgui_t)
')

optional_policy(`
	policykit_dbus_chat(kdumpgui_t)
')
