]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - refpolicy/policy/modules/services/ssh.te
more updates
[people/stevee/selinux-policy.git] / refpolicy / policy / modules / services / ssh.te
CommitLineData
0404a390
CP
1
2policy_module(ssh,1.0)
3
4########################################
5#
6# Declarations
7#
8
45239964 9attribute ssh_server;
0404a390
CP
10
11# Type for the ssh-agent executable.
12type ssh_agent_exec_t;
8fd36732 13files_type(ssh_agent_exec_t)
0404a390
CP
14
15# ssh client executable.
16type ssh_exec_t;
8fd36732 17files_type(ssh_exec_t)
0404a390
CP
18
19type ssh_keygen_t;
20type ssh_keygen_exec_t;
e5f80603 21init_system_domain(ssh_keygen_t,ssh_keygen_exec_t)
0404a390
CP
22role system_r types ssh_keygen_t;
23
8fd36732 24ssh_server_template(sshd)
9ccd96df 25
c0d1566a 26# cjp: commenting this out until typeattribute works in a conditional
0fdf3ef7 27#optional_policy(`inetd.te',`
80436b9b 28# tunable_policy(`run_ssh_inetd',`
9ff30033 29# inetd_tcp_service_domain(sshd_t,sshd_exec_t)
80436b9b 30# ',`
0fdf3ef7 31# init_daemon_domain(sshd_t,sshd_exec_t)
80436b9b 32# ')
0fdf3ef7 33#',`
80436b9b
CP
34 # These rules should match the else block
35 # of the run_ssh_inetd tunable directly above
36 init_daemon_domain(sshd_t,sshd_exec_t)
0fdf3ef7 37#')
80436b9b 38
0404a390 39type sshd_exec_t;
8fd36732 40files_type(sshd_exec_t)
0404a390 41
8fd36732 42ssh_server_template(sshd_extern)
9ccd96df 43
0404a390 44type sshd_key_t;
8fd36732 45files_type(sshd_key_t)
0404a390
CP
46
47type sshd_tmp_t;
48files_tmp_file(sshd_tmp_t)
49
50#################################
51#
52# sshd local policy
53#
54# sshd_t is the domain for the sshd program.
55#
56
9ccd96df
CP
57# so a tunnel can point to another ssh tunnel
58allow sshd_t self:tcp_socket { acceptfrom connectto recvfrom };
0404a390
CP
59
60allow sshd_t sshd_tmp_t:dir create_dir_perms;
61allow sshd_t sshd_tmp_t:file create_file_perms;
62allow sshd_t sshd_tmp_t:sock_file create_file_perms;
63files_create_tmp_files(sshd_t, sshd_tmp_t, { dir file sock_file })
64
65# for X forwarding
66corenet_tcp_bind_xserver_port(sshd_t)
67
68auth_exec_pam(sshd_t)
69
70seutil_read_config(sshd_t)
71
9ccd96df
CP
72# Allow checking users mail at login
73mta_getattr_spool(sshd_t)
74
e5590ea5
CP
75tunable_policy(`ssh_sysadm_login',`
76 # Relabel and access ptys created by sshd
77 # ioctl is necessary for logout() processing for utmp entry and for w to
78 # display the tty.
79 # some versions of sshd on the new SE Linux require setattr
e5590ea5
CP
80 term_use_all_user_ptys(sshd_t)
81 term_setattr_all_user_ptys(sshd_t)
82 term_relabelto_all_user_ptys(sshd_t)
83
84 userdom_spec_domtrans_all_users(sshd_t)
85 userdom_signal_all_users(sshd_t)
86',`
87 userdom_spec_domtrans_unpriv_users(sshd_t)
88 userdom_signal_unpriv_users(sshd_t)
89')
90
df00b2e2
CP
91optional_policy(`rpm.te',`
92 rpm_use_script_fd(sshd_t)
93')
94
0404a390 95ifdef(`TODO',`
9ccd96df 96tunable_policy(`ssh_sysadm_login',`
bbdbdb9e
CP
97 # Relabel and access ptys created by sshd
98 # ioctl is necessary for logout() processing for utmp entry and for w to
99 # display the tty.
100 # some versions of sshd on the new SE Linux require setattr
101 allow sshd_t ptyfile:chr_file relabelto;
102
9ccd96df 103 optional_policy(`xauth.te',`
0404a390
CP
104 domain_trans(sshd_t, xauth_exec_t, userdomain)
105 ')
9ccd96df 106',`
9ccd96df 107 optional_policy(`xauth.te',`
0404a390
CP
108 domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain)
109 ')
110 # Relabel and access ptys created by sshd
111 # ioctl is necessary for logout() processing for utmp entry and for w to
112 # display the tty.
113 # some versions of sshd on the new SE Linux require setattr
114 allow sshd_t userpty_type:chr_file { relabelto read write getattr ioctl setattr };
9ccd96df 115')
0404a390
CP
116') dnl endif TODO
117
118#################################
119#
120# sshd_extern local policy
121#
122# sshd_extern_t is the domain for ssh from outside our network
123#
0404a390 124
9ccd96df 125ifdef(`TODO',`
0404a390
CP
126domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain)
127# Signal the user domains.
128allow sshd_extern_t user_mini_domain:process signal;
129
130ifdef(`xauth.te', `
131domain_trans(sshd_extern_t, xauth_exec_t, user_mini_domain)
132')
133
134# Relabel and access ptys created by sshd
135# ioctl is necessary for logout() processing for utmp entry and for w to
136# display the tty.
137# some versions of sshd on the new SE Linux require setattr
138allow sshd_extern_t user_mini_domain:chr_file { relabelto read write getattr ioctl setattr };
139
140# inheriting stream sockets is needed for "ssh host command" as no pty
141# is allocated
142allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms;
143
144optional_policy(`inetd.te',`
9ccd96df 145 tunable_policy(`run_ssh_inetd',`
0404a390 146 domain_trans(inetd_t, sshd_exec_t, sshd_extern_t)
9ccd96df 147 ',`
0404a390 148 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
9ccd96df 149 ')
0404a390
CP
150',`
151 # These rules should match the else block
9ccd96df 152 # of the run_ssh_inetd tunable directly above
0404a390 153 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
0404a390
CP
154')
155
156ifdef(`direct_sysadm_daemon', `
157# Direct execution by sysadm_r.
158domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t)
159role_transition sysadm_r sshd_exec_t system_r;
160')
161
0404a390
CP
162# for port forwarding
163allow userdomain sshd_t:tcp_socket { connectto recvfrom };
164allow sshd_t userdomain:tcp_socket { acceptfrom recvfrom };
165allow userdomain kernel_t:tcp_socket recvfrom;
166allow sshd_t kernel_t:tcp_socket recvfrom;
167') dnl endif TODO
168
169########################################
170#
171# ssh_keygen local policy
172#
173
174# ssh_keygen_t is the type of the ssh-keygen program when run at install time
175# and by sysadm_t
176
177dontaudit ssh_keygen_t self:capability sys_tty_config;
178allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal };
179
180allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
181
182allow ssh_keygen_t sshd_key_t:file create_file_perms;
183files_create_etc_config(ssh_keygen_t,sshd_key_t,file)
184
185kernel_read_kernel_sysctl(ssh_keygen_t)
186
ab940a4c
CP
187fs_search_auto_mountpoints(ssh_keygen_t)
188
0404a390
CP
189dev_read_sysfs(ssh_keygen_t)
190dev_read_urand(ssh_keygen_t)
191
192term_dontaudit_use_console(ssh_keygen_t)
193
194domain_use_wide_inherit_fd(ssh_keygen_t)
195
8fd36732 196files_read_etc_files(ssh_keygen_t)
0404a390
CP
197
198init_use_fd(ssh_keygen_t)
199init_use_script_pty(ssh_keygen_t)
200
201libs_use_ld_so(ssh_keygen_t)
202libs_use_shared_libs(ssh_keygen_t)
203
204logging_send_syslog_msg(ssh_keygen_t)
205
206allow ssh_keygen_t proc_t:dir r_dir_perms;
207allow ssh_keygen_t proc_t:lnk_file read;
208
209userdom_use_sysadm_tty(ssh_keygen_t)
210userdom_dontaudit_use_unpriv_user_fd(ssh_keygen_t)
211
e5f80603
CP
212# cjp: with the old daemon_(base_)domain being broken up into
213# a daemon and system interface, this probably is not needed:
0404a390
CP
214ifdef(`direct_sysadm_daemon',`
215 userdom_dontaudit_use_sysadm_terms(ssh_keygen_t)
216')
217
218ifdef(`targeted_policy', `
219 term_dontaudit_use_unallocated_tty(ssh_keygen_t)
220 term_dontaudit_use_generic_pty(ssh_keygen_t)
221 files_dontaudit_read_root_file(ssh_keygen_t)
222')
223
ae9e2716 224optional_policy(`selinuxutil.te',`
8fd36732 225 seutil_sigchld_newrole(ssh_keygen_t)
0404a390
CP
226')
227
228optional_policy(`udev.te', `
229 udev_read_db(ssh_keygen_t)
230')
c0d1566a
CP
231
232ifdef(`TODO',`
233optional_policy(`rhgb.te', `
234 rhgb_domain(ssh_keygen_t)
235')
236')