policy_module(webadm, 1.2.0)

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

## <desc>
##	<p>
##	Determine whether webadm can
##	manage generic user files.
##	</p>
## </desc>
gen_tunable(webadm_manage_user_files, false)

## <desc>
##	<p>
##	Determine whether webadm can
##	read generic user files.
##	</p>
## </desc>
gen_tunable(webadm_read_user_files, false)

role webadm_r;

userdom_base_user_template(webadm)

type webadm_tmp_t;
files_tmp_file(webadm_tmp_t)

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

allow webadm_t self:capability { dac_read_search kill sys_nice sys_resource };

manage_dirs_pattern(webadm_t, webadm_tmp_t, webadm_tmp_t)
manage_files_pattern(webadm_t, webadm_tmp_t, webadm_tmp_t)
manage_lnk_files_pattern(webadm_t, webadm_tmp_t, webadm_tmp_t)
files_tmp_filetrans(webadm_t, webadm_tmp_t, { file dir })
can_exec(webadm_t, webadm_tmp_t)

files_dontaudit_search_all_dirs(webadm_t)
files_list_var(webadm_t)

selinux_get_enforce_mode(webadm_t)
seutil_domtrans_setfiles(webadm_t)

init_rw_pipes(webadm_t)
init_status(webadm_t)

logging_send_audit_msgs(webadm_t)
logging_send_syslog_msg(webadm_t)

userdom_dontaudit_search_user_home_dirs(webadm_t)
userdom_dontaudit_manage_admin_files(webadm_t)

optional_policy(`
	apache_admin(webadm_t, webadm_r)
')

optional_policy(`
    dbus_system_bus_client(webadm_t)
')

optional_policy(`
    policykit_dbus_chat(webadm_t)
')

tunable_policy(`webadm_manage_user_files',`
	userdom_manage_user_home_content_files(webadm_t)
	userdom_read_user_tmp_files(webadm_t)
	userdom_write_user_tmp_files(webadm_t)
')

tunable_policy(`webadm_read_user_files',`
	userdom_read_user_home_content_files(webadm_t)
	userdom_read_user_tmp_files(webadm_t)
')
