Chris PeBenito 17de1b
## <summary>Secure shell client and server policy.</summary>
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#######################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 17de1b
##	Basic SSH client template.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <desc>
Chris PeBenito 17de1b
##	

Chris PeBenito 17de1b
##	This template creates a derived domains which are used
Chris PeBenito 17de1b
##	for ssh client sessions.  A derived
Chris PeBenito 17de1b
##	type is also created to protect the user ssh keys.
Chris PeBenito 17de1b
##	

Chris PeBenito 17de1b
##	

Chris PeBenito 17de1b
##	This template was added for NX.
Chris PeBenito 17de1b
##	

Chris PeBenito 17de1b
## </desc>
Chris PeBenito 17de1b
## <param name="userdomain_prefix">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	The prefix of the domain (e.g., user
Chris PeBenito 17de1b
##	is the prefix for user_t).
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
## <param name="user_domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	The type of the domain.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
## <param name="user_role">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	The role associated with the user domain.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
template(`ssh_basic_client_template',`
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		attribute ssh_server;
Chris PeBenito 6b19be
		type ssh_exec_t, sshd_key_t, sshd_tmp_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	##############################
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
	# Declarations
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	type $1_ssh_t;
Chris PeBenito d46cfe
	application_domain($1_ssh_t,ssh_exec_t)
Chris PeBenito 17de1b
	role $3 types $1_ssh_t;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	type $1_home_ssh_t;
Chris PeBenito 17de1b
	files_type($1_home_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	##############################
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
	# Client local policy
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	allow $1_ssh_t self:capability { setuid setgid dac_override dac_read_search };
Chris PeBenito 17de1b
	allow $1_ssh_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
Chris PeBenito 17de1b
	allow $1_ssh_t self:fd use;
Chris PeBenito c0868a
	allow $1_ssh_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito 17de1b
	allow $1_ssh_t self:unix_dgram_socket { create_socket_perms sendto };
Chris PeBenito 17de1b
	allow $1_ssh_t self:unix_stream_socket { create_stream_socket_perms connectto };
Chris PeBenito 17de1b
	allow $1_ssh_t self:shm create_shm_perms;
Chris PeBenito 17de1b
	allow $1_ssh_t self:sem create_sem_perms;
Chris PeBenito 17de1b
	allow $1_ssh_t self:msgq create_msgq_perms;
Chris PeBenito 17de1b
	allow $1_ssh_t self:msg { send receive };
Chris PeBenito 17de1b
	allow $1_ssh_t self:tcp_socket create_socket_perms;
Chris PeBenito 465510
	allow $1_ssh_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# for rsync
Chris PeBenito 17de1b
	allow $1_ssh_t $2:unix_stream_socket rw_socket_perms;
Chris PeBenito 17de1b
	allow $1_ssh_t $2:unix_stream_socket connectto;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# Read the ssh key file.
Chris PeBenito c0868a
	allow $1_ssh_t sshd_key_t:file read_file_perms;
Chris PeBenito 17de1b
Chris PeBenito 6b19be
	# Access the ssh temporary files.
Chris PeBenito 6b19be
	allow $1_ssh_t sshd_tmp_t:dir manage_dir_perms;
Chris PeBenito 6b19be
	allow $1_ssh_t sshd_tmp_t:file manage_file_perms;
Chris PeBenito 6b19be
	files_tmp_filetrans($1_ssh_t, sshd_tmp_t, { file dir })
Chris PeBenito 6b19be
Chris PeBenito 17de1b
	# Transition from the domain to the derived domain.
Chris PeBenito c0868a
	domtrans_pattern($2, ssh_exec_t, $1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# inheriting stream sockets is needed for "ssh host command" as no pty
Chris PeBenito 17de1b
	# is allocated
Chris PeBenito 17de1b
	# cjp: should probably fix target to be an attribute for ssh servers
Chris PeBenito 17de1b
	# or "regular" (not special like sshd_extern_t) servers
Chris PeBenito 17de1b
	allow $2 ssh_server:unix_stream_socket rw_stream_socket_perms;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# allow ps to show ssh
Chris PeBenito c0868a
	ps_process_pattern($2,$1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# user can manage the keys and config
Chris PeBenito c0868a
	manage_files_pattern($2,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito c0868a
	manage_lnk_files_pattern($2,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito c0868a
	manage_sock_files_pattern($2,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# ssh client can manage the keys and config
Chris PeBenito c0868a
	manage_files_pattern($1_ssh_t,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito c0868a
	read_lnk_files_pattern($1_ssh_t,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# ssh servers can read the user keys and config
Chris PeBenito c0868a
	allow ssh_server $1_home_ssh_t:dir list_dir_perms;
Chris PeBenito c0868a
	read_files_pattern(ssh_server,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito c0868a
	read_lnk_files_pattern(ssh_server,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	kernel_read_kernel_sysctls($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 190066
	corenet_all_recvfrom_unlabeled($1_ssh_t)
Chris PeBenito 190066
	corenet_all_recvfrom_netlabel($1_ssh_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_if($1_ssh_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_nodes($1_ssh_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_ports($1_ssh_t)
Chris PeBenito 17de1b
	corenet_tcp_connect_ssh_port($1_ssh_t)
Chris PeBenito 17de1b
	corenet_sendrecv_ssh_client_packets($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	dev_read_urand($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	fs_getattr_all_fs($1_ssh_t)
Chris PeBenito 17de1b
	fs_search_auto_mountpoints($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# run helper programs - needed eg for x11-ssh-askpass
Chris PeBenito 17de1b
	corecmd_exec_shell($1_ssh_t)
Chris PeBenito 17de1b
	corecmd_exec_bin($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	domain_use_interactive_fds($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	files_list_home($1_ssh_t)
Chris PeBenito 17de1b
	files_read_usr_files($1_ssh_t)
Chris PeBenito 17de1b
	files_read_etc_runtime_files($1_ssh_t)
Chris PeBenito 17de1b
	files_read_etc_files($1_ssh_t)
Chris PeBenito 17de1b
	files_read_var_files($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	libs_use_ld_so($1_ssh_t)
Chris PeBenito 17de1b
	libs_use_shared_libs($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	logging_send_syslog_msg($1_ssh_t)
Chris PeBenito 17de1b
	logging_read_generic_logs($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	miscfiles_read_localization($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	seutil_read_config($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	sysnet_read_config($1_ssh_t)
Chris PeBenito 17de1b
	sysnet_dns_name_resolve($1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	tunable_policy(`read_default_t',`
Chris PeBenito 17de1b
		files_list_default($1_ssh_t)
Chris PeBenito 17de1b
		files_read_default_files($1_ssh_t)
Chris PeBenito 17de1b
		files_read_default_symlinks($1_ssh_t)
Chris PeBenito 17de1b
		files_read_default_sockets($1_ssh_t)
Chris PeBenito 17de1b
		files_read_default_pipes($1_ssh_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		kerberos_use($1_ssh_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		nis_use_ypbind($1_ssh_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		nscd_socket_use($1_ssh_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#######################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito bbcd3c
##	The per role template for the ssh module.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <desc>
Chris PeBenito 17de1b
##	

Chris PeBenito 17de1b
##	This template creates a derived domains which are used
Chris PeBenito 17de1b
##	for ssh client sessions and user ssh agents.  A derived
Chris PeBenito 17de1b
##	type is also created to protect the user ssh keys.
Chris PeBenito 17de1b
##	

Chris PeBenito 17de1b
##	

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

Chris PeBenito 17de1b
## </desc>
Chris PeBenito 17de1b
## <param name="userdomain_prefix">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	The prefix of the user domain (e.g., user
Chris PeBenito 17de1b
##	is the prefix for user_t).
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
## <param name="user_domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	The type of the user domain.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
## <param name="user_role">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	The role associated with the user domain.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito bbcd3c
template(`ssh_per_role_template',`
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		type ssh_agent_exec_t, ssh_keysign_exec_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	##############################
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
	# Declarations
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	ssh_basic_client_template($1,$2,$3)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	userdom_user_home_content($1,$1_home_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	type $1_ssh_agent_t;
Chris PeBenito d46cfe
	application_domain($1_ssh_agent_t,ssh_agent_exec_t)
Chris PeBenito 6b19be
	domain_interactive_fd($1_ssh_agent_t)
Chris PeBenito 17de1b
	role $3 types $1_ssh_agent_t;
Chris PeBenito 17de1b
Chris PeBenito 528811
	type $1_ssh_agent_tmp_t;
Chris PeBenito 528811
	files_tmp_file($1_ssh_agent_tmp_t)
Chris PeBenito 528811
Chris PeBenito 17de1b
	type $1_ssh_keysign_t;
Chris PeBenito d46cfe
	application_domain($1_ssh_keysign_t,ssh_keysign_exec_t)
Chris PeBenito 17de1b
	role $3 types $1_ssh_keysign_t;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	type $1_ssh_tmpfs_t;
Chris PeBenito 17de1b
	files_tmpfs_file($1_ssh_tmpfs_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	##############################
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
	# Client local policy
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
Chris PeBenito c0868a
	manage_files_pattern($1_ssh_t,$1_ssh_tmpfs_t,$1_ssh_tmpfs_t)
Chris PeBenito c0868a
	manage_lnk_files_pattern($1_ssh_t,$1_ssh_tmpfs_t,$1_ssh_tmpfs_t)
Chris PeBenito c0868a
	manage_fifo_files_pattern($1_ssh_t,$1_ssh_tmpfs_t,$1_ssh_tmpfs_t)
Chris PeBenito c0868a
	manage_sock_files_pattern($1_ssh_t,$1_ssh_tmpfs_t,$1_ssh_tmpfs_t)
Chris PeBenito 17de1b
	fs_tmpfs_filetrans($1_ssh_t,$1_ssh_tmpfs_t,{ dir file lnk_file sock_file fifo_file })
Chris PeBenito 17de1b
Chris PeBenito c0868a
	manage_dirs_pattern($1_ssh_t,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito c0868a
	manage_sock_files_pattern($1_ssh_t,$1_home_ssh_t,$1_home_ssh_t)
Chris PeBenito 17de1b
	userdom_user_home_dir_filetrans($1,$1_ssh_t,$1_home_ssh_t,{ dir sock_file })
Chris PeBenito 17de1b
Chris PeBenito 528811
	# Allow the ssh program to communicate with ssh-agent.
Chris PeBenito c0868a
	stream_connect_pattern($1_ssh_t,$1_ssh_agent_tmp_t,$1_ssh_agent_tmp_t,$1_ssh_agent_t)
Chris PeBenito 81aa67
Chris PeBenito 528811
	allow $1_ssh_t sshd_t:unix_stream_socket connectto;
Chris PeBenito 528811
Chris PeBenito 6b19be
	allow $2 $1_ssh_t:process signal;
Chris PeBenito 6b19be
Chris PeBenito 17de1b
	userdom_use_unpriv_users_fds($1_ssh_t)
Chris PeBenito 17de1b
	userdom_dontaudit_list_user_home_dirs($1,$1_ssh_t)
Chris PeBenito 17de1b
	userdom_search_user_home_dirs($1,$1_ssh_t)
Chris PeBenito 17de1b
	# Write to the user domain tty.
Chris PeBenito 17de1b
	userdom_use_user_terminals($1,$1_ssh_t)
Chris PeBenito 6b19be
	# needs to read krb tgt
Chris PeBenito 6b19be
	userdom_read_user_tmp_files($1, $1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 528811
	tunable_policy(`allow_ssh_keysign',`
Chris PeBenito 528811
		domain_auto_trans($1_ssh_t, ssh_keysign_exec_t, $1_ssh_keysign_t)
Chris PeBenito 528811
		allow $1_ssh_keysign_t $1_ssh_t:fd use;
Chris PeBenito 528811
		allow $1_ssh_keysign_t $1_ssh_t:process sigchld;
Chris PeBenito 528811
		allow $1_ssh_keysign_t $1_ssh_t:fifo_file rw_file_perms;
Chris PeBenito 528811
	')
Chris PeBenito 528811
Chris PeBenito 17de1b
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 17de1b
		fs_manage_nfs_dirs($1_ssh_t)
Chris PeBenito 17de1b
		fs_manage_nfs_files($1_ssh_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 17de1b
		fs_manage_cifs_dirs($1_ssh_t)
Chris PeBenito 17de1b
		fs_manage_cifs_files($1_ssh_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# for port forwarding
Chris PeBenito 17de1b
	tunable_policy(`user_tcp_server',`
Chris PeBenito 17de1b
		corenet_tcp_bind_ssh_port($1_ssh_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		xserver_user_client_template($1,$1_ssh_t,$1_ssh_tmpfs_t)
Chris PeBenito 17de1b
		xserver_domtrans_user_xauth($1,$1_ssh_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	ifdef(`TODO',`
Chris PeBenito 17de1b
	# for /bin/sh used to execute xauth
Chris PeBenito 17de1b
	dontaudit $1_ssh_t proc_t:{ lnk_file file } { getattr read };
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	#allow ssh to access keys stored on removable media
Chris PeBenito 17de1b
	# Should we have a boolean around this?
Chris PeBenito 17de1b
	files_search_mnt($1_ssh_t)
Chris PeBenito 17de1b
	r_dir_file($1_ssh_t, removable_t) 
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	') dnl endif TODO
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	##############################
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
	# $1_ssh_agent_t local policy
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	allow $1_ssh_agent_t self:process setrlimit;
Chris PeBenito 17de1b
	allow $1_ssh_agent_t self:capability setgid;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	allow $1_ssh_agent_t { $1_ssh_agent_t $2 }:process signull;
Chris PeBenito 17de1b
Chris PeBenito 81aa67
	allow $1_ssh_agent_t self:unix_stream_socket { create_stream_socket_perms connectto };
Chris PeBenito 17de1b
Chris PeBenito c0868a
	manage_dirs_pattern($1_ssh_agent_t,$1_ssh_agent_tmp_t,$1_ssh_agent_tmp_t)
Chris PeBenito c0868a
	manage_sock_files_pattern($1_ssh_agent_t,$1_ssh_agent_tmp_t,$1_ssh_agent_tmp_t)
Chris PeBenito 528811
	files_tmp_filetrans($1_ssh_agent_t,$1_ssh_agent_tmp_t,{ dir sock_file })
Chris PeBenito 528811
Chris PeBenito 17de1b
	# for ssh-add
Chris PeBenito c0868a
	stream_connect_pattern($2,$1_ssh_agent_tmp_t,$1_ssh_agent_tmp_t,$1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# Allow the user shell to signal the ssh program.
Chris PeBenito 17de1b
	allow $2 $1_ssh_agent_t:process signal;
Chris PeBenito 17de1b
Chris PeBenito 528811
	# allow ps to show ssh
Chris PeBenito c0868a
	ps_process_pattern($2,$1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito c0868a
	domtrans_pattern($2, ssh_agent_exec_t, $1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	kernel_read_kernel_sysctls($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	dev_read_urand($1_ssh_agent_t)
Chris PeBenito 17de1b
	dev_read_rand($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	fs_search_auto_mountpoints($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# transition back to normal privs upon exec
Chris PeBenito 17de1b
	corecmd_shell_domtrans($1_ssh_agent_t,$1_t)
Chris PeBenito 17de1b
	corecmd_bin_domtrans($1_ssh_agent_t, $1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	domain_use_interactive_fds($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	files_read_etc_files($1_ssh_agent_t)
Chris PeBenito 17de1b
	files_read_etc_runtime_files($1_ssh_agent_t)
Chris PeBenito 17de1b
	files_search_home($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	libs_read_lib_files($1_ssh_agent_t)
Chris PeBenito 17de1b
	libs_use_ld_so($1_ssh_agent_t)
Chris PeBenito 17de1b
	libs_use_shared_libs($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	logging_send_syslog_msg($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	miscfiles_read_localization($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	seutil_dontaudit_read_config($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# Write to the user domain tty.
Chris PeBenito 17de1b
	userdom_use_user_terminals($1,$1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 528811
	# for the transition back to normal privs upon exec
Chris PeBenito 528811
	userdom_user_home_domtrans($1,$1_ssh_agent_t,$2)
Chris PeBenito 528811
	allow $2 $1_ssh_agent_t:fd use;
Chris PeBenito 528811
	allow $2 $1_ssh_agent_t:fifo_file rw_file_perms;
Chris PeBenito 528811
	allow $2 $1_ssh_agent_t:process sigchld;
Chris PeBenito 528811
Chris PeBenito 17de1b
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 17de1b
		fs_manage_nfs_files($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
		# transition back to normal privs upon exec
Chris PeBenito 17de1b
		fs_nfs_domtrans($1_ssh_agent_t, $1_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 17de1b
		fs_manage_cifs_files($1_ssh_agent_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
		# transition back to normal privs upon exec
Chris PeBenito 17de1b
		fs_cifs_domtrans($1_ssh_agent_t, $1_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		nis_use_ypbind($1_ssh_agent_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito d28e52
	optional_policy(`
Chris PeBenito d28e52
		xserver_use_xdm_fds($1_ssh_agent_t)
Chris PeBenito d28e52
		xserver_rw_xdm_pipes($1_ssh_agent_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito d28e52
	ifdef(`TODO',`
Chris PeBenito 17de1b
	dontaudit $1_ssh_agent_t proc_t:{ lnk_file file } { getattr read };
Chris PeBenito 17de1b
	') dnl endif TODO
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	##############################
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
	# $1_ssh_keysign_t local policy
Chris PeBenito 17de1b
	#
Chris PeBenito 17de1b
Chris PeBenito 528811
	tunable_policy(`allow_ssh_keysign',`
Chris PeBenito 528811
		allow $1_ssh_keysign_t self:capability { setgid setuid };
Chris PeBenito 528811
		allow $1_ssh_keysign_t self:unix_stream_socket create_socket_perms;
Chris PeBenito 528811
Chris PeBenito 528811
		allow $1_ssh_keysign_t sshd_key_t:file { getattr read };
Chris PeBenito 528811
Chris PeBenito 528811
		dev_read_urand($1_ssh_keysign_t)
Chris PeBenito 528811
Chris PeBenito 528811
		files_read_etc_files($1_ssh_keysign_t)
Chris PeBenito 528811
Chris PeBenito 528811
		libs_use_ld_so($1_ssh_keysign_t)
Chris PeBenito 528811
		libs_use_shared_libs($1_ssh_keysign_t)
Chris PeBenito 528811
	')
Chris PeBenito 528811
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 528811
		tunable_policy(`allow_ssh_keysign',`
Chris PeBenito 528811
			nscd_socket_use($1_ssh_keysign_t)
Chris PeBenito 528811
		')
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#######################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 17de1b
##	The template to define a ssh server.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <desc>
Chris PeBenito 17de1b
##	

Chris PeBenito 17de1b
##	This template creates a domains to be used for
Chris PeBenito 17de1b
##	creating a ssh server.  This is typically done
Chris PeBenito 17de1b
##	to have multiple ssh servers of different sensitivities,
Chris PeBenito 17de1b
##	such as for an internal network-facing ssh server, and
Chris PeBenito 17de1b
##	a external network-facing ssh server.
Chris PeBenito 17de1b
##	

Chris PeBenito 17de1b
## </desc>
Chris PeBenito 17de1b
## <param name="userdomain_prefix">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	The prefix of the server domain (e.g., sshd
Chris PeBenito 17de1b
##	is the prefix for sshd_t).
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
template(`ssh_server_template', `
Chris PeBenito 17de1b
	type $1_t, ssh_server;
Chris PeBenito 4b3b46
	auth_login_pgm_domain($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	type $1_devpts_t;
Chris PeBenito 17de1b
	term_login_pty($1_devpts_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	type $1_var_run_t;
Chris PeBenito 17de1b
	files_pid_file($1_var_run_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	allow $1_t self:capability { kill sys_chroot sys_resource chown dac_override fowner fsetid setgid setuid sys_tty_config };
Chris PeBenito c0868a
	allow $1_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito 17de1b
	allow $1_t self:process { signal setsched setrlimit setexec };
Chris PeBenito bf469d
	allow $1_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito bf469d
	allow $1_t self:udp_socket create_socket_perms;
Chris PeBenito bf469d
	# ssh agent connections:
Chris PeBenito bf469d
	allow $1_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 17de1b
Chris PeBenito c0868a
	allow $1_t $1_devpts_t:chr_file { rw_chr_file_perms setattr getattr relabelfrom };
Chris PeBenito 17de1b
	term_create_pty($1_t,$1_devpts_t)
Chris PeBenito 17de1b
Chris PeBenito c0868a
	allow $1_t $1_var_run_t:file manage_file_perms;
Chris PeBenito 17de1b
	files_pid_filetrans($1_t,$1_var_run_t,file)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	can_exec($1_t, sshd_exec_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# Access key files
Chris PeBenito 17de1b
	allow $1_t sshd_key_t:file { getattr read };
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	kernel_read_kernel_sysctls($1_t)
Chris PeBenito 17de1b
Chris PeBenito 190066
	corenet_all_recvfrom_unlabeled($1_t)
Chris PeBenito 190066
	corenet_all_recvfrom_netlabel($1_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_if($1_t)
Chris PeBenito 17de1b
	corenet_udp_sendrecv_all_if($1_t)
Chris PeBenito 17de1b
	corenet_raw_sendrecv_all_if($1_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_nodes($1_t)
Chris PeBenito 17de1b
	corenet_udp_sendrecv_all_nodes($1_t)
Chris PeBenito 17de1b
	corenet_raw_sendrecv_all_nodes($1_t)
Chris PeBenito 17de1b
	corenet_udp_sendrecv_all_ports($1_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_ports($1_t)
Chris PeBenito 17de1b
	corenet_tcp_bind_all_nodes($1_t)
Chris PeBenito 17de1b
	corenet_udp_bind_all_nodes($1_t)
Chris PeBenito 56e1b3
	corenet_tcp_bind_ssh_port($1_t)
Chris PeBenito 17de1b
	corenet_tcp_connect_all_ports($1_t)
Chris PeBenito 17de1b
	corenet_sendrecv_ssh_server_packets($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	fs_dontaudit_getattr_all_fs($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	auth_rw_login_records($1_t)
Chris PeBenito d9845a
	auth_rw_faillog($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	corecmd_read_bin_symlinks($1_t)
Chris PeBenito 17de1b
	corecmd_getattr_bin_files($1_t)
Chris PeBenito 17de1b
	# for sshd subsystems, such as sftp-server.
Chris PeBenito 17de1b
	corecmd_getattr_bin_files($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	domain_interactive_fd($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	files_read_etc_files($1_t)
Chris PeBenito 17de1b
	files_read_etc_runtime_files($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	libs_use_ld_so($1_t)
Chris PeBenito 17de1b
	libs_use_shared_libs($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	logging_search_logs($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	miscfiles_read_localization($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	sysnet_read_config($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	userdom_dontaudit_relabelfrom_unpriv_users_ptys($1_t)
Chris PeBenito a9e03b
	userdom_search_all_users_home_dirs($1_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 17de1b
		fs_read_nfs_files($1_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 17de1b
		fs_read_cifs_files($1_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		kerberos_use($1_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 12cf80
		# Allow checking users mail at login
Chris PeBenito 12cf80
		mta_getattr_spool($1_t)
Chris PeBenito 12cf80
	')
Chris PeBenito 12cf80
Chris PeBenito 12cf80
	optional_policy(`
Chris PeBenito 17de1b
		nscd_socket_use($1_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		nx_spec_domtrans_server($1_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 17de1b
##	Send a SIGCHLD signal to the ssh server.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <param name="domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	Domain allowed access.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
interface(`ssh_sigchld',`
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		type sshd_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	allow $1 sshd_t:process sigchld;
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 17de1b
##	Read a ssh server unnamed pipe.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <param name="domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	Domain allowed access.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
interface(`ssh_read_pipes',`
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		type sshd_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	allow $1 sshd_t:fifo_file { getattr read };
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 17de1b
##	Read and write ssh server unix domain stream sockets.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <param name="domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	Domain allowed access.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
interface(`ssh_rw_stream_sockets',`
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		type sshd_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	allow $1 sshd_t:unix_stream_socket rw_stream_socket_perms;
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 17de1b
##	Read and write ssh server TCP sockets.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <param name="domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	Domain allowed access.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
interface(`ssh_rw_tcp_sockets',`
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		type sshd_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	allow $1 sshd_t:tcp_socket rw_stream_socket_perms;
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 17de1b
##	Do not audit attempts to read and write
Chris PeBenito 17de1b
##	ssh server TCP sockets.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <param name="domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	Domain to not audit.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
interface(`ssh_dontaudit_rw_tcp_sockets',`
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		type sshd_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	dontaudit $1 sshd_t:tcp_socket { read write };
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 33c7e6
##	Connect to SSH daemons over TCP sockets.  (Deprecated)
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <param name="domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	Domain allowed access.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
interface(`ssh_tcp_connect',`
Chris PeBenito 33c7e6
	refpolicywarn(`$0($*) has been deprecated.')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 6b19be
##	Execute the ssh daemon sshd domain.
Chris PeBenito 6b19be
## </summary>
Chris PeBenito 6b19be
## <param name="domain">
Chris PeBenito 6b19be
##	<summary>
Chris PeBenito 6b19be
##	Domain allowed access.
Chris PeBenito 6b19be
##	</summary>
Chris PeBenito 6b19be
## </param>
Chris PeBenito 6b19be
#
Chris PeBenito 6b19be
interface(`ssh_domtrans',`
Chris PeBenito 6b19be
	gen_require(`
Chris PeBenito 6b19be
		type sshd_t, sshd_exec_t;
Chris PeBenito 6b19be
	')
Chris PeBenito 6b19be
Chris PeBenito 6b19be
	domtrans_pattern($1,sshd_exec_t,sshd_t)
Chris PeBenito 6b19be
')
Chris PeBenito 6b19be
Chris PeBenito 6b19be
########################################
Chris PeBenito 6b19be
## <summary>
Chris PeBenito 17de1b
##	Execute the ssh client in the caller domain.
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <param name="domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	Domain allowed access.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
interface(`ssh_exec',`
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		type ssh_exec_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	corecmd_search_bin($1)
Chris PeBenito 17de1b
	can_exec($1,ssh_exec_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito eac818
##	Execute the ssh key generator in the ssh keygen domain.
Chris PeBenito eac818
## </summary>
Chris PeBenito eac818
## <param name="domain">
Chris PeBenito eac818
##	<summary>
Chris PeBenito eac818
##	Domain allowed access.
Chris PeBenito eac818
##	</summary>
Chris PeBenito eac818
## </param>
Chris PeBenito eac818
#
Chris PeBenito eac818
interface(`ssh_domtrans_keygen',`
Chris PeBenito eac818
	gen_require(`
Chris PeBenito eac818
		type ssh_keygen_t, ssh_keygen_exec_t;
Chris PeBenito eac818
	')
Chris PeBenito eac818
Chris PeBenito c0868a
	domtrans_pattern($1,ssh_keygen_exec_t,ssh_keygen_t)
Chris PeBenito eac818
')
Chris PeBenito eac818
Chris PeBenito eac818
########################################
Chris PeBenito eac818
## <summary>
Chris PeBenito 17de1b
##	Read ssh server keys
Chris PeBenito 17de1b
## </summary>
Chris PeBenito 17de1b
## <param name="domain">
Chris PeBenito 17de1b
##	<summary>
Chris PeBenito 17de1b
##	Domain allowed access.
Chris PeBenito 17de1b
##	</summary>
Chris PeBenito 17de1b
## </param>
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
interface(`ssh_dontaudit_read_server_keys',`
Chris PeBenito 17de1b
	gen_require(`
Chris PeBenito 17de1b
		type sshd_key_t;
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	dontaudit $1 sshd_key_t:file { getattr read };
Chris PeBenito 17de1b
')