selinux-policy/refpolicy/policy/modules/services/ssh.te

270 lines
6.9 KiB
Plaintext
Raw Normal View History

2005-06-21 21:07:46 +00:00
2006-05-09 15:12:17 +00:00
policy_module(ssh,1.3.3)
2005-06-21 21:07:46 +00:00
########################################
#
# Declarations
#
2005-06-23 19:57:15 +00:00
attribute ssh_server;
2005-06-21 21:07:46 +00:00
# ssh client executable.
type ssh_exec_t;
corecmd_executable_file(ssh_exec_t)
2005-06-21 21:07:46 +00:00
type ssh_keygen_exec_t;
corecmd_executable_file(ssh_keygen_exec_t)
2005-06-21 21:07:46 +00:00
2005-09-16 13:36:26 +00:00
type ssh_keysign_exec_t;
2006-05-09 15:24:11 +00:00
corecmd_executable_file(ssh_keysign_exec_t)
2005-09-16 13:36:26 +00:00
2005-10-18 15:07:11 +00:00
# real declaration moved to mls until
# range_transition works in loadable modules
gen_require(`
type sshd_exec_t;
')
corecmd_executable_file(sshd_exec_t)
2005-10-18 15:07:11 +00:00
2005-10-28 18:13:44 +00:00
type sshd_key_t;
files_type(sshd_key_t)
2005-10-28 18:13:44 +00:00
ifdef(`targeted_policy',`
unconfined_alias_domain(sshd_t)
init_system_domain(sshd_t,sshd_exec_t)
2005-10-28 18:38:04 +00:00
type sshd_var_run_t;
files_type(sshd_var_run_t)
2005-10-28 18:13:44 +00:00
',`
# Type for the ssh-agent executable.
type ssh_agent_exec_t;
files_type(ssh_agent_exec_t)
type ssh_keygen_t;
init_system_domain(ssh_keygen_t,ssh_keygen_exec_t)
role system_r types ssh_keygen_t;
ssh_server_template(sshd)
ssh_server_template(sshd_extern)
# cjp: commenting this out until typeattribute works in a conditional
# optional_policy(`
2005-10-28 18:13:44 +00:00
# tunable_policy(`run_ssh_inetd',`
# inetd_tcp_service_domain(sshd_t,sshd_exec_t)
# ',`
# init_daemon_domain(sshd_t,sshd_exec_t)
# ')
2005-06-27 18:37:33 +00:00
# ',`
2005-10-28 18:13:44 +00:00
# These rules should match the else block
# of the run_ssh_inetd tunable directly above
init_daemon_domain(sshd_t,sshd_exec_t)
2005-06-27 18:37:33 +00:00
# ')
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
type sshd_tmp_t;
files_tmp_file(sshd_tmp_t)
')
2005-06-21 21:07:46 +00:00
#################################
#
# sshd local policy
#
# sshd_t is the domain for the sshd program.
#
2006-04-25 19:17:43 +00:00
ifdef(`strict_policy',`
2005-10-28 18:13:44 +00:00
# so a tunnel can point to another ssh tunnel
allow sshd_t self:tcp_socket { acceptfrom connectto recvfrom };
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
allow sshd_t sshd_tmp_t:dir create_dir_perms;
allow sshd_t sshd_tmp_t:file create_file_perms;
allow sshd_t sshd_tmp_t:sock_file create_file_perms;
2006-02-21 18:40:44 +00:00
files_tmp_filetrans(sshd_t, sshd_tmp_t, { dir file sock_file })
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
# for X forwarding
corenet_tcp_bind_xserver_port(sshd_t)
2005-06-21 21:07:46 +00:00
2006-01-06 22:51:40 +00:00
mls_file_read_up(sshd_t)
mls_file_write_down(sshd_t)
mls_file_upgrade(sshd_t)
mls_file_downgrade(sshd_t)
mls_process_set_level(sshd_t)
2005-10-28 18:13:44 +00:00
auth_exec_pam(sshd_t)
2005-07-28 20:52:55 +00:00
2005-10-28 18:13:44 +00:00
seutil_read_config(sshd_t)
2005-07-28 20:52:55 +00:00
2005-10-28 18:13:44 +00:00
tunable_policy(`ssh_sysadm_login',`
# Relabel and access ptys created by sshd
# ioctl is necessary for logout() processing for utmp entry and for w to
# display the tty.
# some versions of sshd on the new SE Linux require setattr
term_use_all_user_ptys(sshd_t)
term_setattr_all_user_ptys(sshd_t)
term_relabelto_all_user_ptys(sshd_t)
userdom_spec_domtrans_all_users(sshd_t)
userdom_signal_all_users(sshd_t)
',`
userdom_spec_domtrans_unpriv_users(sshd_t)
userdom_signal_unpriv_users(sshd_t)
2006-01-20 22:41:54 +00:00
2006-02-20 21:33:25 +00:00
userdom_setattr_unpriv_users_ptys(sshd_t)
userdom_relabelto_unpriv_users_ptys(sshd_t)
2006-02-02 21:08:12 +00:00
userdom_use_unpriv_users_ptys(sshd_t)
2005-10-28 18:13:44 +00:00
')
2005-07-29 15:07:15 +00:00
optional_policy(`
daemontools_service_domain(sshd_t, sshd_exec_t)
')
optional_policy(`
2006-02-20 21:33:25 +00:00
rpm_use_script_fds(sshd_t)
2005-06-21 21:07:46 +00:00
')
2005-10-28 18:13:44 +00:00
2006-04-25 19:17:43 +00:00
optional_policy(`
rssh_spec_domtrans_all_users(sshd_t)
# For reading /home/user/.ssh
rssh_read_all_users_ro_content(sshd_t)
')
2005-10-28 18:13:44 +00:00
ifdef(`TODO',`
tunable_policy(`ssh_sysadm_login',`
# Relabel and access ptys created by sshd
# ioctl is necessary for logout() processing for utmp entry and for w to
# display the tty.
# some versions of sshd on the new SE Linux require setattr
allow sshd_t ptyfile:chr_file relabelto;
optional_policy(`
2005-10-28 18:13:44 +00:00
domain_trans(sshd_t, xauth_exec_t, userdomain)
')
',`
optional_policy(`
2005-10-28 18:13:44 +00:00
domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain)
')
# Relabel and access ptys created by sshd
# ioctl is necessary for logout() processing for utmp entry and for w to
# display the tty.
# some versions of sshd on the new SE Linux require setattr
allow sshd_t userpty_type:chr_file { relabelto read write getattr ioctl setattr };
2005-06-21 21:07:46 +00:00
')
2005-10-28 18:13:44 +00:00
') dnl endif TODO
')
2005-06-21 21:07:46 +00:00
#################################
#
# sshd_extern local policy
#
# sshd_extern_t is the domain for ssh from outside our network
#
2006-04-25 19:17:43 +00:00
ifdef(`strict_policy',`
2005-10-28 18:13:44 +00:00
ifdef(`TODO',`
domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain)
# Signal the user domains.
allow sshd_extern_t user_mini_domain:process signal;
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
ifdef(`xauth.te', `
domain_trans(sshd_extern_t, xauth_exec_t, user_mini_domain)
')
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
# Relabel and access ptys created by sshd
# ioctl is necessary for logout() processing for utmp entry and for w to
# display the tty.
# some versions of sshd on the new SE Linux require setattr
allow sshd_extern_t user_mini_domain:chr_file { relabelto read write getattr ioctl setattr };
# inheriting stream sockets is needed for "ssh host command" as no pty
# is allocated
allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms;
optional_policy(`
2005-10-28 18:13:44 +00:00
tunable_policy(`run_ssh_inetd',`
domain_trans(inetd_t, sshd_exec_t, sshd_extern_t)
',`
domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
')
',`
2005-10-28 18:13:44 +00:00
# These rules should match the else block
# of the run_ssh_inetd tunable directly above
2005-06-21 21:07:46 +00:00
domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
')
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
ifdef(`direct_sysadm_daemon', `
# Direct execution by sysadm_r.
domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t)
role_transition sysadm_r sshd_exec_t system_r;
')
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
# for port forwarding
allow userdomain sshd_t:tcp_socket { connectto recvfrom };
allow sshd_t userdomain:tcp_socket { acceptfrom recvfrom };
allow userdomain kernel_t:tcp_socket recvfrom;
allow sshd_t kernel_t:tcp_socket recvfrom;
') dnl endif TODO
')
2005-06-21 21:07:46 +00:00
########################################
#
# ssh_keygen local policy
#
2005-10-28 18:13:44 +00:00
ifdef(`targeted_policy',`',`
# ssh_keygen_t is the type of the ssh-keygen program when run at install time
# and by sysadm_t
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
dontaudit ssh_keygen_t self:capability sys_tty_config;
allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal };
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
allow ssh_keygen_t sshd_key_t:file create_file_perms;
2006-02-21 18:40:44 +00:00
files_etc_filetrans(ssh_keygen_t,sshd_key_t,file)
2005-06-21 21:07:46 +00:00
kernel_read_kernel_sysctls(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
fs_search_auto_mountpoints(ssh_keygen_t)
2005-06-27 16:30:55 +00:00
2005-10-28 18:13:44 +00:00
dev_read_sysfs(ssh_keygen_t)
dev_read_urand(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
term_dontaudit_use_console(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
2006-02-20 21:33:25 +00:00
domain_use_interactive_fds(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
files_read_etc_files(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
init_use_fds(ssh_keygen_t)
2006-02-02 21:08:12 +00:00
init_use_script_ptys(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
libs_use_ld_so(ssh_keygen_t)
libs_use_shared_libs(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
logging_send_syslog_msg(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
allow ssh_keygen_t proc_t:dir r_dir_perms;
allow ssh_keygen_t proc_t:lnk_file read;
2005-06-21 21:07:46 +00:00
2006-02-02 21:08:12 +00:00
userdom_use_sysadm_ttys(ssh_keygen_t)
2006-02-20 21:33:25 +00:00
userdom_dontaudit_use_unpriv_user_fds(ssh_keygen_t)
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
# cjp: with the old daemon_(base_)domain being broken up into
# a daemon and system interface, this probably is not needed:
ifdef(`direct_sysadm_daemon',`
userdom_dontaudit_use_sysadm_terms(ssh_keygen_t)
')
2005-06-21 21:07:46 +00:00
2005-10-28 18:13:44 +00:00
ifdef(`targeted_policy', `
2006-02-02 21:08:12 +00:00
term_dontaudit_use_unallocated_ttys(ssh_keygen_t)
term_dontaudit_use_generic_ptys(ssh_keygen_t)
files_dontaudit_read_root_files(ssh_keygen_t)
2005-10-28 18:13:44 +00:00
')
2005-06-21 21:07:46 +00:00
optional_policy(`
2005-10-28 18:13:44 +00:00
seutil_sigchld_newrole(ssh_keygen_t)
')
2005-06-21 21:07:46 +00:00
optional_policy(`
2005-10-28 18:13:44 +00:00
udev_read_db(ssh_keygen_t)
')
')