|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Macros for ssh domains.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Authors: Stephen Smalley <sds@epoch.ncsc.mil>
|
|
Chris PeBenito |
ab58ad |
# Russell Coker <russell@coker.com.au>
|
|
Chris PeBenito |
ab58ad |
# Thomas Bleher <ThomasBleher@gmx.de>
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# ssh_domain(domain_prefix)
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Define a derived domain for the ssh program when executed
|
|
Chris PeBenito |
ab58ad |
# by a user domain.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# The type declaration for the executable type for this program is
|
|
Chris PeBenito |
ab58ad |
# provided separately in domains/program/ssh.te.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
undefine(`ssh_domain')
|
|
Chris PeBenito |
ab58ad |
ifdef(`ssh.te', `
|
|
Chris PeBenito |
ab58ad |
define(`ssh_domain',`
|
|
Chris PeBenito |
ab58ad |
# Derived domain based on the calling user domain and the program.
|
|
Chris PeBenito |
ab58ad |
type $1_ssh_t, domain, privlog, nscd_client_domain;
|
|
Chris PeBenito |
ab58ad |
type $1_home_ssh_t, file_type, $1_file_type, sysadmfile;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t autofs_t:dir { search getattr };
|
|
Chris PeBenito |
ab58ad |
if (use_nfs_home_dirs) {
|
|
Chris PeBenito |
ab58ad |
create_dir_file($1_ssh_t, nfs_t)
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
if (use_samba_home_dirs) {
|
|
Chris PeBenito |
ab58ad |
create_dir_file($1_ssh_t, cifs_t)
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Transition from the user domain to the derived domain.
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans($1_t, ssh_exec_t, $1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# The user role is authorized for this domain.
|
|
Chris PeBenito |
ab58ad |
role $1_r types $1_ssh_t;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Grant permissions within the domain.
|
|
Chris PeBenito |
ab58ad |
general_domain_access($1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Use descriptors created by sshd
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t privfd:fd use;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
uses_shlib($1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
read_locale($1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Get attributes of file systems.
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t fs_type:filesystem getattr;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
base_file_read_access($1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read /var.
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1_ssh_t, var_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read /var/run, /var/log.
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t var_run_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t var_run_t:{ file lnk_file } r_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t var_log_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t var_log_t:{ file lnk_file } r_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read /etc.
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1_ssh_t, etc_t)
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t etc_runtime_t:{ file lnk_file } r_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read /dev directories and any symbolic links.
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t device_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t device_t:lnk_file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read /dev/urandom.
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t urandom_device_t:chr_file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read and write /dev/null.
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t { null_device_t zero_device_t }:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Grant permissions needed to create TCP and UDP sockets and
|
|
Chris PeBenito |
ab58ad |
# to access the network.
|
|
Chris PeBenito |
ab58ad |
can_network_client_tcp($1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t ssh_port_t:tcp_socket name_connect;
|
|
Chris PeBenito |
ab58ad |
can_resolve($1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
can_ypbind($1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
can_kerberos($1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for port forwarding
|
|
Chris PeBenito |
ab58ad |
if (user_tcp_server) {
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t port_t:tcp_socket name_bind;
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Use capabilities.
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t self:capability { setuid setgid dac_override dac_read_search };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# run helper programs - needed eg for x11-ssh-askpass
|
|
Chris PeBenito |
ab58ad |
can_exec($1_ssh_t, { shell_exec_t bin_t })
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Read the ssh key file.
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t sshd_key_t:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Access the ssh temporary files.
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_ssh_t, tmp_t, sshd_tmp_t)
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t $1_tmp_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for rsync
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t $1_t:unix_stream_socket rw_socket_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Access the users .ssh directory.
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans({ sysadm_ssh_t $1_ssh_t }, $1_home_dir_t, $1_home_ssh_t, dir)
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_ssh_t, $1_home_dir_t, $1_home_ssh_t, sock_file)
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_home_ssh_t:sock_file create_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow { sysadm_ssh_t $1_ssh_t } $1_home_ssh_t:file create_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow { sysadm_ssh_t $1_ssh_t } $1_home_ssh_t:lnk_file { getattr read };
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_ssh_t $1_home_t:dir { getattr search };
|
|
Chris PeBenito |
ab58ad |
r_dir_file({ sshd_t sshd_extern_t }, $1_home_ssh_t)
|
|
Chris PeBenito |
ab58ad |
rw_dir_create_file($1_t, $1_home_ssh_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for /bin/sh used to execute xauth
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_ssh_t proc_t:dir search;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_ssh_t proc_t:{ lnk_file file } { getattr read };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Inherit and use descriptors from gnome-pty-helper.
|
|
Chris PeBenito |
ab58ad |
ifdef(`gnome-pty-helper.te', `allow $1_ssh_t $1_gph_t:fd use;')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Write to the user domain tty.
|
|
Chris PeBenito |
ab58ad |
access_terminal($1_ssh_t, $1)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Allow the user shell to signal the ssh program.
|
|
Chris PeBenito |
ab58ad |
allow $1_t $1_ssh_t:process signal;
|
|
Chris PeBenito |
ab58ad |
# allow ps to show ssh
|
|
Chris PeBenito |
ab58ad |
can_ps($1_t, $1_ssh_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Connect to X server
|
|
Chris PeBenito |
ab58ad |
x_client_domain($1_ssh, $1)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifdef(`ssh-agent.te', `
|
|
Chris PeBenito |
ab58ad |
ssh_agent_domain($1)
|
|
Chris PeBenito |
ab58ad |
')dnl end if ssh_agent.te
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#allow ssh to access keys stored on removable media
|
|
Chris PeBenito |
ab58ad |
# Should we have a boolean around this?
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_t mnt_t:dir search;
|
|
Chris PeBenito |
ab58ad |
r_dir_file($1_ssh_t, removable_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
type $1_ssh_keysign_t, domain, nscd_client_domain;
|
|
Chris PeBenito |
ab58ad |
role $1_r types $1_ssh_keysign_t;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
if (allow_ssh_keysign) {
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans($1_ssh_t, ssh_keysign_exec_t, $1_ssh_keysign_t)
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_keysign_t sshd_key_t:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_keysign_t self:capability { setgid setuid };
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_keysign_t urandom_device_t:chr_file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
uses_shlib($1_ssh_keysign_t)
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_ssh_keysign_t selinux_config_t:dir search;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_ssh_keysign_t proc_t:dir search;
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_ssh_keysign_t proc_t:{ lnk_file file } { getattr read };
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_keysign_t usr_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_keysign_t etc_t:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_keysign_t self:dir search;
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_keysign_t self:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
allow $1_ssh_keysign_t self:unix_stream_socket create_socket_perms;
|
|
Chris PeBenito |
ab58ad |
}
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')dnl end macro definition
|
|
Chris PeBenito |
ab58ad |
', `
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
define(`ssh_domain',`')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
')dnl end if ssh.te
|