]>
Commit | Line | Data |
---|---|---|
29af4c13 | 1 | policy_module(ssh, 2.2.0) |
0404a390 CP |
2 | |
3 | ######################################## | |
4 | # | |
5 | # Declarations | |
6 | # | |
7 | ||
56e1b3d2 | 8 | ## <desc> |
1e2abee1 DG |
9 | ## <p> |
10 | ## allow host key based authentication | |
11 | ## </p> | |
56e1b3d2 | 12 | ## </desc> |
0bfccda4 | 13 | gen_tunable(allow_ssh_keysign, false) |
56e1b3d2 CP |
14 | |
15 | ## <desc> | |
1e2abee1 DG |
16 | ## <p> |
17 | ## Allow ssh logins as sysadm_r:sysadm_t | |
18 | ## </p> | |
56e1b3d2 | 19 | ## </desc> |
0bfccda4 | 20 | gen_tunable(ssh_sysadm_login, false) |
56e1b3d2 | 21 | |
3eaa9939 | 22 | ## <desc> |
1e2abee1 DG |
23 | ## <p> |
24 | ## allow sshd to forward port connections | |
25 | ## </p> | |
3eaa9939 DW |
26 | ## </desc> |
27 | gen_tunable(sshd_forward_ports, false) | |
28 | ||
45239964 | 29 | attribute ssh_server; |
296273a7 | 30 | attribute ssh_agent_type; |
0404a390 | 31 | |
75beb950 | 32 | type ssh_keygen_t; |
0404a390 | 33 | type ssh_keygen_exec_t; |
0bfccda4 | 34 | init_system_domain(ssh_keygen_t, ssh_keygen_exec_t) |
0404a390 | 35 | |
e070dd2d | 36 | type sshd_exec_t; |
fb63d0b5 | 37 | corecmd_executable_file(sshd_exec_t) |
c3812748 | 38 | |
6b19be33 | 39 | ssh_server_template(sshd) |
0bfccda4 | 40 | init_daemon_domain(sshd_t, sshd_exec_t) |
6b19be33 | 41 | |
3eaa9939 DW |
42 | type sshd_initrc_exec_t; |
43 | init_script_file(sshd_initrc_exec_t) | |
44 | ||
375c2415 CP |
45 | type sshd_key_t; |
46 | files_type(sshd_key_t) | |
9ccd96df | 47 | |
296273a7 CP |
48 | type ssh_t; |
49 | type ssh_exec_t; | |
50 | typealias ssh_t alias { user_ssh_t staff_ssh_t sysadm_ssh_t }; | |
51 | typealias ssh_t alias { auditadm_ssh_t secadm_ssh_t }; | |
52 | application_domain(ssh_t, ssh_exec_t) | |
53 | ubac_constrained(ssh_t) | |
54 | ||
55 | type ssh_agent_exec_t; | |
56 | corecmd_executable_file(ssh_agent_exec_t) | |
57 | ||
58 | type ssh_agent_tmp_t; | |
59 | typealias ssh_agent_tmp_t alias { user_ssh_agent_tmp_t staff_ssh_agent_tmp_t sysadm_ssh_agent_tmp_t }; | |
60 | typealias ssh_agent_tmp_t alias { auditadm_ssh_agent_tmp_t secadm_ssh_agent_tmp_t }; | |
61 | files_tmp_file(ssh_agent_tmp_t) | |
62 | ubac_constrained(ssh_agent_tmp_t) | |
63 | ||
64 | type ssh_keysign_t; | |
65 | type ssh_keysign_exec_t; | |
66 | typealias ssh_keysign_t alias { user_ssh_keysign_t staff_ssh_keysign_t sysadm_ssh_keysign_t }; | |
67 | typealias ssh_keysign_t alias { auditadm_ssh_keysign_t secadm_ssh_keysign_t }; | |
68 | application_domain(ssh_keysign_t, ssh_keysign_exec_t) | |
69 | ubac_constrained(ssh_keysign_t) | |
70 | ||
71 | type ssh_tmpfs_t; | |
72 | typealias ssh_tmpfs_t alias { user_ssh_tmpfs_t staff_ssh_tmpfs_t sysadm_ssh_tmpfs_t }; | |
73 | typealias ssh_tmpfs_t alias { auditadm_ssh_tmpfs_t secadm_ssh_tmpfs_t }; | |
74 | files_tmpfs_file(ssh_tmpfs_t) | |
75 | ubac_constrained(ssh_tmpfs_t) | |
76 | ||
cde15072 CP |
77 | type ssh_home_t; |
78 | typealias ssh_home_t alias { home_ssh_t user_ssh_home_t user_home_ssh_t staff_home_ssh_t sysadm_home_ssh_t }; | |
79 | typealias ssh_home_t alias { auditadm_home_ssh_t secadm_home_ssh_t }; | |
cde15072 | 80 | userdom_user_home_content(ssh_home_t) |
8ba1f41a | 81 | files_poly_parent(ssh_home_t) |
296273a7 | 82 | |
4781493e DG |
83 | ifdef(`enable_mcs',` |
84 | init_ranged_daemon_domain(sshd_t, sshd_exec_t, s0 - mcs_systemhigh) | |
85 | ') | |
86 | ||
296273a7 CP |
87 | ############################## |
88 | # | |
89 | # SSH client local policy | |
90 | # | |
91 | ||
92 | allow ssh_t self:capability { setuid setgid dac_override dac_read_search }; | |
93 | allow ssh_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap }; | |
94 | allow ssh_t self:fd use; | |
95 | allow ssh_t self:fifo_file rw_fifo_file_perms; | |
96 | allow ssh_t self:unix_dgram_socket { create_socket_perms sendto }; | |
97 | allow ssh_t self:unix_stream_socket { create_stream_socket_perms connectto }; | |
98 | allow ssh_t self:shm create_shm_perms; | |
99 | allow ssh_t self:sem create_sem_perms; | |
100 | allow ssh_t self:msgq create_msgq_perms; | |
101 | allow ssh_t self:msg { send receive }; | |
cde15072 | 102 | allow ssh_t self:tcp_socket create_stream_socket_perms; |
64607462 | 103 | can_exec(ssh_t, ssh_exec_t) |
296273a7 CP |
104 | |
105 | # Read the ssh key file. | |
106 | allow ssh_t sshd_key_t:file read_file_perms; | |
107 | ||
296273a7 CP |
108 | manage_files_pattern(ssh_t, ssh_tmpfs_t, ssh_tmpfs_t) |
109 | manage_lnk_files_pattern(ssh_t, ssh_tmpfs_t, ssh_tmpfs_t) | |
110 | manage_fifo_files_pattern(ssh_t, ssh_tmpfs_t, ssh_tmpfs_t) | |
111 | manage_sock_files_pattern(ssh_t, ssh_tmpfs_t, ssh_tmpfs_t) | |
cde15072 | 112 | fs_tmpfs_filetrans(ssh_t, ssh_tmpfs_t, { dir file lnk_file sock_file fifo_file }) |
296273a7 | 113 | |
edc2f7de CP |
114 | manage_dirs_pattern(ssh_t, ssh_home_t, ssh_home_t) |
115 | manage_sock_files_pattern(ssh_t, ssh_home_t, ssh_home_t) | |
116 | userdom_user_home_dir_filetrans(ssh_t, ssh_home_t, { dir sock_file }) | |
3eaa9939 | 117 | userdom_stream_connect(ssh_t) |
726d3fd9 | 118 | userdom_search_admin_dir(sshd_t) |
70be862b | 119 | userdom_admin_home_dir_filetrans(ssh_t, ssh_home_t, { dir sock_file }) |
296273a7 CP |
120 | |
121 | # Allow the ssh program to communicate with ssh-agent. | |
122 | stream_connect_pattern(ssh_t, ssh_agent_tmp_t, ssh_agent_tmp_t, ssh_agent_type) | |
123 | ||
124 | allow ssh_t sshd_t:unix_stream_socket connectto; | |
5dd938af | 125 | allow ssh_t sshd_t:peer recv; |
296273a7 CP |
126 | |
127 | # ssh client can manage the keys and config | |
edc2f7de CP |
128 | manage_files_pattern(ssh_t, ssh_home_t, ssh_home_t) |
129 | read_lnk_files_pattern(ssh_t, ssh_home_t, ssh_home_t) | |
296273a7 CP |
130 | |
131 | # ssh servers can read the user keys and config | |
3eaa9939 DW |
132 | manage_dirs_pattern(ssh_server, ssh_home_t, ssh_home_t) |
133 | manage_files_pattern(ssh_server, ssh_home_t, ssh_home_t) | |
134 | userdom_user_home_dir_filetrans(ssh_server, ssh_home_t, dir) | |
135 | userdom_admin_home_dir_filetrans(ssh_server, ssh_home_t, dir) | |
296273a7 CP |
136 | |
137 | kernel_read_kernel_sysctls(ssh_t) | |
cde15072 | 138 | kernel_read_system_state(ssh_t) |
296273a7 CP |
139 | |
140 | corenet_all_recvfrom_unlabeled(ssh_t) | |
141 | corenet_all_recvfrom_netlabel(ssh_t) | |
668b3093 | 142 | corenet_tcp_sendrecv_generic_if(ssh_t) |
c1262146 | 143 | corenet_tcp_sendrecv_generic_node(ssh_t) |
296273a7 CP |
144 | corenet_tcp_sendrecv_all_ports(ssh_t) |
145 | corenet_tcp_connect_ssh_port(ssh_t) | |
146 | corenet_sendrecv_ssh_client_packets(ssh_t) | |
3eaa9939 DW |
147 | corenet_tcp_bind_generic_node(ssh_t) |
148 | corenet_tcp_bind_all_unreserved_ports(ssh_t) | |
296273a7 | 149 | |
8fd700fe | 150 | dev_read_rand(ssh_t) |
296273a7 CP |
151 | dev_read_urand(ssh_t) |
152 | ||
153 | fs_getattr_all_fs(ssh_t) | |
154 | fs_search_auto_mountpoints(ssh_t) | |
155 | ||
156 | # run helper programs - needed eg for x11-ssh-askpass | |
157 | corecmd_exec_shell(ssh_t) | |
158 | corecmd_exec_bin(ssh_t) | |
159 | ||
160 | domain_use_interactive_fds(ssh_t) | |
161 | ||
162 | files_list_home(ssh_t) | |
163 | files_read_usr_files(ssh_t) | |
164 | files_read_etc_runtime_files(ssh_t) | |
165 | files_read_etc_files(ssh_t) | |
166 | files_read_var_files(ssh_t) | |
167 | ||
168 | logging_send_syslog_msg(ssh_t) | |
169 | logging_read_generic_logs(ssh_t) | |
170 | ||
cde15072 CP |
171 | auth_use_nsswitch(ssh_t) |
172 | ||
296273a7 | 173 | miscfiles_read_localization(ssh_t) |
442a14fe | 174 | miscfiles_read_generic_certs(ssh_t) |
296273a7 CP |
175 | |
176 | seutil_read_config(ssh_t) | |
177 | ||
296273a7 CP |
178 | userdom_dontaudit_list_user_home_dirs(ssh_t) |
179 | userdom_search_user_home_dirs(ssh_t) | |
bebaa6a2 | 180 | userdom_search_admin_dir(ssh_t) |
296273a7 CP |
181 | # Write to the user domain tty. |
182 | userdom_use_user_terminals(ssh_t) | |
3eaa9939 | 183 | # needs to read krb/write tgt |
296273a7 | 184 | userdom_read_user_tmp_files(ssh_t) |
3eaa9939 DW |
185 | userdom_write_user_tmp_files(ssh_t) |
186 | userdom_read_user_home_content_symlinks(ssh_t) | |
ded9692e | 187 | userdom_read_home_certs(ssh_t) |
296273a7 CP |
188 | |
189 | tunable_policy(`allow_ssh_keysign',` | |
3c4ffa32 | 190 | domtrans_pattern(ssh_t, ssh_keysign_exec_t, ssh_keysign_t) |
296273a7 CP |
191 | ') |
192 | ||
201582fb DW |
193 | tunable_policy(`use_fusefs_home_dirs',` |
194 | fs_manage_fusefs_dirs(ssh_t) | |
195 | fs_manage_fusefs_files(ssh_t) | |
196 | ') | |
197 | ||
296273a7 CP |
198 | tunable_policy(`use_nfs_home_dirs',` |
199 | fs_manage_nfs_dirs(ssh_t) | |
200 | fs_manage_nfs_files(ssh_t) | |
201 | ') | |
202 | ||
203 | tunable_policy(`use_samba_home_dirs',` | |
204 | fs_manage_cifs_dirs(ssh_t) | |
205 | fs_manage_cifs_files(ssh_t) | |
206 | ') | |
207 | ||
208 | # for port forwarding | |
209 | tunable_policy(`user_tcp_server',` | |
210 | corenet_tcp_bind_ssh_port(ssh_t) | |
cde15072 | 211 | corenet_tcp_bind_generic_node(ssh_t) |
296273a7 CP |
212 | ') |
213 | ||
27608c5b DW |
214 | optional_policy(` |
215 | gnome_stream_connect_all_gkeyringd(ssh_t) | |
216 | ') | |
217 | ||
296273a7 CP |
218 | optional_policy(` |
219 | xserver_user_x_domain_template(ssh, ssh_t, ssh_tmpfs_t) | |
220 | xserver_domtrans_xauth(ssh_t) | |
221 | ') | |
222 | ||
3eaa9939 | 223 | |
296273a7 CP |
224 | ############################## |
225 | # | |
226 | # ssh_keysign_t local policy | |
227 | # | |
228 | ||
229 | tunable_policy(`allow_ssh_keysign',` | |
230 | allow ssh_keysign_t self:capability { setgid setuid }; | |
231 | allow ssh_keysign_t self:unix_stream_socket create_socket_perms; | |
232 | ||
7d1f5642 | 233 | allow ssh_keysign_t sshd_key_t:file read_file_perms; |
296273a7 | 234 | |
8fd700fe | 235 | dev_read_rand(ssh_keysign_t) |
296273a7 CP |
236 | dev_read_urand(ssh_keysign_t) |
237 | ||
238 | files_read_etc_files(ssh_keysign_t) | |
239 | ') | |
240 | ||
241 | optional_policy(` | |
242 | tunable_policy(`allow_ssh_keysign',` | |
243 | nscd_socket_use(ssh_keysign_t) | |
244 | ') | |
245 | ') | |
246 | ||
0404a390 CP |
247 | ################################# |
248 | # | |
249 | # sshd local policy | |
250 | # | |
251 | # sshd_t is the domain for the sshd program. | |
252 | # | |
253 | ||
6b19be33 CP |
254 | # so a tunnel can point to another ssh tunnel |
255 | allow sshd_t self:netlink_route_socket r_netlink_socket_perms; | |
256 | allow sshd_t self:key { search link write }; | |
3eaa9939 | 257 | allow sshd_t self:process setcurrent; |
44d5d93f | 258 | |
6b19be33 CP |
259 | kernel_search_key(sshd_t) |
260 | kernel_link_key(sshd_t) | |
261 | ||
c3c753f7 CP |
262 | term_use_all_ptys(sshd_t) |
263 | term_setattr_all_ptys(sshd_t) | |
3eaa9939 | 264 | term_setattr_all_ttys(sshd_t) |
c3c753f7 | 265 | term_relabelto_all_ptys(sshd_t) |
3eaa9939 | 266 | term_use_ptmx(sshd_t) |
296273a7 | 267 | |
6b19be33 CP |
268 | # for X forwarding |
269 | corenet_tcp_bind_xserver_port(sshd_t) | |
270 | corenet_sendrecv_xserver_server_packets(sshd_t) | |
271 | ||
3eaa9939 DW |
272 | userdom_read_user_home_content_files(sshd_t) |
273 | userdom_read_user_home_content_symlinks(sshd_t) | |
3eaa9939 | 274 | userdom_manage_tmp_role(system_r, sshd_t) |
4781493e DG |
275 | userdom_spec_domtrans_unpriv_users(sshd_t) |
276 | userdom_signal_unpriv_users(sshd_t) | |
277 | ||
278 | tunable_policy(`sshd_forward_ports',` | |
279 | corenet_tcp_bind_all_unreserved_ports(sshd_t) | |
280 | corenet_tcp_connect_all_ports(sshd_t) | |
281 | ') | |
3eaa9939 | 282 | |
6b19be33 CP |
283 | tunable_policy(`ssh_sysadm_login',` |
284 | # Relabel and access ptys created by sshd | |
285 | # ioctl is necessary for logout() processing for utmp entry and for w to | |
286 | # display the tty. | |
287 | # some versions of sshd on the new SE Linux require setattr | |
6b19be33 | 288 | userdom_signal_all_users(sshd_t) |
6b19be33 CP |
289 | ') |
290 | ||
57ce3836 | 291 | optional_policy(` |
5a1cc7f0 | 292 | amanda_search_var_lib(sshd_t) |
57ce3836 DW |
293 | ') |
294 | ||
cde15072 | 295 | optional_policy(` |
088b65e5 | 296 | daemontools_service_domain(sshd_t, sshd_exec_t) |
cde15072 CP |
297 | ') |
298 | ||
3eaa9939 DW |
299 | optional_policy(` |
300 | kerberos_keytab_template(sshd, sshd_t) | |
301 | ') | |
302 | ||
303 | optional_policy(` | |
304 | ftp_dyntrans_sftpd(sshd_t) | |
305 | ftp_dyntrans_anon_sftpd(sshd_t) | |
306 | ') | |
307 | ||
308 | optional_policy(` | |
309 | gitosis_manage_lib_files(sshd_t) | |
310 | ') | |
311 | ||
6b19be33 | 312 | optional_policy(` |
088b65e5 | 313 | inetd_tcp_service_domain(sshd_t, sshd_exec_t) |
6b19be33 CP |
314 | ') |
315 | ||
316 | optional_policy(` | |
3eaa9939 | 317 | nx_read_home_files(sshd_t) |
6b19be33 CP |
318 | ') |
319 | ||
320 | optional_policy(` | |
321 | rpm_use_script_fds(sshd_t) | |
322 | ') | |
323 | ||
324 | optional_policy(` | |
296273a7 | 325 | rssh_spec_domtrans(sshd_t) |
6b19be33 | 326 | # For reading /home/user/.ssh |
296273a7 | 327 | rssh_read_ro_content(sshd_t) |
6b19be33 CP |
328 | ') |
329 | ||
3eaa9939 DW |
330 | optional_policy(` |
331 | usermanage_domtrans_passwd(sshd_t) | |
332 | usermanage_read_crack_db(sshd_t) | |
333 | ') | |
334 | ||
350b6ab7 | 335 | optional_policy(` |
350b6ab7 CP |
336 | unconfined_shell_domtrans(sshd_t) |
337 | ') | |
338 | ||
088b65e5 CP |
339 | optional_policy(` |
340 | xserver_domtrans_xauth(sshd_t) | |
341 | ') | |
342 | ||
6b19be33 | 343 | ifdef(`TODO',` |
1e2abee1 DG |
344 | tunable_policy(`ssh_sysadm_login',` |
345 | # Relabel and access ptys created by sshd | |
346 | # ioctl is necessary for logout() processing for utmp entry and for w to | |
347 | # display the tty. | |
348 | # some versions of sshd on the new SE Linux require setattr | |
349 | allow sshd_t ptyfile:chr_file relabelto; | |
350 | ||
351 | optional_policy(` | |
352 | domain_trans(sshd_t, xauth_exec_t, userdomain) | |
353 | ') | |
354 | ',` | |
355 | optional_policy(` | |
356 | domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain) | |
357 | ') | |
358 | # Relabel and access ptys created by sshd | |
359 | # ioctl is necessary for logout() processing for utmp entry and for w to | |
360 | # display the tty. | |
361 | # some versions of sshd on the new SE Linux require setattr | |
7d1f5642 | 362 | allow sshd_t userpty_type:chr_file { relabelto rw_inherited_chr_file_perms setattr_chr_file_perms }; |
5540e76a | 363 | ') |
6b19be33 | 364 | ') dnl endif TODO |
0404a390 | 365 | |
0404a390 CP |
366 | ######################################## |
367 | # | |
368 | # ssh_keygen local policy | |
369 | # | |
370 | ||
75beb950 CP |
371 | # ssh_keygen_t is the type of the ssh-keygen program when run at install time |
372 | # and by sysadm_t | |
0404a390 | 373 | |
3e23c54b | 374 | allow ssh_keygen_t self:capability dac_override; |
75beb950 CP |
375 | dontaudit ssh_keygen_t self:capability sys_tty_config; |
376 | allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal }; | |
75beb950 | 377 | allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms; |
0404a390 | 378 | |
c0868a7a | 379 | allow ssh_keygen_t sshd_key_t:file manage_file_perms; |
0bfccda4 | 380 | files_etc_filetrans(ssh_keygen_t, sshd_key_t, file) |
0404a390 | 381 | |
58c3d0e9 MG |
382 | manage_dirs_pattern(ssh_keygen_t, ssh_home_t, ssh_home_t) |
383 | manage_files_pattern(ssh_keygen_t, ssh_home_t, ssh_home_t) | |
384 | userdom_admin_home_dir_filetrans(ssh_keygen_t, ssh_home_t, dir) | |
092a35ee | 385 | userdom_user_home_dir_filetrans(ssh_keygen_t, ssh_home_t, dir) |
58c3d0e9 | 386 | |
75beb950 | 387 | kernel_read_kernel_sysctls(ssh_keygen_t) |
0404a390 | 388 | |
75beb950 | 389 | fs_search_auto_mountpoints(ssh_keygen_t) |
ab940a4c | 390 | |
75beb950 | 391 | dev_read_sysfs(ssh_keygen_t) |
b76a6a16 | 392 | dev_read_rand(ssh_keygen_t) |
75beb950 | 393 | dev_read_urand(ssh_keygen_t) |
0404a390 | 394 | |
75beb950 | 395 | term_dontaudit_use_console(ssh_keygen_t) |
0404a390 | 396 | |
75beb950 | 397 | domain_use_interactive_fds(ssh_keygen_t) |
0404a390 | 398 | |
75beb950 | 399 | files_read_etc_files(ssh_keygen_t) |
0404a390 | 400 | |
75beb950 CP |
401 | init_use_fds(ssh_keygen_t) |
402 | init_use_script_ptys(ssh_keygen_t) | |
0404a390 | 403 | |
cde15072 CP |
404 | auth_use_nsswitch(ssh_keygen_t) |
405 | ||
75beb950 | 406 | logging_send_syslog_msg(ssh_keygen_t) |
0404a390 | 407 | |
75beb950 | 408 | userdom_dontaudit_use_unpriv_user_fds(ssh_keygen_t) |
0404a390 | 409 | |
58c3d0e9 MG |
410 | optional_policy(` |
411 | nscd_socket_use(ssh_keygen_t) | |
412 | ') | |
413 | ||
75beb950 CP |
414 | optional_policy(` |
415 | seutil_sigchld_newrole(ssh_keygen_t) | |
416 | ') | |
417 | ||
418 | optional_policy(` | |
419 | udev_read_db(ssh_keygen_t) | |
c0d1566a | 420 | ') |