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;
Dan Walsh 3eaa99
		type ssh_home_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 0bfccd
	application_domain($1_ssh_t, ssh_exec_t)
Chris PeBenito 17de1b
	role $3 types $1_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 cde150
	allow $1_ssh_t self:tcp_socket create_stream_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 0bfccd
	ps_process_pattern($2, $1_ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# user can manage the keys and config
Dan Walsh 3eaa99
	manage_files_pattern($2, ssh_home_t, ssh_home_t)
Dan Walsh 3eaa99
	manage_lnk_files_pattern($2, ssh_home_t, ssh_home_t)
Dan Walsh 3eaa99
	manage_sock_files_pattern($2, ssh_home_t, ssh_home_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# ssh client can manage the keys and config
Dan Walsh 3eaa99
	manage_files_pattern($1_ssh_t, ssh_home_t, ssh_home_t)
Dan Walsh 3eaa99
	read_lnk_files_pattern($1_ssh_t, ssh_home_t, ssh_home_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# ssh servers can read the user keys and config
Dan Walsh 3eaa99
	allow ssh_server ssh_home_t:dir list_dir_perms;
Dan Walsh 3eaa99
	read_files_pattern(ssh_server, ssh_home_t, ssh_home_t)
Dan Walsh 3eaa99
	read_lnk_files_pattern(ssh_server, ssh_home_t, ssh_home_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	kernel_read_kernel_sysctls($1_ssh_t)
Chris PeBenito cde150
	kernel_read_system_state($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 668b30
	corenet_tcp_sendrecv_generic_if($1_ssh_t)
Chris PeBenito c12621
	corenet_tcp_sendrecv_generic_node($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)
Dan Walsh 3eaa99
	corenet_tcp_bind_generic_node($1_ssh_t)
Dan Walsh 3eaa99
	corenet_tcp_bind_all_unreserved_ports($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 cde150
	auth_use_nsswitch($1_ssh_t)
Chris PeBenito cde150
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
	optional_policy(`
Chris PeBenito 17de1b
		kerberos_use($1_ssh_t)
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 cde150
	type $1_tmpfs_t;
Chris PeBenito cde150
	files_tmpfs_file($1_tmpfs_t)
Chris PeBenito cde150
Chris PeBenito 17de1b
	type $1_var_run_t;
Chris PeBenito 17de1b
	files_pid_file($1_var_run_t)
Chris PeBenito 17de1b
Dan Walsh 3eaa99
	allow $1_t self:capability { kill sys_chroot sys_nice sys_resource chown dac_override fowner fsetid net_admin setgid setuid sys_tty_config };
Chris PeBenito c0868a
	allow $1_t self:fifo_file rw_fifo_file_perms;
Dan Walsh 3eaa99
	allow $1_t self:process { signal getsched 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 cde150
	allow $1_t self:shm create_shm_perms;
Chris PeBenito 17de1b
Chris PeBenito c0868a
	allow $1_t $1_devpts_t:chr_file { rw_chr_file_perms setattr getattr relabelfrom };
Chris PeBenito cde150
	term_create_pty($1_t, $1_devpts_t)
Chris PeBenito cde150
Chris PeBenito cde150
	manage_files_pattern($1_t, $1_tmpfs_t, $1_tmpfs_t)
Chris PeBenito cde150
	fs_tmpfs_filetrans($1_t, $1_tmpfs_t, file)
Chris PeBenito 17de1b
Chris PeBenito c0868a
	allow $1_t $1_var_run_t:file manage_file_perms;
Chris PeBenito 0bfccd
	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 82d277
	allow $1_t sshd_key_t:file read_file_perms;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	kernel_read_kernel_sysctls($1_t)
Chris PeBenito cde150
	kernel_read_network_state($1_t)
Dan Walsh 3eaa99
	kernel_request_load_module(ssh_t)
Chris PeBenito 17de1b
Chris PeBenito 190066
	corenet_all_recvfrom_unlabeled($1_t)
Chris PeBenito 190066
	corenet_all_recvfrom_netlabel($1_t)
Chris PeBenito 668b30
	corenet_tcp_sendrecv_generic_if($1_t)
Chris PeBenito 668b30
	corenet_udp_sendrecv_generic_if($1_t)
Chris PeBenito 668b30
	corenet_raw_sendrecv_generic_if($1_t)
Chris PeBenito c12621
	corenet_tcp_sendrecv_generic_node($1_t)
Chris PeBenito c12621
	corenet_udp_sendrecv_generic_node($1_t)
Chris PeBenito c12621
	corenet_raw_sendrecv_generic_node($1_t)
Chris PeBenito 17de1b
	corenet_udp_sendrecv_all_ports($1_t)
Chris PeBenito 17de1b
	corenet_tcp_sendrecv_all_ports($1_t)
Chris PeBenito c12621
	corenet_tcp_bind_generic_node($1_t)
Chris PeBenito c12621
	corenet_udp_bind_generic_node($1_t)
Chris PeBenito 56e1b3
	corenet_tcp_bind_ssh_port($1_t)
Chris PeBenito 17de1b
	corenet_sendrecv_ssh_server_packets($1_t)
Dan Walsh 3eaa99
	# -R qualifier
Dan Walsh 3eaa99
	corenet_sendrecv_ssh_server_packets($1_t)
Dan Walsh 3eaa99
	# tunnel feature and -w (net_admin capability also)
Dan Walsh 3eaa99
	corenet_rw_tun_tap_dev($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)
Dan Walsh 3eaa99
	domain_dyntrans_type($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 088b65
	files_read_usr_files($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 296273
	userdom_dontaudit_relabelfrom_user_ptys($1_t)
Chris PeBenito 296273
	userdom_search_user_home_dirs($1_t)
Dan Walsh 3eaa99
	userdom_read_user_home_content_files($1_t)
Chris PeBenito 17de1b
Chris PeBenito cde150
	# Allow checking users mail at login
Chris PeBenito cde150
	mta_getattr_spool($1_t)
Chris PeBenito cde150
Chris PeBenito 17de1b
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 17de1b
		fs_read_nfs_files($1_t)
Chris PeBenito cde150
		fs_read_nfs_symlinks($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 cde150
		kerberos_manage_host_rcache($1_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito cde150
		files_read_var_lib_symlinks($1_t)
Chris PeBenito 17de1b
		nx_spec_domtrans_server($1_t)
Chris PeBenito 17de1b
	')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	optional_policy(`
Dan Walsh 3eaa99
		rlogin_read_home_content($1_t)
Dan Walsh 3eaa99
	')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	optional_policy(`
Dan Walsh 3eaa99
		shutdown_getattr_exec_files($1_t)
Dan Walsh 3eaa99
	')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito 296273
##	Role access for ssh
Chris PeBenito 296273
## </summary>
Chris PeBenito 296273
## <param name="role_prefix">
Chris PeBenito 296273
##	<summary>
Chris PeBenito 296273
##	The prefix of the role (e.g., user
Chris PeBenito 296273
##	is the prefix for user_r).
Chris PeBenito 296273
##	</summary>
Chris PeBenito 296273
## </param>
Chris PeBenito 296273
## <param name="role">
Chris PeBenito 296273
##	<summary>
Chris PeBenito 296273
##	Role allowed access
Chris PeBenito 296273
##	</summary>
Chris PeBenito 296273
## </param>
Chris PeBenito 296273
## <param name="domain">
Chris PeBenito 296273
##	<summary>
Chris PeBenito 296273
##	User domain for the role
Chris PeBenito 296273
##	</summary>
Chris PeBenito 296273
## </param>
Chris PeBenito 296273
#
Chris PeBenito 296273
template(`ssh_role_template',`
Chris PeBenito 296273
	gen_require(`
Chris PeBenito 296273
		attribute ssh_server, ssh_agent_type;
Chris PeBenito 296273
Chris PeBenito cde150
		type ssh_t, ssh_exec_t, ssh_tmpfs_t, ssh_home_t;
Chris PeBenito 296273
		type ssh_agent_exec_t, ssh_keysign_t, ssh_tmpfs_t;
Chris PeBenito 296273
		type ssh_agent_tmp_t;
Chris PeBenito 296273
	')
Chris PeBenito 296273
Chris PeBenito 296273
	##############################
Chris PeBenito 296273
	#
Chris PeBenito 296273
	# Declarations
Chris PeBenito 296273
	#
Chris PeBenito 296273
Chris PeBenito 296273
	role $2 types ssh_t;
Chris PeBenito 296273
Chris PeBenito 296273
	type $1_ssh_agent_t, ssh_agent_type;
Chris PeBenito 296273
	application_domain($1_ssh_agent_t, ssh_agent_exec_t)
Chris PeBenito 296273
	domain_interactive_fd($1_ssh_agent_t)
Chris PeBenito 296273
	ubac_constrained($1_ssh_agent_t)
Chris PeBenito 296273
	role $2 types $1_ssh_agent_t;
Chris PeBenito 296273
Chris PeBenito 296273
	##############################
Chris PeBenito 296273
	#
Chris PeBenito 296273
	# Local policy
Chris PeBenito 296273
	#
Chris PeBenito 296273
Chris PeBenito 296273
	# Transition from the domain to the derived domain.
Chris PeBenito 296273
	domtrans_pattern($3, ssh_exec_t, ssh_t)
Chris PeBenito 296273
Chris PeBenito 296273
	# inheriting stream sockets is needed for "ssh host command" as no pty
Chris PeBenito 296273
	# is allocated
Chris PeBenito 296273
	allow $3 ssh_server:unix_stream_socket rw_stream_socket_perms;
Chris PeBenito 296273
Chris PeBenito 296273
	# allow ps to show ssh
Chris PeBenito 296273
	ps_process_pattern($3, ssh_t)
Chris PeBenito 296273
	allow $3 ssh_t:process signal;
Chris PeBenito 296273
Chris PeBenito 296273
	# for rsync
Chris PeBenito 296273
	allow ssh_t $3:unix_stream_socket rw_socket_perms;
Chris PeBenito 296273
	allow ssh_t $3:unix_stream_socket connectto;
Chris PeBenito 296273
Chris PeBenito 296273
	# user can manage the keys and config
Chris PeBenito cde150
	manage_files_pattern($3, ssh_home_t, ssh_home_t)
Chris PeBenito cde150
	manage_lnk_files_pattern($3, ssh_home_t, ssh_home_t)
Chris PeBenito cde150
	manage_sock_files_pattern($3, ssh_home_t, ssh_home_t)
Chris PeBenito cde150
	userdom_search_user_home_dirs($1_t)
Dan Walsh 3eaa99
	userdom_manage_tmp_role($2, ssh_t)
Chris PeBenito 296273
Chris PeBenito 296273
	##############################
Chris PeBenito 296273
	#
Chris PeBenito 296273
	# SSH agent local policy
Chris PeBenito 296273
	#
Chris PeBenito 296273
Chris PeBenito 296273
	allow $1_ssh_agent_t self:process setrlimit;
Chris PeBenito 296273
	allow $1_ssh_agent_t self:capability setgid;
Chris PeBenito 296273
Chris PeBenito 296273
	allow $1_ssh_agent_t { $1_ssh_agent_t $3 }:process signull;
Chris PeBenito 296273
Chris PeBenito 296273
	allow $1_ssh_agent_t self:unix_stream_socket { create_stream_socket_perms connectto };
Chris PeBenito 296273
Chris PeBenito 296273
	manage_dirs_pattern($1_ssh_agent_t, ssh_agent_tmp_t, ssh_agent_tmp_t)
Chris PeBenito 296273
	manage_sock_files_pattern($1_ssh_agent_t, ssh_agent_tmp_t, ssh_agent_tmp_t)
Chris PeBenito 296273
	files_tmp_filetrans($1_ssh_agent_t, ssh_agent_tmp_t, { dir sock_file })
Chris PeBenito 296273
Chris PeBenito 296273
	# for ssh-add
Chris PeBenito 296273
	stream_connect_pattern($3, ssh_agent_tmp_t, ssh_agent_tmp_t, $1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	# Allow the user shell to signal the ssh program.
Chris PeBenito 296273
	allow $3 $1_ssh_agent_t:process signal;
Chris PeBenito 296273
Chris PeBenito 296273
	# allow ps to show ssh
Chris PeBenito 296273
	ps_process_pattern($3, $1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	domtrans_pattern($3, ssh_agent_exec_t, $1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	kernel_read_kernel_sysctls($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	dev_read_urand($1_ssh_agent_t)
Chris PeBenito 296273
	dev_read_rand($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	fs_search_auto_mountpoints($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	# transition back to normal privs upon exec
Chris PeBenito 296273
	corecmd_shell_domtrans($1_ssh_agent_t, $3)
Chris PeBenito 296273
	corecmd_bin_domtrans($1_ssh_agent_t, $3)
Chris PeBenito 296273
Chris PeBenito 296273
	domain_use_interactive_fds($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	files_read_etc_files($1_ssh_agent_t)
Chris PeBenito 296273
	files_read_etc_runtime_files($1_ssh_agent_t)
Chris PeBenito 296273
	files_search_home($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	libs_read_lib_files($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	logging_send_syslog_msg($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	miscfiles_read_localization($1_ssh_agent_t)
Dominick Grift 834062
	miscfiles_read_generic_certs($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	seutil_dontaudit_read_config($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	# Write to the user domain tty.
Chris PeBenito 296273
	userdom_use_user_terminals($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
	# for the transition back to normal privs upon exec
Chris PeBenito 088b65
	userdom_search_user_home_content($1_ssh_agent_t)
Chris PeBenito 296273
	userdom_user_home_domtrans($1_ssh_agent_t, $3)
Chris PeBenito 296273
	allow $3 $1_ssh_agent_t:fd use;
Chris PeBenito 296273
	allow $3 $1_ssh_agent_t:fifo_file rw_file_perms;
Chris PeBenito 296273
	allow $3 $1_ssh_agent_t:process sigchld;
Chris PeBenito 296273
Chris PeBenito 296273
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 296273
		fs_manage_nfs_files($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
		# transition back to normal privs upon exec
Chris PeBenito 296273
		fs_nfs_domtrans($1_ssh_agent_t, $3)
Chris PeBenito 296273
	')
Chris PeBenito 296273
Chris PeBenito 296273
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 296273
		fs_manage_cifs_files($1_ssh_agent_t)
Chris PeBenito 296273
Chris PeBenito 296273
		# transition back to normal privs upon exec
Chris PeBenito 296273
		fs_cifs_domtrans($1_ssh_agent_t, $3)
Chris PeBenito 296273
	')
Chris PeBenito 296273
Chris PeBenito 296273
	optional_policy(`
Chris PeBenito 296273
		nis_use_ypbind($1_ssh_agent_t)
Chris PeBenito 296273
	')
Chris PeBenito 296273
Chris PeBenito 296273
	optional_policy(`
Chris PeBenito 296273
		xserver_use_xdm_fds($1_ssh_agent_t)
Chris PeBenito 296273
		xserver_rw_xdm_pipes($1_ssh_agent_t)
Chris PeBenito 296273
	')
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
########################################
Chris PeBenito 296273
## <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 cde150
##	Send a generic signal to the ssh server.
Chris PeBenito cde150
## </summary>
Chris PeBenito cde150
## <param name="domain">
Chris PeBenito cde150
##	<summary>
Chris PeBenito cde150
##	Domain allowed access.
Chris PeBenito cde150
##	</summary>
Chris PeBenito cde150
## </param>
Chris PeBenito cde150
#
Chris PeBenito cde150
interface(`ssh_signal',`
Chris PeBenito cde150
	gen_require(`
Chris PeBenito cde150
		type sshd_t;
Chris PeBenito cde150
	')
Chris PeBenito cde150
Chris PeBenito cde150
	allow $1 sshd_t:process signal;
Chris PeBenito cde150
')
Chris PeBenito cde150
Chris PeBenito cde150
########################################
Chris PeBenito cde150
## <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 cde150
########################################
Chris PeBenito cde150
## <summary>
Chris PeBenito cde150
##	Read and write a ssh server unnamed pipe.
Chris PeBenito cde150
## </summary>
Chris PeBenito cde150
## <param name="domain">
Chris PeBenito cde150
##	<summary>
Chris PeBenito cde150
##	Domain allowed access.
Chris PeBenito cde150
##	</summary>
Chris PeBenito cde150
## </param>
Chris PeBenito cde150
#
Chris PeBenito cde150
interface(`ssh_rw_pipes',`
Chris PeBenito cde150
	gen_require(`
Chris PeBenito cde150
		type sshd_t;
Chris PeBenito cde150
	')
Chris PeBenito cde150
Chris PeBenito cde150
	allow $1 sshd_t:fifo_file { write read getattr ioctl };
Chris PeBenito cde150
')
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>
Dominick Grift 288845
##	Domain allowed to transition.
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 0bfccd
	domtrans_pattern($1, sshd_exec_t, sshd_t)
Chris PeBenito 6b19be
')
Chris PeBenito 6b19be
Dan Walsh 3eaa99
Dan Walsh 3eaa99
########################################
Dan Walsh 3eaa99
## <summary>
Dan Walsh 3eaa99
##	Execute sshd server in the sshd domain.
Dan Walsh 3eaa99
## </summary>
Dan Walsh 3eaa99
## <param name="domain">
Dan Walsh 3eaa99
##	<summary>
Dan Walsh 3eaa99
##	Domain allowed access.
Dan Walsh 3eaa99
##	</summary>
Dan Walsh 3eaa99
## </param>
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
interface(`ssh_initrc_domtrans',`
Dan Walsh 3eaa99
	gen_require(`
Dan Walsh 3eaa99
		type sshd_initrc_exec_t;
Dan Walsh 3eaa99
	')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	init_labeled_script_domtrans($1, sshd_initrc_exec_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
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 0bfccd
	can_exec($1, ssh_exec_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
## <summary>
Chris PeBenito cde150
##	Set the attributes of sshd key files.
Chris PeBenito cde150
## </summary>
Chris PeBenito cde150
## <param name="domain">
Chris PeBenito cde150
##	<summary>
Chris PeBenito cde150
##	Domain allowed access.
Chris PeBenito cde150
##	</summary>
Chris PeBenito cde150
## </param>
Chris PeBenito cde150
#
Chris PeBenito cde150
interface(`ssh_setattr_key_files',`
Chris PeBenito cde150
	gen_require(`
Chris PeBenito cde150
		type sshd_key_t;
Chris PeBenito cde150
	')
Chris PeBenito cde150
Chris PeBenito cde150
	allow $1 sshd_key_t:file setattr;
Chris PeBenito cde150
	files_search_pids($1)
Chris PeBenito cde150
')
Chris PeBenito cde150
Chris PeBenito cde150
########################################
Chris PeBenito cde150
## <summary>
Chris PeBenito cde150
##	Execute the ssh agent client in the caller domain.
Chris PeBenito cde150
## </summary>
Chris PeBenito cde150
## <param name="domain">
Chris PeBenito cde150
##	<summary>
Chris PeBenito cde150
##	Domain allowed access.
Chris PeBenito cde150
##	</summary>
Chris PeBenito cde150
## </param>
Chris PeBenito cde150
#
Chris PeBenito cde150
interface(`ssh_agent_exec',`
Chris PeBenito cde150
	gen_require(`
Chris PeBenito cde150
		type ssh_agent_exec_t;
Chris PeBenito cde150
	')
Chris PeBenito cde150
Chris PeBenito cde150
	corecmd_search_bin($1)
Chris PeBenito cde150
	can_exec($1, ssh_agent_exec_t)
Chris PeBenito cde150
')
Chris PeBenito cde150
Chris PeBenito cde150
########################################
Chris PeBenito cde150
## <summary>
Chris PeBenito cde150
##	Read ssh home directory content
Chris PeBenito cde150
## </summary>
Chris PeBenito cde150
## <param name="domain">
Chris PeBenito cde150
##	<summary>
Chris PeBenito cde150
##	Domain allowed access.
Chris PeBenito cde150
##	</summary>
Chris PeBenito cde150
## </param>
Chris PeBenito cde150
#
Chris PeBenito cde150
interface(`ssh_read_user_home_files',`
Chris PeBenito cde150
	gen_require(`
Chris PeBenito cde150
		type ssh_home_t;
Chris PeBenito cde150
	')
Chris PeBenito cde150
Chris PeBenito cde150
	allow $1 ssh_home_t:dir list_dir_perms;
Chris PeBenito cde150
	read_files_pattern($1, ssh_home_t, ssh_home_t)
Chris PeBenito cde150
	read_lnk_files_pattern($1, ssh_home_t, ssh_home_t)
Chris PeBenito cde150
	userdom_search_user_home_dirs($1)
Chris PeBenito cde150
')
Chris PeBenito cde150
Chris PeBenito cde150
########################################
Chris PeBenito cde150
## <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>
Dominick Grift 288845
##	Domain allowed to transition.
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 0bfccd
	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>
Dominick Grift 288845
##	Domain to not audit.
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
')
Chris PeBenito cde150
Chris PeBenito 088b65
######################################
Chris PeBenito 088b65
## <summary>
Chris PeBenito 088b65
##	Manage ssh home directory content
Chris PeBenito 088b65
## </summary>
Chris PeBenito 088b65
## <param name="domain">
Chris PeBenito 088b65
##	<summary>
Chris PeBenito 088b65
##	Domain allowed access.
Chris PeBenito 088b65
##	</summary>
Chris PeBenito 088b65
## </param>
Chris PeBenito 088b65
#
Chris PeBenito 088b65
interface(`ssh_manage_home_files',`
Chris PeBenito 088b65
	gen_require(`
Chris PeBenito 088b65
		type ssh_home_t;
Chris PeBenito 088b65
	')
Chris PeBenito 088b65
Chris PeBenito 088b65
	manage_files_pattern($1, ssh_home_t, ssh_home_t)
Chris PeBenito 088b65
	userdom_search_user_home_dirs($1)
Chris PeBenito 088b65
')
Chris PeBenito 088b65
Chris PeBenito cde150
#######################################
Chris PeBenito cde150
## <summary>
Chris PeBenito cde150
##	Delete from the ssh temp files.
Chris PeBenito cde150
## </summary>
Chris PeBenito cde150
## <param name="domain">
Chris PeBenito cde150
##	<summary>
Chris PeBenito cde150
##	Domain allowed access.
Chris PeBenito cde150
##	</summary>
Chris PeBenito cde150
## </param>
Chris PeBenito cde150
#
Chris PeBenito cde150
interface(`ssh_delete_tmp',`
Chris PeBenito cde150
	gen_require(`
Chris PeBenito cde150
		type sshd_tmp_t;
Chris PeBenito cde150
	')
Chris PeBenito cde150
Chris PeBenito cde150
	files_search_tmp($1)
Chris PeBenito cde150
	delete_files_pattern($1, sshd_tmp_t, sshd_tmp_t)
Chris PeBenito cde150
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
########################################
Dan Walsh 3eaa99
## <summary>
Dan Walsh 3eaa99
##	Send a null signal to sshd processes.
Dan Walsh 3eaa99
## </summary>
Dan Walsh 3eaa99
## <param name="domain">
Dan Walsh 3eaa99
##	<summary>
Dan Walsh 3eaa99
##	Domain allowed access.
Dan Walsh 3eaa99
##	</summary>
Dan Walsh 3eaa99
## </param>
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
interface(`ssh_signull',`
Dan Walsh 3eaa99
	gen_require(`
Dan Walsh 3eaa99
		type sshd_t;
Dan Walsh 3eaa99
	')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	allow $1 sshd_t:process signull;
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99