2005-06-24 13:36:57 +00:00
|
|
|
## <summary>Secure shell client and server policy.</summary>
|
|
|
|
|
2005-06-24 20:37:09 +00:00
|
|
|
#######################################
|
|
|
|
## <summary>
|
|
|
|
## The per user domain template for the ssh module.
|
|
|
|
## </summary>
|
|
|
|
## <desc>
|
|
|
|
## <p>
|
|
|
|
## This template creates a derived domains which are used
|
|
|
|
## for ssh client sessions and user ssh agents. A derived
|
|
|
|
## type is also created to protect the user ssh keys.
|
|
|
|
## </p>
|
|
|
|
## <p>
|
|
|
|
## This template is invoked automatically for each user, and
|
|
|
|
## generally does not need to be invoked directly
|
|
|
|
## by policy writers.
|
|
|
|
## </p>
|
|
|
|
## </desc>
|
|
|
|
## <param name="userdomain_prefix">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2005-06-24 20:37:09 +00:00
|
|
|
## The prefix of the user domain (e.g., user
|
|
|
|
## is the prefix for user_t).
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-06-24 20:37:09 +00:00
|
|
|
## </param>
|
2005-08-30 15:48:57 +00:00
|
|
|
## <param name="user_domain">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## The type of the user domain.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## </param>
|
|
|
|
## <param name="user_role">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## The role associated with the user domain.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-08-30 15:48:57 +00:00
|
|
|
## </param>
|
2005-06-24 20:37:09 +00:00
|
|
|
#
|
2005-06-22 19:21:31 +00:00
|
|
|
template(`ssh_per_userdomain_template',`
|
2005-10-18 18:25:33 +00:00
|
|
|
gen_require(`
|
2005-10-19 14:36:04 +00:00
|
|
|
attribute ssh_server;
|
2005-10-18 18:25:33 +00:00
|
|
|
type ssh_exec_t, ssh_agent_exec_t;
|
2005-10-19 14:36:04 +00:00
|
|
|
type sshd_key_t, ssh_keysign_exec_t;
|
|
|
|
type sshd_tmp_t, sshd_t;
|
2005-10-18 18:25:33 +00:00
|
|
|
')
|
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Declarations
|
|
|
|
#
|
2005-06-21 21:07:46 +00:00
|
|
|
|
2005-12-01 18:01:21 +00:00
|
|
|
type $1_home_ssh_t;
|
|
|
|
userdom_home_file($1,$1_home_ssh_t)
|
2005-08-30 15:48:57 +00:00
|
|
|
role $3 types $1_ssh_t;
|
2005-06-21 21:07:46 +00:00
|
|
|
|
2005-07-13 20:48:51 +00:00
|
|
|
type $1_ssh_t;
|
2005-06-22 21:14:48 +00:00
|
|
|
domain_type($1_ssh_t)
|
2005-10-10 18:11:46 +00:00
|
|
|
domain_entry_file($1_ssh_t,ssh_exec_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
|
|
|
|
type $1_ssh_agent_t;
|
|
|
|
domain_type($1_ssh_agent_t)
|
2005-10-10 18:11:46 +00:00
|
|
|
domain_entry_file($1_ssh_agent_t,ssh_agent_exec_t)
|
2005-08-30 15:48:57 +00:00
|
|
|
role $3 types $1_ssh_agent_t;
|
2005-06-22 21:14:48 +00:00
|
|
|
|
2005-10-10 18:11:46 +00:00
|
|
|
type $1_ssh_keysign_t; #, nscd_client_domain;
|
|
|
|
domain_type($1_ssh_keysign_t)
|
|
|
|
domain_entry_file($1_ssh_keysign_t,ssh_keysign_exec_t)
|
|
|
|
role $3 types $1_ssh_keysign_t;
|
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# $1_ssh_t local policy
|
|
|
|
#
|
|
|
|
allow $1_ssh_t self:capability { setuid setgid dac_override dac_read_search };
|
2005-09-01 20:13:42 +00:00
|
|
|
allow $1_ssh_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
|
2005-06-22 21:14:48 +00:00
|
|
|
allow $1_ssh_t self:fd use;
|
|
|
|
allow $1_ssh_t self:fifo_file { read getattr lock ioctl write append };
|
|
|
|
allow $1_ssh_t self:unix_dgram_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
|
|
|
|
allow $1_ssh_t self:unix_stream_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown listen accept };
|
|
|
|
allow $1_ssh_t self:unix_dgram_socket sendto;
|
|
|
|
allow $1_ssh_t self:unix_stream_socket connectto;
|
|
|
|
allow $1_ssh_t self:shm { associate getattr setattr create destroy read write lock unix_read unix_write };
|
|
|
|
allow $1_ssh_t self:sem { associate getattr setattr create destroy read write unix_read unix_write };
|
|
|
|
allow $1_ssh_t self:msgq { associate getattr setattr create destroy read write enqueue unix_read unix_write };
|
|
|
|
allow $1_ssh_t self:msg { send receive };
|
2005-06-23 15:44:18 +00:00
|
|
|
allow $1_ssh_t self:tcp_socket { create connect ioctl read getattr write setattr append bind getopt setopt shutdown };
|
2005-06-22 21:14:48 +00:00
|
|
|
|
2005-06-21 21:07:46 +00:00
|
|
|
# Transition from the user domain to the derived domain.
|
2005-08-30 15:48:57 +00:00
|
|
|
domain_auto_trans($2, ssh_exec_t, $1_ssh_t)
|
|
|
|
allow $2 $1_ssh_t:fd use;
|
|
|
|
allow $1_ssh_t $2:fd use;
|
|
|
|
allow $1_ssh_t $2:fifo_file rw_file_perms;
|
|
|
|
allow $1_ssh_t $2:process sigchld;
|
2005-06-21 21:07:46 +00:00
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
# Read the ssh key file.
|
|
|
|
allow $1_ssh_t sshd_key_t:file r_file_perms;
|
|
|
|
|
2005-06-23 20:35:48 +00:00
|
|
|
# Access the ssh temporary files.
|
|
|
|
allow $1_ssh_t sshd_tmp_t:dir create_dir_perms;
|
|
|
|
allow $1_ssh_t sshd_tmp_t:file create_file_perms;
|
2006-01-13 21:06:49 +00:00
|
|
|
files_filetrans_tmp($1_ssh_t, sshd_tmp_t, { file dir })
|
2005-06-23 20:35:48 +00:00
|
|
|
|
|
|
|
# for rsync
|
2005-08-30 15:48:57 +00:00
|
|
|
allow $1_ssh_t $2:unix_stream_socket rw_socket_perms;
|
|
|
|
allow $1_ssh_t $2:unix_stream_socket connectto;
|
2005-06-23 20:35:48 +00:00
|
|
|
|
|
|
|
# user can manage the keys and config
|
2005-08-30 15:48:57 +00:00
|
|
|
allow $2 $1_home_ssh_t:dir rw_dir_perms;
|
|
|
|
allow $2 $1_home_ssh_t:file create_file_perms;
|
|
|
|
allow $2 $1_home_ssh_t:lnk_file create_lnk_perms;
|
|
|
|
allow $2 $1_home_ssh_t:sock_file create_file_perms;
|
2005-06-23 20:35:48 +00:00
|
|
|
|
2005-07-28 20:52:55 +00:00
|
|
|
# inheriting stream sockets is needed for "ssh host command" as no pty
|
|
|
|
# is allocated
|
|
|
|
# cjp: should probably fix target to be an attribute for ssh servers
|
|
|
|
# or "regular" (not special like sshd_extern_t) servers
|
2005-08-30 15:48:57 +00:00
|
|
|
allow $2 sshd_t:unix_stream_socket rw_stream_socket_perms;
|
2005-07-28 20:52:55 +00:00
|
|
|
|
2005-06-23 20:35:48 +00:00
|
|
|
# ssh client can manage the keys and config
|
2006-01-20 22:41:54 +00:00
|
|
|
userdom_search_user_home($1,$1_ssh_t)
|
|
|
|
allow $1_ssh_t $1_home_ssh_t:dir r_dir_perms;
|
2005-06-23 20:35:48 +00:00
|
|
|
allow $1_ssh_t $1_home_ssh_t:file create_file_perms;
|
|
|
|
allow $1_ssh_t $1_home_ssh_t:lnk_file { getattr read };
|
|
|
|
|
|
|
|
# ssh servers can read the user keys and config
|
|
|
|
allow ssh_server $1_home_ssh_t:dir r_dir_perms;
|
|
|
|
allow ssh_server $1_home_ssh_t:lnk_file r_file_perms;
|
|
|
|
allow ssh_server $1_home_ssh_t:file r_file_perms;
|
|
|
|
|
2006-01-31 16:49:43 +00:00
|
|
|
kernel_read_kernel_sysctls($1_ssh_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
|
2005-06-23 15:44:18 +00:00
|
|
|
corenet_tcp_sendrecv_all_if($1_ssh_t)
|
|
|
|
corenet_raw_sendrecv_all_if($1_ssh_t)
|
|
|
|
corenet_tcp_sendrecv_all_nodes($1_ssh_t)
|
|
|
|
corenet_raw_sendrecv_all_nodes($1_ssh_t)
|
|
|
|
corenet_tcp_sendrecv_all_ports($1_ssh_t)
|
2005-12-06 19:59:50 +00:00
|
|
|
corenet_non_ipsec_sendrecv($1_ssh_t)
|
2005-06-23 15:44:18 +00:00
|
|
|
corenet_tcp_bind_all_nodes($1_ssh_t)
|
2005-09-16 19:36:10 +00:00
|
|
|
corenet_tcp_connect_ssh_port($1_ssh_t)
|
2005-06-23 15:44:18 +00:00
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
dev_read_urand($1_ssh_t)
|
|
|
|
|
|
|
|
fs_getattr_all_fs($1_ssh_t)
|
2005-06-27 16:30:55 +00:00
|
|
|
fs_search_auto_mountpoints($1_ssh_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
|
|
|
|
# run helper programs - needed eg for x11-ssh-askpass
|
|
|
|
corecmd_exec_shell($1_ssh_t)
|
|
|
|
corecmd_exec_bin($1_ssh_t)
|
2005-07-13 18:29:08 +00:00
|
|
|
corecmd_list_sbin($1_ssh_t)
|
2006-02-02 21:08:12 +00:00
|
|
|
corecmd_read_sbin_symlinks($1_ssh_t)
|
2005-07-13 18:29:08 +00:00
|
|
|
# cjp: these are probably not needed:
|
2006-02-02 21:08:12 +00:00
|
|
|
corecmd_read_sbin_files($1_ssh_t)
|
|
|
|
corecmd_read_sbin_pipes($1_ssh_t)
|
|
|
|
corecmd_read_sbin_sockets($1_ssh_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
|
|
|
|
domain_use_wide_inherit_fd($1_ssh_t)
|
|
|
|
|
|
|
|
files_list_home($1_ssh_t)
|
|
|
|
files_read_usr_files($1_ssh_t)
|
|
|
|
files_read_etc_runtime_files($1_ssh_t)
|
2005-06-29 14:26:41 +00:00
|
|
|
files_read_etc_files($1_ssh_t)
|
2005-09-16 19:36:10 +00:00
|
|
|
files_read_var_files($1_ssh_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
|
2005-06-21 21:07:46 +00:00
|
|
|
libs_use_ld_so($1_ssh_t)
|
|
|
|
libs_use_shared_libs($1_ssh_t)
|
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
logging_send_syslog_msg($1_ssh_t)
|
|
|
|
logging_read_generic_logs($1_ssh_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization($1_ssh_t)
|
|
|
|
|
|
|
|
seutil_read_config($1_ssh_t)
|
|
|
|
|
2005-06-23 15:44:18 +00:00
|
|
|
sysnet_read_config($1_ssh_t)
|
2005-09-15 21:03:29 +00:00
|
|
|
sysnet_dns_name_resolve($1_ssh_t)
|
2005-06-23 15:44:18 +00:00
|
|
|
|
2005-06-23 20:35:48 +00:00
|
|
|
userdom_use_unpriv_users_fd($1_ssh_t)
|
2005-10-19 19:45:20 +00:00
|
|
|
# Write to the user domain tty.
|
|
|
|
userdom_use_user_terminals($1,$1_ssh_t)
|
2005-06-23 20:35:48 +00:00
|
|
|
|
2005-07-13 18:29:08 +00:00
|
|
|
tunable_policy(`read_default_t',`
|
|
|
|
files_list_default($1_ssh_t)
|
|
|
|
files_read_default_files($1_ssh_t)
|
|
|
|
files_read_default_symlinks($1_ssh_t)
|
|
|
|
files_read_default_sockets($1_ssh_t)
|
|
|
|
files_read_default_pipes($1_ssh_t)
|
|
|
|
')
|
|
|
|
|
2005-06-21 21:07:46 +00:00
|
|
|
tunable_policy(`use_nfs_home_dirs',`
|
|
|
|
fs_manage_nfs_dirs($1_ssh_t)
|
|
|
|
fs_manage_nfs_files($1_ssh_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`use_samba_home_dirs',`
|
|
|
|
fs_manage_cifs_dirs($1_ssh_t)
|
|
|
|
fs_manage_cifs_files($1_ssh_t)
|
|
|
|
')
|
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
# for port forwarding
|
|
|
|
tunable_policy(`user_tcp_server',`
|
|
|
|
corenet_tcp_bind_ssh_port($1_ssh_t)
|
|
|
|
')
|
2005-06-21 21:07:46 +00:00
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`kerberos',`
|
2005-07-01 13:31:34 +00:00
|
|
|
kerberos_use($1_ssh_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`nis',`
|
2005-06-27 16:30:55 +00:00
|
|
|
nis_use_ypbind($1_ssh_t)
|
|
|
|
')
|
2005-06-21 21:07:46 +00:00
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`nscd',`
|
2006-02-02 21:08:12 +00:00
|
|
|
nscd_socket_use($1_ssh_t)
|
2005-07-13 20:48:51 +00:00
|
|
|
')
|
|
|
|
|
2006-01-20 20:10:35 +00:00
|
|
|
optional_policy(`xserver',`
|
|
|
|
xserver_domtrans_user_xauth($1,$1_ssh_t)
|
|
|
|
')
|
|
|
|
|
2005-06-27 16:30:55 +00:00
|
|
|
ifdef(`TODO',`
|
2005-06-21 21:07:46 +00:00
|
|
|
|
|
|
|
# Read /var/run, /var/log.
|
|
|
|
allow $1_ssh_t var_run_t:dir r_dir_perms;
|
|
|
|
allow $1_ssh_t var_run_t:{ file lnk_file } r_file_perms;
|
|
|
|
|
|
|
|
allow $1_ssh_t $1_tmp_t:dir r_dir_perms;
|
|
|
|
|
|
|
|
# Access the users .ssh directory.
|
|
|
|
file_type_auto_trans({ sysadm_ssh_t $1_ssh_t }, $1_home_dir_t, $1_home_ssh_t, dir)
|
|
|
|
file_type_auto_trans($1_ssh_t, $1_home_dir_t, $1_home_ssh_t, sock_file)
|
2005-06-23 20:35:48 +00:00
|
|
|
allow sysadm_ssh_t $1_home_ssh_t:file create_file_perms;
|
|
|
|
allow sysadm_ssh_t $1_home_ssh_t:lnk_file { getattr read };
|
2005-06-21 21:07:46 +00:00
|
|
|
dontaudit $1_ssh_t $1_home_t:dir { getattr search };
|
|
|
|
|
|
|
|
# for /bin/sh used to execute xauth
|
|
|
|
dontaudit $1_ssh_t proc_t:{ lnk_file file } { getattr read };
|
|
|
|
|
|
|
|
# Inherit and use descriptors from gnome-pty-helper.
|
|
|
|
ifdef(`gnome-pty-helper.te', `allow $1_ssh_t $1_gph_t:fd use;')
|
|
|
|
|
|
|
|
# allow ps to show ssh
|
|
|
|
can_ps($1_t, $1_ssh_t)
|
|
|
|
|
2005-09-16 19:36:10 +00:00
|
|
|
# Connect to X server
|
|
|
|
x_client_domain($1_ssh, $1)
|
2005-06-21 21:07:46 +00:00
|
|
|
|
|
|
|
#allow ssh to access keys stored on removable media
|
|
|
|
# Should we have a boolean around this?
|
2005-06-27 18:37:33 +00:00
|
|
|
files_search_mnt($1_ssh_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
r_dir_file($1_ssh_t, removable_t)
|
|
|
|
|
2005-09-16 19:36:10 +00:00
|
|
|
if (allow_ssh_keysign) {
|
|
|
|
domain_auto_trans($1_ssh_t, ssh_keysign_exec_t, $1_ssh_keysign_t)
|
|
|
|
allow $1_ssh_keysign_t sshd_key_t:file { getattr read };
|
|
|
|
allow $1_ssh_keysign_t self:capability { setgid setuid };
|
|
|
|
allow $1_ssh_keysign_t urandom_device_t:chr_file r_file_perms;
|
|
|
|
uses_shlib($1_ssh_keysign_t)
|
|
|
|
dontaudit $1_ssh_keysign_t selinux_config_t:dir search;
|
|
|
|
dontaudit $1_ssh_keysign_t proc_t:dir search;
|
|
|
|
dontaudit $1_ssh_keysign_t proc_t:{ lnk_file file } { getattr read };
|
|
|
|
allow $1_ssh_keysign_t usr_t:dir search;
|
|
|
|
allow $1_ssh_keysign_t etc_t:file { getattr read };
|
|
|
|
allow $1_ssh_keysign_t self:dir search;
|
|
|
|
allow $1_ssh_keysign_t self:file { getattr read };
|
|
|
|
allow $1_ssh_keysign_t self:unix_stream_socket create_socket_perms;
|
|
|
|
}
|
|
|
|
|
2005-06-21 21:07:46 +00:00
|
|
|
') dnl endif TODO
|
2005-06-22 21:14:48 +00:00
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# $1_ssh_agent_t local policy
|
|
|
|
#
|
2005-07-13 18:29:08 +00:00
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
allow $1_ssh_agent_t self:process setrlimit;
|
|
|
|
allow $1_ssh_agent_t self:capability setgid;
|
|
|
|
|
2005-08-30 15:48:57 +00:00
|
|
|
allow $1_ssh_agent_t { $1_ssh_agent_t $2 }:process signull;
|
2005-06-22 21:14:48 +00:00
|
|
|
|
|
|
|
allow $1_ssh_t $1_ssh_agent_t:unix_stream_socket connectto;
|
|
|
|
|
2005-08-30 15:48:57 +00:00
|
|
|
# for ssh-add
|
|
|
|
allow $2 $1_ssh_agent_t:unix_stream_socket connectto;
|
|
|
|
|
|
|
|
# Allow the user shell to signal the ssh program.
|
|
|
|
allow $2 $1_ssh_agent_t:process signal;
|
|
|
|
|
2005-07-13 18:29:08 +00:00
|
|
|
# for the transition back to normal privs upon exec
|
2005-08-30 15:48:57 +00:00
|
|
|
allow $1_ssh_agent_t $2:fd use;
|
|
|
|
allow $2 $1_ssh_agent_t:fd use;
|
|
|
|
allow $2 $1_ssh_agent_t:fifo_file rw_file_perms;
|
|
|
|
allow $2 $1_ssh_agent_t:process sigchld;
|
2005-07-13 18:29:08 +00:00
|
|
|
|
|
|
|
# Allow the ssh program to communicate with ssh-agent.
|
|
|
|
allow $1_ssh_t sshd_t:unix_stream_socket connectto;
|
|
|
|
|
2005-08-30 15:48:57 +00:00
|
|
|
domain_auto_trans($2, ssh_agent_exec_t, $1_ssh_agent_t)
|
|
|
|
allow $2 $1_ssh_agent_t:fd use;
|
|
|
|
allow $1_ssh_agent_t $2:fd use;
|
|
|
|
allow $1_ssh_agent_t $2:fifo_file rw_file_perms;
|
|
|
|
allow $1_ssh_agent_t $2:process sigchld;
|
2005-06-22 21:14:48 +00:00
|
|
|
|
2006-01-31 16:49:43 +00:00
|
|
|
kernel_read_kernel_sysctls($1_ssh_agent_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
|
|
|
|
dev_read_urand($1_ssh_agent_t)
|
|
|
|
dev_read_rand($1_ssh_agent_t)
|
|
|
|
|
2005-06-27 16:30:55 +00:00
|
|
|
fs_search_auto_mountpoints($1_ssh_agent_t)
|
|
|
|
|
2005-07-13 18:29:08 +00:00
|
|
|
# transition back to normal privs upon exec
|
|
|
|
corecmd_shell_domtrans($1_ssh_agent_t,$1_t)
|
|
|
|
corecmd_bin_domtrans($1_ssh_agent_t, $1_t)
|
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
domain_use_wide_inherit_fd($1_ssh_agent_t)
|
|
|
|
|
2005-06-29 14:26:41 +00:00
|
|
|
files_read_etc_files($1_ssh_agent_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
files_read_etc_runtime_files($1_ssh_agent_t)
|
2005-08-05 18:49:23 +00:00
|
|
|
files_search_home($1_ssh_agent_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
|
2006-02-02 21:08:12 +00:00
|
|
|
libs_read_lib_files($1_ssh_agent_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
libs_use_ld_so($1_ssh_agent_t)
|
|
|
|
libs_use_shared_libs($1_ssh_agent_t)
|
|
|
|
|
|
|
|
logging_send_syslog_msg($1_ssh_agent_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization($1_ssh_agent_t)
|
|
|
|
|
2005-09-16 19:36:10 +00:00
|
|
|
seutil_dontaudit_read_config($1_ssh_agent_t)
|
2005-07-13 18:29:08 +00:00
|
|
|
|
2005-08-30 15:48:57 +00:00
|
|
|
# Write to the user domain tty.
|
|
|
|
userdom_use_user_terminals($1,$1_ssh_agent_t)
|
|
|
|
|
2005-07-13 18:29:08 +00:00
|
|
|
tunable_policy(`use_nfs_home_dirs',`
|
2005-06-22 21:14:48 +00:00
|
|
|
fs_manage_nfs_files($1_ssh_agent_t)
|
|
|
|
|
2005-07-13 18:29:08 +00:00
|
|
|
# transition back to normal privs upon exec
|
|
|
|
fs_nfs_domtrans($1_ssh_agent_t, $1_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`use_samba_home_dirs',`
|
2005-06-22 21:14:48 +00:00
|
|
|
fs_manage_cifs_files($1_ssh_agent_t)
|
2005-07-13 18:29:08 +00:00
|
|
|
|
|
|
|
# transition back to normal privs upon exec
|
|
|
|
fs_cifs_domtrans($1_ssh_agent_t, $1_t)
|
|
|
|
')
|
2005-06-22 21:14:48 +00:00
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`nis',`
|
2005-06-27 16:30:55 +00:00
|
|
|
nis_use_ypbind($1_ssh_agent_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
# optional_policy(`xdm',`
|
2005-10-18 18:25:33 +00:00
|
|
|
# # KDM:
|
|
|
|
# xdm_sigchld($1_ssh_agent_t)
|
|
|
|
# ')
|
2005-07-13 18:29:08 +00:00
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
ifdef(`TODO',`
|
2005-09-16 19:36:10 +00:00
|
|
|
ifdef(`xdm.te',`
|
|
|
|
can_pipe_xdm($1_ssh_agent_t)
|
|
|
|
')
|
2005-06-22 21:14:48 +00:00
|
|
|
|
|
|
|
# allow ps to show ssh
|
|
|
|
can_ps($1_t, $1_ssh_agent_t)
|
|
|
|
|
|
|
|
dontaudit $1_ssh_agent_t proc_t:{ lnk_file file } { getattr read };
|
|
|
|
|
|
|
|
# Access the ssh temporary files. Should we have an own type here
|
|
|
|
# to which only ssh, ssh-agent and ssh-add have access?
|
|
|
|
allow $1_ssh_agent_t $1_tmp_t:dir r_dir_perms;
|
|
|
|
file_type_auto_trans($1_ssh_agent_t, tmp_t, $1_tmp_t)
|
|
|
|
|
|
|
|
# transition back to normal privs upon exec
|
2005-07-13 18:29:08 +00:00
|
|
|
domain_auto_trans($1_ssh_agent_t, $1_home_t, $1_t)
|
2005-08-05 18:49:23 +00:00
|
|
|
allow $1_ssh_agent_t $1_home_dir_t:dir search;
|
2005-06-22 21:14:48 +00:00
|
|
|
|
|
|
|
allow $1_ssh_t $1_tmp_t:sock_file write;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Allow command to ssh-agent > ~/.ssh_agent
|
|
|
|
#
|
|
|
|
allow $1_ssh_agent_t $1_home_t:file rw_file_perms;
|
|
|
|
allow $1_ssh_agent_t $1_tmp_t:file rw_file_perms;
|
|
|
|
|
|
|
|
# Allow the ssh program to communicate with ssh-agent.
|
|
|
|
allow $1_ssh_t $1_tmp_t:sock_file write;
|
2005-08-30 15:48:57 +00:00
|
|
|
allow $1_ssh_t $2:unix_stream_socket connectto;
|
2005-06-22 21:14:48 +00:00
|
|
|
') dnl endif TODO
|
2005-10-10 18:11:46 +00:00
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# $1_ssh_keysign_t local policy
|
|
|
|
#
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`nscd',`
|
2006-02-02 21:08:12 +00:00
|
|
|
nscd_socket_use($1_ssh_keysign_t)
|
2005-10-10 18:11:46 +00:00
|
|
|
')
|
2005-06-21 21:07:46 +00:00
|
|
|
')
|
|
|
|
|
2005-06-24 20:37:09 +00:00
|
|
|
#######################################
|
|
|
|
## <summary>
|
|
|
|
## The template to define a ssh server.
|
|
|
|
## </summary>
|
|
|
|
## <desc>
|
|
|
|
## <p>
|
|
|
|
## This template creates a domains to be used for
|
|
|
|
## creating a ssh server. This is typically done
|
|
|
|
## to have multiple ssh servers of different sensitivities,
|
|
|
|
## such as for an internal network-facing ssh server, and
|
|
|
|
## a external network-facing ssh server.
|
|
|
|
## </p>
|
|
|
|
## </desc>
|
|
|
|
## <param name="userdomain_prefix">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2005-06-29 14:26:41 +00:00
|
|
|
## The prefix of the server domain (e.g., sshd
|
|
|
|
## is the prefix for sshd_t).
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-06-24 20:37:09 +00:00
|
|
|
## </param>
|
2005-06-21 21:07:46 +00:00
|
|
|
#
|
2005-06-29 14:26:41 +00:00
|
|
|
template(`ssh_server_template', `
|
2005-09-26 20:26:32 +00:00
|
|
|
type $1_t, ssh_server;
|
|
|
|
|
2005-09-09 20:51:54 +00:00
|
|
|
domain_type($1_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
role system_r types $1_t;
|
|
|
|
|
|
|
|
type $1_devpts_t;
|
|
|
|
term_login_pty($1_devpts_t)
|
|
|
|
|
|
|
|
type $1_var_run_t;
|
|
|
|
files_pid_file($1_var_run_t)
|
|
|
|
|
|
|
|
allow $1_t self:capability { kill sys_chroot sys_resource chown dac_override fowner fsetid setgid setuid sys_tty_config };
|
|
|
|
allow $1_t self:fifo_file rw_file_perms;
|
|
|
|
allow $1_t self:process { signal setsched setrlimit setexec };
|
|
|
|
|
|
|
|
allow $1_t self:tcp_socket { listen accept create connect ioctl read getattr write setattr append bind getopt setopt shutdown };
|
|
|
|
allow $1_t self:udp_socket { connect create ioctl read getattr write setattr append bind getopt setopt shutdown };
|
|
|
|
|
|
|
|
allow $1_t $1_devpts_t:chr_file { rw_file_perms setattr getattr relabelfrom };
|
|
|
|
term_create_pty($1_t,$1_devpts_t)
|
|
|
|
|
|
|
|
allow $1_t $1_var_run_t:file create_file_perms;
|
2006-01-13 21:06:49 +00:00
|
|
|
files_filetrans_pid($1_t,$1_var_run_t,file)
|
2005-06-21 21:07:46 +00:00
|
|
|
|
|
|
|
can_exec($1_t, sshd_exec_t)
|
|
|
|
|
|
|
|
# Access key files
|
|
|
|
allow $1_t sshd_key_t:file { getattr read };
|
|
|
|
|
2006-01-31 16:49:43 +00:00
|
|
|
kernel_read_kernel_sysctls($1_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
|
|
|
|
corenet_tcp_sendrecv_all_if($1_t)
|
|
|
|
corenet_udp_sendrecv_all_if($1_t)
|
|
|
|
corenet_raw_sendrecv_all_if($1_t)
|
|
|
|
corenet_tcp_sendrecv_all_nodes($1_t)
|
|
|
|
corenet_udp_sendrecv_all_nodes($1_t)
|
|
|
|
corenet_raw_sendrecv_all_nodes($1_t)
|
|
|
|
corenet_udp_sendrecv_all_ports($1_t)
|
|
|
|
corenet_tcp_sendrecv_all_ports($1_t)
|
2005-12-06 19:59:50 +00:00
|
|
|
corenet_non_ipsec_sendrecv($1_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
corenet_tcp_bind_all_nodes($1_t)
|
|
|
|
corenet_udp_bind_all_nodes($1_t)
|
2005-09-13 13:06:07 +00:00
|
|
|
corenet_tcp_connect_all_ports($1_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
|
|
|
|
dev_read_urand($1_t)
|
|
|
|
|
2005-06-22 21:14:48 +00:00
|
|
|
fs_dontaudit_getattr_all_fs($1_t)
|
|
|
|
|
2005-06-21 21:07:46 +00:00
|
|
|
selinux_get_fs_mount($1_t)
|
|
|
|
selinux_validate_context($1_t)
|
|
|
|
selinux_compute_access_vector($1_t)
|
|
|
|
selinux_compute_create_context($1_t)
|
|
|
|
selinux_compute_relabel_context($1_t)
|
|
|
|
selinux_compute_user_contexts($1_t)
|
|
|
|
|
|
|
|
auth_dontaudit_read_shadow($1_t)
|
|
|
|
auth_domtrans_chk_passwd($1_t)
|
|
|
|
auth_rw_login_records($1_t)
|
|
|
|
auth_rw_lastlog($1_t)
|
2005-09-16 21:20:37 +00:00
|
|
|
auth_append_faillog($1_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
|
2006-02-02 21:08:12 +00:00
|
|
|
corecmd_read_bin_symlinks($1_t)
|
|
|
|
corecmd_getattr_bin_files($1_t)
|
2005-06-27 18:37:33 +00:00
|
|
|
# for sshd subsystems, such as sftp-server.
|
2006-02-02 21:08:12 +00:00
|
|
|
corecmd_getattr_bin_files($1_t)
|
2005-06-27 18:37:33 +00:00
|
|
|
|
2005-06-21 21:07:46 +00:00
|
|
|
domain_wide_inherit_fd($1_t)
|
2006-02-02 21:08:12 +00:00
|
|
|
domain_subj_id_change_exemption($1_t)
|
|
|
|
domain_role_change_exemption($1_t)
|
|
|
|
domain_obj_id_change_exemption($1_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
|
2005-06-29 14:26:41 +00:00
|
|
|
files_read_etc_files($1_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
files_read_etc_runtime_files($1_t)
|
|
|
|
|
2006-01-18 18:08:39 +00:00
|
|
|
init_rw_utmp($1_t)
|
2005-06-21 21:07:46 +00:00
|
|
|
|
|
|
|
libs_use_ld_so($1_t)
|
|
|
|
libs_use_shared_libs($1_t)
|
|
|
|
|
|
|
|
logging_search_logs($1_t)
|
|
|
|
logging_send_syslog_msg($1_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization($1_t)
|
|
|
|
|
2005-09-26 20:26:32 +00:00
|
|
|
mls_file_read_up($1_t)
|
|
|
|
mls_file_write_down($1_t)
|
|
|
|
mls_file_upgrade($1_t)
|
|
|
|
mls_file_downgrade($1_t)
|
|
|
|
mls_process_set_level($1_t)
|
|
|
|
|
2005-06-21 21:07:46 +00:00
|
|
|
seutil_read_default_contexts($1_t)
|
|
|
|
|
|
|
|
sysnet_read_config($1_t)
|
|
|
|
|
2006-02-02 21:08:12 +00:00
|
|
|
userdom_dontaudit_relabelfrom_unpriv_users_ptys($1_t)
|
2005-06-22 21:14:48 +00:00
|
|
|
userdom_search_all_users_home($1_t)
|
|
|
|
|
2005-09-16 13:36:26 +00:00
|
|
|
# Allow checking users mail at login
|
|
|
|
mta_getattr_spool($1_t)
|
|
|
|
|
2005-06-21 21:07:46 +00:00
|
|
|
tunable_policy(`use_nfs_home_dirs',`
|
|
|
|
fs_read_nfs_files($1_t)
|
|
|
|
')
|
|
|
|
|
|
|
|
tunable_policy(`use_samba_home_dirs',`
|
|
|
|
fs_read_cifs_files($1_t)
|
|
|
|
')
|
|
|
|
|
2005-09-21 20:01:40 +00:00
|
|
|
# cjp: commenting out until typeattribute works in conditional
|
|
|
|
# and require block in optional else is resolved
|
2005-11-23 20:24:27 +00:00
|
|
|
#optional_policy(`inetd',`
|
2005-09-21 20:01:40 +00:00
|
|
|
# tunable_policy(`run_ssh_inetd',`
|
|
|
|
# allow $1_t self:process signal;
|
|
|
|
# files_list_pids($1_t)
|
|
|
|
# ',`
|
|
|
|
# corenet_tcp_bind_ssh_port($1_t)
|
|
|
|
# init_use_fd($1_t)
|
2006-02-02 21:08:12 +00:00
|
|
|
# init_use_script_ptys($1_t)
|
2005-09-21 20:01:40 +00:00
|
|
|
# ')
|
|
|
|
#',`
|
2005-06-27 18:37:33 +00:00
|
|
|
# These rules should match the else block
|
|
|
|
# of the run_ssh_inetd tunable directly above
|
|
|
|
corenet_tcp_bind_ssh_port($1_t)
|
|
|
|
init_use_fd($1_t)
|
2006-02-02 21:08:12 +00:00
|
|
|
init_use_script_ptys($1_t)
|
2005-09-21 20:01:40 +00:00
|
|
|
#')
|
2005-06-27 18:37:33 +00:00
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`kerberos',`
|
2005-09-13 13:06:07 +00:00
|
|
|
kerberos_use($1_t)
|
|
|
|
')
|
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`mount',`
|
2005-06-22 21:14:48 +00:00
|
|
|
mount_send_nfs_client_request($1_t)
|
|
|
|
')
|
2005-06-21 21:07:46 +00:00
|
|
|
|
2005-11-23 20:24:27 +00:00
|
|
|
optional_policy(`nscd',`
|
2006-02-02 21:08:12 +00:00
|
|
|
nscd_socket_use($1_t)
|
2005-07-13 20:48:51 +00:00
|
|
|
')
|
2005-06-21 21:07:46 +00:00
|
|
|
')
|
2005-06-22 21:14:48 +00:00
|
|
|
|
2005-06-24 13:36:57 +00:00
|
|
|
########################################
|
2006-01-20 20:10:35 +00:00
|
|
|
## <summary>
|
|
|
|
## Send a SIGCHLD signal to the ssh server.
|
|
|
|
## </summary>
|
|
|
|
## <param name="domain">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2006-01-20 20:10:35 +00:00
|
|
|
## Domain allowed access.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2006-01-20 20:10:35 +00:00
|
|
|
## </param>
|
|
|
|
#
|
|
|
|
interface(`ssh_sigchld',`
|
|
|
|
gen_require(`
|
|
|
|
type sshd_t;
|
|
|
|
')
|
|
|
|
|
|
|
|
allow $1 sshd_t:process sigchld;
|
|
|
|
')
|
|
|
|
|
|
|
|
########################################
|
|
|
|
## <summary>
|
|
|
|
## Read a ssh server unnamed pipe.
|
|
|
|
## </summary>
|
|
|
|
## <param name="domain">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2006-01-20 20:10:35 +00:00
|
|
|
## Domain allowed access.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2006-01-20 20:10:35 +00:00
|
|
|
## </param>
|
|
|
|
#
|
2006-02-02 21:08:12 +00:00
|
|
|
interface(`ssh_read_pipes',`
|
2006-01-20 20:10:35 +00:00
|
|
|
gen_require(`
|
|
|
|
type sshd_t;
|
|
|
|
')
|
|
|
|
|
|
|
|
allow $1 sshd_t:fifo_file { getattr read };
|
|
|
|
')
|
|
|
|
|
|
|
|
########################################
|
|
|
|
## <summary>
|
|
|
|
## Do not audit attempts to read and write
|
|
|
|
## ssh server TCP sockets.
|
|
|
|
## </summary>
|
|
|
|
## <param name="domain">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2006-01-20 20:10:35 +00:00
|
|
|
## Domain to not audit.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2006-01-20 20:10:35 +00:00
|
|
|
## </param>
|
|
|
|
#
|
2006-02-02 21:08:12 +00:00
|
|
|
interface(`ssh_dontaudit_rw_tcp_sockets',`
|
2006-01-20 20:10:35 +00:00
|
|
|
gen_require(`
|
|
|
|
type sshd_t;
|
|
|
|
')
|
|
|
|
|
|
|
|
dontaudit $1 sshd_t:tcp_socket { read write };
|
|
|
|
')
|
|
|
|
|
|
|
|
########################################
|
|
|
|
## <summary>
|
|
|
|
## Read ssh server keys
|
|
|
|
## </summary>
|
2005-06-24 13:36:57 +00:00
|
|
|
## <param name="domain">
|
2006-02-10 18:41:53 +00:00
|
|
|
## <summary>
|
2006-01-20 20:10:35 +00:00
|
|
|
## Domain allowed access.
|
2006-02-10 18:41:53 +00:00
|
|
|
## </summary>
|
2005-06-24 13:36:57 +00:00
|
|
|
## </param>
|
|
|
|
#
|
2005-06-22 21:14:48 +00:00
|
|
|
interface(`ssh_dontaudit_read_server_keys',`
|
|
|
|
gen_require(`
|
|
|
|
type sshd_key_t;
|
|
|
|
')
|
|
|
|
|
|
|
|
dontaudit $1 sshd_key_t:file { getattr read };
|
|
|
|
')
|