Chris PeBenito 6cd6d7
## <summary>giFT peer to peer file sharing tool</summary>
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
#######################################
Chris PeBenito 6cd6d7
## <summary>
Chris PeBenito bbcd3c
##	The per role template for the gift module.
Chris PeBenito 6cd6d7
## </summary>
Chris PeBenito 6cd6d7
## <desc>
Chris PeBenito 6cd6d7
##	

Chris PeBenito 6cd6d7
##	This template creates a derived domains which are used
Chris PeBenito 6cd6d7
##	for gift client sessions and gift daemons.
Chris PeBenito 6cd6d7
##	

Chris PeBenito 6cd6d7
##	

Chris PeBenito 6cd6d7
##	This template is invoked automatically for each user, and
Chris PeBenito 6cd6d7
##	generally does not need to be invoked directly
Chris PeBenito 6cd6d7
##	by policy writers.
Chris PeBenito 6cd6d7
##	

Chris PeBenito 6cd6d7
## </desc>
Chris PeBenito 6cd6d7
## <param name="userdomain_prefix">
Chris PeBenito 6cd6d7
##	<summary>
Chris PeBenito 6cd6d7
##	The prefix of the user domain (e.g., user
Chris PeBenito 6cd6d7
##	is the prefix for user_t).
Chris PeBenito 6cd6d7
##	</summary>
Chris PeBenito 6cd6d7
## </param>
Chris PeBenito 6cd6d7
## <param name="user_domain">
Chris PeBenito 6cd6d7
##	<summary>
Chris PeBenito 6cd6d7
##	The type of the user domain.
Chris PeBenito 6cd6d7
##	</summary>
Chris PeBenito 6cd6d7
## </param>
Chris PeBenito 6cd6d7
## <param name="user_role">
Chris PeBenito 6cd6d7
##	<summary>
Chris PeBenito 6cd6d7
##	The role associated with the user domain.
Chris PeBenito 6cd6d7
##	</summary>
Chris PeBenito 6cd6d7
## </param>
Chris PeBenito 6cd6d7
#
Chris PeBenito bbcd3c
template(`gift_per_role_template',`
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	##############################
Chris PeBenito 6cd6d7
	#
Chris PeBenito 6cd6d7
	# Declarations
Chris PeBenito 6cd6d7
	#
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	type $1_gift_t;
Chris PeBenito d46cfe
	application_domain($1_gift_t,gift_exec_t)
Chris PeBenito 6cd6d7
	role $3 types $1_gift_t;
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	type $1_gift_home_t alias $1_gift_rw_t;
Chris PeBenito 6cd6d7
	files_poly_member($1_gift_home_t)
Chris PeBenito 6cd6d7
	userdom_user_home_content($1,$1_gift_home_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	type $1_gift_tmpfs_t;
Chris PeBenito 6cd6d7
	files_tmpfs_file($1_gift_tmpfs_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	type $1_giftd_t;
Chris PeBenito d46cfe
	application_domain($1_giftd_t,giftd_exec_t)
Chris PeBenito 6cd6d7
	role $3 types $1_giftd_t;
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	##############################
Chris PeBenito 6cd6d7
	#
Chris PeBenito 6cd6d7
	# giFT user interface local policy
Chris PeBenito 6cd6d7
	#
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	allow $1_gift_t self:tcp_socket create_socket_perms;
Chris PeBenito 6cd6d7
Chris PeBenito c0868a
	manage_files_pattern($1_gift_t,$1_gift_tmpfs_t,$1_gift_tmpfs_t)
Chris PeBenito c0868a
	manage_lnk_files_pattern($1_gift_t,$1_gift_tmpfs_t,$1_gift_tmpfs_t)
Chris PeBenito c0868a
	manage_fifo_files_pattern($1_gift_t,$1_gift_tmpfs_t,$1_gift_tmpfs_t)
Chris PeBenito c0868a
	manage_sock_files_pattern($1_gift_t,$1_gift_tmpfs_t,$1_gift_tmpfs_t)
Chris PeBenito 6cd6d7
	fs_tmpfs_filetrans($1_gift_t,$1_gift_tmpfs_t,{ dir file lnk_file sock_file fifo_file })
Chris PeBenito 6cd6d7
Chris PeBenito c0868a
	manage_dirs_pattern($1_gift_t,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	manage_files_pattern($1_gift_t,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	manage_lnk_files_pattern($1_gift_t,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito 6cd6d7
	userdom_user_home_dir_filetrans($1,$1_gift_t,$1_gift_home_t,dir)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# Launch gift daemon
Chris PeBenito c0868a
	domtrans_pattern($1_gift_t, giftd_exec_t, $1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# transition from user domain
Chris PeBenito c0868a
	domtrans_pattern($2, gift_exec_t, $1_gift_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# user managed content
Chris PeBenito c0868a
	manage_dirs_pattern($2,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	manage_files_pattern($2,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	manage_lnk_files_pattern($2,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	relabel_dirs_pattern($2,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	relabel_files_pattern($2,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	relabel_lnk_files_pattern($2,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# Allow the user domain to signal/ps.
Chris PeBenito c0868a
	ps_process_pattern($2,$1_gift_t)
Chris PeBenito c0868a
	allow $2 $1_gift_t:process signal_perms;
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# Read /proc/meminfo
Chris PeBenito 6cd6d7
	kernel_read_system_state($1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# Connect to gift daemon
Chris PeBenito 190066
	corenet_all_recvfrom_unlabeled($1_gift_t)
Chris PeBenito 190066
	corenet_all_recvfrom_netlabel($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_generic_if($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_all_nodes($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_giftd_port($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_connect_giftd_port($1_gift_t)
Chris PeBenito c0d8c4
	corenet_sendrecv_giftd_client_packets($1_gift_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	fs_search_auto_mountpoints($1_gift_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	sysnet_read_config($1_gift_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# giftui looks in .icons, .themes.
Chris PeBenito 6cd6d7
	userdom_dontaudit_read_user_home_content_files($1,$1_gift_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 6cd6d7
		fs_manage_nfs_dirs($1_gift_t)
Chris PeBenito 6cd6d7
		fs_manage_nfs_files($1_gift_t)
Chris PeBenito 6cd6d7
		fs_manage_nfs_symlinks($1_gift_t)
Chris PeBenito 6cd6d7
	')
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 6cd6d7
		fs_manage_cifs_dirs($1_gift_t)
Chris PeBenito 6cd6d7
		fs_manage_cifs_files($1_gift_t)
Chris PeBenito 6cd6d7
		fs_manage_cifs_symlinks($1_gift_t)
Chris PeBenito 6cd6d7
	')
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
#	optional_policy(`
Chris PeBenito 6cd6d7
#		gnome_user_application($1,$1_gift,$1_gift_t)
Chris PeBenito 6cd6d7
#	')
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	optional_policy(`
Chris PeBenito 6cd6d7
		nscd_socket_use($1_gift_t)
Chris PeBenito 6cd6d7
	')
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	optional_policy(`
Chris PeBenito 2c12b4
		xserver_user_x_domain_template($1,$1_gift,$1_gift_t,$1_gift_tmpfs_t)
Chris PeBenito 6cd6d7
	')
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	##############################
Chris PeBenito 6cd6d7
	#
Chris PeBenito 6cd6d7
	# giFT server local policy
Chris PeBenito 6cd6d7
	#
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	allow $1_giftd_t self:process { signal setsched };
Chris PeBenito 6cd6d7
	allow $1_giftd_t self:unix_stream_socket create_socket_perms;
Chris PeBenito 6cd6d7
	allow $1_giftd_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito 6cd6d7
	allow $1_giftd_t self:udp_socket create_socket_perms;
Chris PeBenito 6cd6d7
Chris PeBenito c0868a
	manage_dirs_pattern($1_giftd_t,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	manage_files_pattern($1_giftd_t,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito c0868a
	manage_lnk_files_pattern($1_giftd_t,$1_gift_home_t,$1_gift_home_t)
Chris PeBenito 6cd6d7
	userdom_user_home_dir_filetrans($1,$1_giftd_t,$1_gift_home_t,dir)
Chris PeBenito 6cd6d7
Chris PeBenito c0868a
	domtrans_pattern($2, giftd_exec_t, $1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	kernel_read_system_state($1_giftd_t)
Chris PeBenito 6cd6d7
	kernel_read_kernel_sysctls($1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# Serve content on various p2p networks. Ports can be random.
Chris PeBenito 190066
	corenet_all_recvfrom_unlabeled($1_giftd_t)
Chris PeBenito 190066
	corenet_all_recvfrom_netlabel($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_generic_if($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_udp_sendrecv_generic_if($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_all_nodes($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_udp_sendrecv_all_nodes($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_all_ports($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_udp_sendrecv_all_ports($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_tcp_bind_all_nodes($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_udp_bind_all_nodes($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_tcp_bind_all_ports($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_udp_bind_all_ports($1_giftd_t)
Chris PeBenito 6cd6d7
	corenet_tcp_connect_all_ports($1_giftd_t)
Chris PeBenito c0d8c4
	corenet_sendrecv_all_client_packets($1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	files_read_usr_files($1_giftd_t)
Chris PeBenito 6cd6d7
	# Read /etc/mtab
Chris PeBenito 6cd6d7
	files_read_etc_runtime_files($1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	libs_use_ld_so($1_giftd_t)
Chris PeBenito 6cd6d7
	libs_use_shared_libs($1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	miscfiles_read_localization($1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	sysnet_read_config($1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	userdom_use_user_terminals($1,$1_giftd_t)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 6cd6d7
		fs_manage_nfs_dirs($1_giftd_t)
Chris PeBenito 6cd6d7
		fs_manage_nfs_files($1_giftd_t)
Chris PeBenito 6cd6d7
		fs_manage_nfs_symlinks($1_giftd_t)
Chris PeBenito 6cd6d7
	')
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 6cd6d7
		fs_manage_cifs_dirs($1_giftd_t)
Chris PeBenito 6cd6d7
		fs_manage_cifs_files($1_giftd_t)
Chris PeBenito 6cd6d7
		fs_manage_cifs_symlinks($1_giftd_t)
Chris PeBenito 6cd6d7
	')
Chris PeBenito 6cd6d7
')