Chris PeBenito 6cd6d7
## <summary>giFT peer to peer file sharing tool</summary>
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
#######################################
Chris PeBenito 6cd6d7
## <summary>
Chris PeBenito 6cd6d7
##	The per user domain 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 6cd6d7
template(`gift_per_userdomain_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 6cd6d7
	domain_type($1_gift_t)
Chris PeBenito 6cd6d7
	domain_entry_file($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 6cd6d7
	domain_type($1_giftd_t)
Chris PeBenito 6cd6d7
	domain_entry_file($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 6cd6d7
	allow $1_gift_t $1_gift_tmpfs_t:dir rw_dir_perms;
Chris PeBenito 6cd6d7
	allow $1_gift_t $1_gift_tmpfs_t:file manage_file_perms;
Chris PeBenito 6cd6d7
	allow $1_gift_t $1_gift_tmpfs_t:lnk_file create_lnk_perms;
Chris PeBenito 6cd6d7
	allow $1_gift_t $1_gift_tmpfs_t:sock_file manage_file_perms;
Chris PeBenito 6cd6d7
	allow $1_gift_t $1_gift_tmpfs_t:fifo_file manage_file_perms;
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 6cd6d7
	allow $1_gift_t $1_gift_home_t:dir manage_dir_perms;
Chris PeBenito 6cd6d7
	allow $1_gift_t $1_gift_home_t:file manage_file_perms;
Chris PeBenito 6cd6d7
	allow $1_gift_t $1_gift_home_t:lnk_file create_lnk_perms;
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 6cd6d7
	domain_auto_trans($1_gift_t, giftd_exec_t, $1_giftd_t)
Chris PeBenito 6cd6d7
	allow $1_giftd_t $1_gift_t:fd use;
Chris PeBenito 6cd6d7
	allow $1_giftd_t $1_gift_t:fifo_file rw_file_perms;
Chris PeBenito 6cd6d7
	allow $1_giftd_t $1_gift_t:process sigchld;
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# transition from user domain
Chris PeBenito 6cd6d7
	domain_auto_trans($2, gift_exec_t, $1_gift_t)
Chris PeBenito 6cd6d7
	allow $1_gift_t $2:fd use;
Chris PeBenito 6cd6d7
	allow $1_gift_t $2:fifo_file rw_file_perms;
Chris PeBenito 6cd6d7
	allow $1_gift_t $2:process sigchld;
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# user managed content
Chris PeBenito 6cd6d7
	allow $2 $1_gift_home_t:dir manage_dir_perms;
Chris PeBenito 6cd6d7
	allow $2 $1_gift_home_t:file manage_file_perms;
Chris PeBenito 6cd6d7
	allow $2 $1_gift_home_t:lnk_file create_lnk_perms;
Chris PeBenito 6cd6d7
	allow $2 $1_gift_home_t:{ dir file lnk_file } { relabelfrom relabelto };
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	# Allow the user domain to signal/ps.
Chris PeBenito 6cd6d7
	allow $2 $1_gift_t:dir { search getattr read };
Chris PeBenito 6cd6d7
	allow $2 $1_gift_t:{ file lnk_file } { read getattr };
Chris PeBenito 6cd6d7
	allow $2 $1_gift_t:process { getattr 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 6cd6d7
	corenet_non_ipsec_sendrecv($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_generic_if($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_raw_sendrecv_generic_if($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_all_nodes($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_raw_sendrecv_all_nodes($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_sendrecv_giftd_port($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_bind_all_nodes($1_gift_t)
Chris PeBenito 6cd6d7
	corenet_tcp_connect_giftd_port($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 6cd6d7
		xserver_user_client_template($1,$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 6cd6d7
	allow $1_giftd_t $1_gift_home_t:dir manage_dir_perms;
Chris PeBenito 6cd6d7
	allow $1_giftd_t $1_gift_home_t:file manage_file_perms;
Chris PeBenito 6cd6d7
	allow $1_giftd_t $1_gift_home_t:lnk_file create_lnk_perms;
Chris PeBenito 6cd6d7
	userdom_user_home_dir_filetrans($1,$1_giftd_t,$1_gift_home_t,dir)
Chris PeBenito 6cd6d7
Chris PeBenito 6cd6d7
	domain_auto_trans($2, giftd_exec_t, $1_giftd_t)
Chris PeBenito 6cd6d7
	allow $1_giftd_t $2:fd use;
Chris PeBenito 6cd6d7
	allow $1_giftd_t $2:fifo_file rw_file_perms;
Chris PeBenito 6cd6d7
	allow $1_giftd_t $2:process sigchld;
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 6cd6d7
	corenet_non_ipsec_sendrecv($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_raw_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_raw_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 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
')