|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
policy_module(ssh,1.0)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
########################################
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
# Declarations
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
452399 |
attribute ssh_server;
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# Type for the ssh-agent executable.
|
|
Chris PeBenito |
0404a3 |
type ssh_agent_exec_t;
|
|
Chris PeBenito |
0404a3 |
files_file_type(ssh_agent_exec_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# ssh client executable.
|
|
Chris PeBenito |
0404a3 |
type ssh_exec_t;
|
|
Chris PeBenito |
0404a3 |
files_file_type(ssh_exec_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
type ssh_keygen_t;
|
|
Chris PeBenito |
0404a3 |
type ssh_keygen_exec_t;
|
|
Chris PeBenito |
0404a3 |
init_daemon_domain(ssh_keygen_t,ssh_keygen_exec_t)
|
|
Chris PeBenito |
0404a3 |
role system_r types ssh_keygen_t;
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
9ccd96 |
sshd_program_domain(sshd)
|
|
Chris PeBenito |
9ccd96 |
|
|
Chris PeBenito |
0404a3 |
type sshd_exec_t;
|
|
Chris PeBenito |
0404a3 |
files_file_type(sshd_exec_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
9ccd96 |
sshd_program_domain(sshd_extern)
|
|
Chris PeBenito |
9ccd96 |
|
|
Chris PeBenito |
0404a3 |
type sshd_key_t;
|
|
Chris PeBenito |
0404a3 |
files_file_type(sshd_key_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
type sshd_tmp_t;
|
|
Chris PeBenito |
0404a3 |
files_tmp_file(sshd_tmp_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
#################################
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
# sshd local policy
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
# sshd_t is the domain for the sshd program.
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
9ccd96 |
# so a tunnel can point to another ssh tunnel
|
|
Chris PeBenito |
9ccd96 |
allow sshd_t self:tcp_socket { acceptfrom connectto recvfrom };
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
allow sshd_t sshd_tmp_t:dir create_dir_perms;
|
|
Chris PeBenito |
0404a3 |
allow sshd_t sshd_tmp_t:file create_file_perms;
|
|
Chris PeBenito |
0404a3 |
allow sshd_t sshd_tmp_t:sock_file create_file_perms;
|
|
Chris PeBenito |
0404a3 |
files_create_tmp_files(sshd_t, sshd_tmp_t, { dir file sock_file })
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# for X forwarding
|
|
Chris PeBenito |
0404a3 |
corenet_tcp_bind_xserver_port(sshd_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
auth_exec_pam(sshd_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
seutil_read_config(sshd_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
9ccd96 |
# Allow checking users mail at login
|
|
Chris PeBenito |
9ccd96 |
mta_getattr_spool(sshd_t)
|
|
Chris PeBenito |
9ccd96 |
|
|
Chris PeBenito |
9ccd96 |
optional_policy(`inetd.te',`
|
|
Chris PeBenito |
9ccd96 |
tunable_policy(`run_ssh_inetd',`
|
|
Chris PeBenito |
9ccd96 |
inetd_service_domain(sshd_t,sshd_exec_t)
|
|
Chris PeBenito |
9ccd96 |
',`
|
|
Chris PeBenito |
9ccd96 |
init_daemon_domain(sshd_t,sshd_exec_t)
|
|
Chris PeBenito |
9ccd96 |
')
|
|
Chris PeBenito |
9ccd96 |
',`
|
|
Chris PeBenito |
9ccd96 |
# These rules should match the else block
|
|
Chris PeBenito |
9ccd96 |
# of the run_ssh_inetd tunable directly above
|
|
Chris PeBenito |
9ccd96 |
init_daemon_domain(sshd_t,sshd_exec_t)
|
|
Chris PeBenito |
9ccd96 |
')
|
|
Chris PeBenito |
9ccd96 |
|
|
Chris PeBenito |
0404a3 |
ifdef(`TODO',`
|
|
Chris PeBenito |
9ccd96 |
tunable_policy(`ssh_sysadm_login',`
|
|
Chris PeBenito |
0404a3 |
userdom_spec_domtrans_all_users(sshd_t)
|
|
Chris PeBenito |
0404a3 |
userdom_signal_all_users(sshd_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
9ccd96 |
optional_policy(`xauth.te',`
|
|
Chris PeBenito |
0404a3 |
domain_trans(sshd_t, xauth_exec_t, userdomain)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
# Relabel and access ptys created by sshd
|
|
Chris PeBenito |
0404a3 |
# ioctl is necessary for logout() processing for utmp entry and for w to
|
|
Chris PeBenito |
0404a3 |
# display the tty.
|
|
Chris PeBenito |
0404a3 |
# some versions of sshd on the new SE Linux require setattr
|
|
Chris PeBenito |
0404a3 |
allow sshd_t ptyfile:chr_file { relabelto read write getattr ioctl setattr };
|
|
Chris PeBenito |
0404a3 |
# inheriting stream sockets is needed for "ssh host command" as no pty
|
|
Chris PeBenito |
0404a3 |
# is allocated
|
|
Chris PeBenito |
0404a3 |
allow userdomain sshd_t:unix_stream_socket rw_stream_socket_perms;
|
|
Chris PeBenito |
9ccd96 |
',`
|
|
Chris PeBenito |
0404a3 |
userdom_spec_domtrans_unpriv_users(sshd_t)
|
|
Chris PeBenito |
0404a3 |
userdom_signal_unpriv_users(sshd_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
9ccd96 |
optional_policy(`xauth.te',`
|
|
Chris PeBenito |
0404a3 |
domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
# Relabel and access ptys created by sshd
|
|
Chris PeBenito |
0404a3 |
# ioctl is necessary for logout() processing for utmp entry and for w to
|
|
Chris PeBenito |
0404a3 |
# display the tty.
|
|
Chris PeBenito |
0404a3 |
# some versions of sshd on the new SE Linux require setattr
|
|
Chris PeBenito |
0404a3 |
allow sshd_t userpty_type:chr_file { relabelto read write getattr ioctl setattr };
|
|
Chris PeBenito |
0404a3 |
# inheriting stream sockets is needed for "ssh host command" as no pty
|
|
Chris PeBenito |
0404a3 |
# is allocated
|
|
Chris PeBenito |
0404a3 |
allow userdomain sshd_t:unix_stream_socket rw_stream_socket_perms;
|
|
Chris PeBenito |
9ccd96 |
')
|
|
Chris PeBenito |
9ccd96 |
|
|
Chris PeBenito |
9ccd96 |
# this goes to inetd
|
|
Chris PeBenito |
9ccd96 |
tunable_policy(`run_ssh_inetd',`
|
|
Chris PeBenito |
9ccd96 |
corenet_tcp_bind_ssh_port(inetd_t)
|
|
Chris PeBenito |
9ccd96 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# for when the network connection breaks after running newrole -r sysadm_r
|
|
Chris PeBenito |
0404a3 |
dontaudit sshd_t sysadm_devpts_t:chr_file setattr;
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
') dnl endif TODO
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
#################################
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
# sshd_extern local policy
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
# sshd_extern_t is the domain for ssh from outside our network
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
9ccd96 |
ifdef(`TODO',`
|
|
Chris PeBenito |
0404a3 |
domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain)
|
|
Chris PeBenito |
0404a3 |
# Signal the user domains.
|
|
Chris PeBenito |
0404a3 |
allow sshd_extern_t user_mini_domain:process signal;
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
ifdef(`xauth.te', `
|
|
Chris PeBenito |
0404a3 |
domain_trans(sshd_extern_t, xauth_exec_t, user_mini_domain)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# Relabel and access ptys created by sshd
|
|
Chris PeBenito |
0404a3 |
# ioctl is necessary for logout() processing for utmp entry and for w to
|
|
Chris PeBenito |
0404a3 |
# display the tty.
|
|
Chris PeBenito |
0404a3 |
# some versions of sshd on the new SE Linux require setattr
|
|
Chris PeBenito |
0404a3 |
allow sshd_extern_t user_mini_domain:chr_file { relabelto read write getattr ioctl setattr };
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# inheriting stream sockets is needed for "ssh host command" as no pty
|
|
Chris PeBenito |
0404a3 |
# is allocated
|
|
Chris PeBenito |
0404a3 |
allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms;
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
optional_policy(`inetd.te',`
|
|
Chris PeBenito |
9ccd96 |
tunable_policy(`run_ssh_inetd',`
|
|
Chris PeBenito |
0404a3 |
domain_trans(inetd_t, sshd_exec_t, sshd_extern_t)
|
|
Chris PeBenito |
9ccd96 |
',`
|
|
Chris PeBenito |
0404a3 |
domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
|
|
Chris PeBenito |
9ccd96 |
')
|
|
Chris PeBenito |
0404a3 |
',`
|
|
Chris PeBenito |
0404a3 |
# These rules should match the else block
|
|
Chris PeBenito |
9ccd96 |
# of the run_ssh_inetd tunable directly above
|
|
Chris PeBenito |
0404a3 |
domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
ifdef(`direct_sysadm_daemon', `
|
|
Chris PeBenito |
0404a3 |
# Direct execution by sysadm_r.
|
|
Chris PeBenito |
0404a3 |
domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t)
|
|
Chris PeBenito |
0404a3 |
role_transition sysadm_r sshd_exec_t system_r;
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# so a tunnel can point to another ssh tunnel...
|
|
Chris PeBenito |
0404a3 |
allow sshd_t kernel_t:tcp_socket recvfrom;
|
|
Chris PeBenito |
0404a3 |
allow sshd_t kernel_t:tcp_socket recvfrom;
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# for port forwarding
|
|
Chris PeBenito |
0404a3 |
allow userdomain sshd_t:tcp_socket { connectto recvfrom };
|
|
Chris PeBenito |
0404a3 |
allow sshd_t userdomain:tcp_socket { acceptfrom recvfrom };
|
|
Chris PeBenito |
0404a3 |
allow userdomain kernel_t:tcp_socket recvfrom;
|
|
Chris PeBenito |
0404a3 |
allow sshd_t kernel_t:tcp_socket recvfrom;
|
|
Chris PeBenito |
0404a3 |
') dnl endif TODO
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
########################################
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
# ssh_keygen local policy
|
|
Chris PeBenito |
0404a3 |
#
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
# ssh_keygen_t is the type of the ssh-keygen program when run at install time
|
|
Chris PeBenito |
0404a3 |
# and by sysadm_t
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
dontaudit ssh_keygen_t self:capability sys_tty_config;
|
|
Chris PeBenito |
0404a3 |
allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal };
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
allow ssh_keygen_t sshd_key_t:file create_file_perms;
|
|
Chris PeBenito |
0404a3 |
files_create_etc_config(ssh_keygen_t,sshd_key_t,file)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
kernel_read_kernel_sysctl(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
dev_read_sysfs(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
dev_read_urand(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
term_dontaudit_use_console(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
domain_use_wide_inherit_fd(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
files_read_generic_etc_files(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
init_use_fd(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
init_use_script_pty(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
libs_use_ld_so(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
libs_use_shared_libs(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
logging_send_syslog_msg(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
allow ssh_keygen_t proc_t:dir r_dir_perms;
|
|
Chris PeBenito |
0404a3 |
allow ssh_keygen_t proc_t:lnk_file read;
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
userdom_use_sysadm_tty(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
userdom_dontaudit_use_unpriv_user_fd(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
ifdef(`direct_sysadm_daemon',`
|
|
Chris PeBenito |
0404a3 |
userdom_dontaudit_use_sysadm_terms(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
ifdef(`targeted_policy', `
|
|
Chris PeBenito |
0404a3 |
term_dontaudit_use_unallocated_tty(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
term_dontaudit_use_generic_pty(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
files_dontaudit_read_root_file(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
optional_policy(`rhgb.te', `
|
|
Chris PeBenito |
0404a3 |
rhgb_domain(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
optional_policy(`selinux.te',`
|
|
Chris PeBenito |
0404a3 |
seutil_newrole_sigchld(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
optional_policy(`udev.te', `
|
|
Chris PeBenito |
0404a3 |
udev_read_db(ssh_keygen_t)
|
|
Chris PeBenito |
0404a3 |
')
|
|
Chris PeBenito |
0404a3 |
|
|
Chris PeBenito |
0404a3 |
ifdef(`TODO',`
|
|
Chris PeBenito |
0404a3 |
allow ssh_keygen_t autofs_t:dir { search getattr };
|
|
Chris PeBenito |
0404a3 |
')
|