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