policy_module(xscreensaver, 1.4.1)

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

## <desc>
##	<p>
##	Grant the xscreensaver domains read access to generic user content
##	</p>
## </desc>
gen_tunable(`xscreensaver_read_generic_user_content', true)

attribute_role xscreensaver_roles;
attribute_role xscreensaver_helper_roles;

type xscreensaver_t;
type xscreensaver_exec_t;
userdom_user_application_domain(xscreensaver_t, xscreensaver_exec_t)
role xscreensaver_roles types xscreensaver_t;

type xscreensaver_helper_t;
type xscreensaver_helper_exec_t;
userdom_user_application_domain(xscreensaver_helper_t, xscreensaver_helper_exec_t)
role xscreensaver_helper_roles types xscreensaver_helper_t;

type xscreensaver_config_t;
userdom_user_home_content(xscreensaver_config_t)

type xscreensaver_tmpfs_t;
userdom_user_tmpfs_file(xscreensaver_tmpfs_t)

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

allow xscreensaver_t self:capability { setgid setuid };
allow xscreensaver_t self:process { setsched signal sigstop };
allow xscreensaver_t self:fifo_file rw_fifo_file_perms;

allow xscreensaver_t xscreensaver_helper_t:process { signal sigstop };

allow xscreensaver_t xscreensaver_config_t:file manage_file_perms;

kernel_read_system_state(xscreensaver_t)

files_read_usr_files(xscreensaver_t)

fs_dontaudit_getattr_xattr_fs(xscreensaver_t)

auth_use_nsswitch(xscreensaver_t)
auth_domtrans_chk_passwd(xscreensaver_t)

domtrans_pattern(xscreensaver_t, xscreensaver_helper_exec_t, xscreensaver_helper_t)

init_read_utmp(xscreensaver_t)

logging_send_audit_msgs(xscreensaver_t)
logging_send_syslog_msg(xscreensaver_t)

miscfiles_read_localization(xscreensaver_t)

userdom_use_user_terminals(xscreensaver_t)

xdg_read_pictures(xscreensaver_t)

xserver_rw_xsession_log(xscreensaver_t)
xserver_user_x_domain_template(xscreensaver, xscreensaver_t, xscreensaver_tmpfs_t)

tunable_policy(`xscreensaver_read_generic_user_content',`
	userdom_list_user_tmp(xscreensaver_t)
	userdom_list_user_home_content(xscreensaver_t)
	userdom_read_user_home_content_files(xscreensaver_t)
	userdom_read_user_home_content_symlinks(xscreensaver_t)
	userdom_read_user_tmp_files(xscreensaver_t)
',`
	files_dontaudit_list_home(xscreensaver_t)
	files_dontaudit_list_tmp(xscreensaver_t)

	userdom_dontaudit_list_user_home_dirs(xscreensaver_t)
	userdom_dontaudit_list_user_tmp(xscreensaver_t)
	userdom_dontaudit_read_user_home_content_files(xscreensaver_t)
	userdom_dontaudit_read_user_tmp_files(xscreensaver_t)
')

########################################
#
# Helper local policy
#

allow xscreensaver_helper_t self:process { execmem signal };
allow xscreensaver_helper_t self:fifo_file rw_fifo_file_perms;

allow xscreensaver_helper_t xscreensaver_config_t:file manage_file_perms;

dev_read_sysfs(xscreensaver_helper_t)

kernel_read_system_state(xscreensaver_helper_t)

files_dontaudit_search_home(xscreensaver_helper_t)

# /etc/drirc
files_read_etc_files(xscreensaver_helper_t)

files_read_usr_files(xscreensaver_helper_t)

fs_dontaudit_getattr_xattr_fs(xscreensaver_helper_t)

miscfiles_read_fonts(xscreensaver_helper_t)
miscfiles_read_localization(xscreensaver_helper_t)

xserver_rw_xsession_log(xscreensaver_helper_t)
xserver_stream_connect(xscreensaver_helper_t)
