Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Macros for ssh agent
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author:  Thomas Bleher <ThomasBleher@gmx.de>
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# ssh_agent_domain(domain_prefix)
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-agent.te. 
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`ssh_agent_domain',`
Chris PeBenito ab58ad
# Define a derived domain for the ssh-agent program when executed
Chris PeBenito ab58ad
# by a user domain.
Chris PeBenito ab58ad
# Derived domain based on the calling user domain and the program.
Chris PeBenito ab58ad
type $1_ssh_agent_t, domain, privlog;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Transition from the user domain to the derived domain.
Chris PeBenito ab58ad
domain_auto_trans($1_t, ssh_agent_exec_t, $1_ssh_agent_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# The user role is authorized for this domain.
Chris PeBenito ab58ad
role $1_r types $1_ssh_agent_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_ssh_agent_t privfd:fd use;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write to the user domain tty.
Chris PeBenito ab58ad
access_terminal($1_ssh_agent_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_agent_t:process signal;
Chris PeBenito ab58ad
# allow ps to show ssh
Chris PeBenito ab58ad
can_ps($1_t, $1_ssh_agent_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_ypbind($1_ssh_agent_t)
Chris PeBenito ab58ad
if (use_nfs_home_dirs) {
Chris PeBenito ab58ad
allow $1_ssh_agent_t autofs_t:dir { search getattr };
Chris PeBenito ab58ad
rw_dir_create_file($1_ssh_agent_t, nfs_t)
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
if (use_samba_home_dirs) {
Chris PeBenito ab58ad
rw_dir_create_file($1_ssh_agent_t, cifs_t)
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
Chris PeBenito ab58ad
uses_shlib($1_ssh_agent_t)
Chris PeBenito ab58ad
read_locale($1_ssh_agent_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_ssh_agent_t proc_t:dir search;
Chris PeBenito ab58ad
dontaudit $1_ssh_agent_t proc_t:{ lnk_file file } { getattr read };
Chris PeBenito ab58ad
dontaudit $1_ssh_agent_t selinux_config_t:dir search;
Chris PeBenito ab58ad
dontaudit $1_ssh_agent_t selinux_config_t:file { read getattr };
Chris PeBenito ab58ad
read_sysctl($1_ssh_agent_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access the ssh temporary files. Should we have an own type here
Chris PeBenito ab58ad
# to which only ssh, ssh-agent and ssh-add have access?
Chris PeBenito ab58ad
allow $1_ssh_agent_t $1_tmp_t:dir r_dir_perms;
Chris PeBenito ab58ad
file_type_auto_trans($1_ssh_agent_t, tmp_t, $1_tmp_t)
Chris PeBenito ab58ad
allow $1_ssh_agent_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
allow $1_ssh_agent_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_ssh_agent_t self:process { fork sigchld setrlimit };
Chris PeBenito ab58ad
allow $1_ssh_agent_t self:capability setgid;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# access the random devices
Chris PeBenito ab58ad
allow $1_ssh_agent_t { random_device_t urandom_device_t }:chr_file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for ssh-add
Chris PeBenito ab58ad
can_unix_connect($1_t, $1_ssh_agent_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# transition back to normal privs upon exec
Chris PeBenito ab58ad
domain_auto_trans($1_ssh_agent_t, { bin_t shell_exec_t $1_home_t }, $1_t)
Chris PeBenito ab58ad
if (use_nfs_home_dirs) {
Chris PeBenito ab58ad
domain_auto_trans($1_ssh_agent_t, nfs_t, $1_t)
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
if (use_samba_home_dirs) {
Chris PeBenito ab58ad
domain_auto_trans($1_ssh_agent_t, cifs_t, $1_t)
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
allow $1_ssh_agent_t bin_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# allow reading of /usr/bin/X11 (is a symlink)
Chris PeBenito ab58ad
allow $1_ssh_agent_t bin_t:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_ssh_agent_t { $1_ssh_agent_t $1_t }:process signull;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_ssh_agent_t { home_root_t $1_home_dir_t }:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_ssh_t $1_tmp_t:sock_file write;
Chris PeBenito ab58ad
allow $1_ssh_t $1_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
allow $1_ssh_t $1_ssh_agent_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`xdm.te', `
Chris PeBenito ab58ad
can_pipe_xdm($1_ssh_agent_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# kdm: sigchld
Chris PeBenito ab58ad
allow $1_ssh_agent_t xdm_t:process sigchld;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Allow command to ssh-agent > ~/.ssh_agent
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow $1_ssh_agent_t $1_home_t:file rw_file_perms;
Chris PeBenito ab58ad
allow $1_ssh_agent_t $1_tmp_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_ssh_agent_t etc_runtime_t:file { getattr read };
Chris PeBenito ab58ad
allow $1_ssh_agent_t etc_t:file { getattr read };
Chris PeBenito ab58ad
allow $1_ssh_agent_t lib_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_ssh_agent_t self:dir search;
Chris PeBenito ab58ad
allow $1_ssh_agent_t self:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow the ssh program to communicate with ssh-agent.
Chris PeBenito ab58ad
allow $1_ssh_t $1_tmp_t:sock_file write;
Chris PeBenito ab58ad
allow $1_ssh_t $1_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
allow $1_ssh_t sshd_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
')dnl end if ssh_agent
Chris PeBenito ab58ad