## <summary>Run .NET server and client applications on Linux.</summary>

#######################################
## <summary>
##	The role template for the mono module.
## </summary>
## <desc>
##	<p>
##	This template creates a derived domains which are used
##	for mono applications.
##	</p>
## </desc>
## <param name="role_prefix">
##	<summary>
##	The prefix of the user role (e.g., user
##	is the prefix for user_r).
##	</summary>
## </param>
## <param name="user_domain">
##	<summary>
##	User domain for the role.
##	</summary>
## </param>
## <param name="user_exec_domain">
##	<summary>
##	User exec domain for execute and transition access.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	Role allowed access
##	</summary>
## </param>
#
template(`mono_role_template',`
	gen_require(`
		attribute mono_domain;
		type mono_exec_t;
	')

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

	type $1_mono_t, mono_domain;
	domain_type($1_mono_t)
	domain_entry_file($1_mono_t, mono_exec_t)
	role $2 types $1_mono_t;

	domain_interactive_fd($1_mono_t)
	application_type($1_mono_t)

	########################################
	#
	# Policy
	#

	domtrans_pattern($3, mono_exec_t, $1_mono_t)

	allow $3 $1_mono_t:process { ptrace noatsecure signal_perms };
	ps_process_pattern($3, $1_mono_t)

	corecmd_bin_domtrans($1_mono_t, $2)

	userdom_manage_user_tmpfs_files($1_mono_t)

	optional_policy(`
		fs_dontaudit_rw_tmpfs_files($1_mono_t)

		xserver_role($1, $1_mono_t, $3, $4)
	')
')

########################################
## <summary>
##	Execute mono in the mono domain.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed to transition.
##	</summary>
## </param>
#
interface(`mono_domtrans',`
	gen_require(`
		type mono_t, mono_exec_t;
	')

	corecmd_search_bin($1)
	domtrans_pattern($1, mono_exec_t, mono_t)
')

########################################
## <summary>
##	Execute mono in the mono domain, and
##	allow the specified role the mono domain.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed to transition.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	Role allowed access.
##	</summary>
## </param>
#
interface(`mono_run',`
	gen_require(`
		attribute_role mono_roles;
	')

	mono_domtrans($1)
	roleattribute $2 mono_roles;
')

########################################
## <summary>
##	Execute mono in the caller domain.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`mono_exec',`
	gen_require(`
		type mono_exec_t;
	')

	corecmd_search_bin($1)
	can_exec($1, mono_exec_t)
')

########################################
## <summary>
##	Read and write mono shared memory.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`mono_rw_shm',`
	gen_require(`
		type mono_t;
	')

	allow $1 mono_t:shm rw_shm_perms;
')
