]>
Commit | Line | Data |
---|---|---|
0404a390 | 1 | |
d08a3df0 | 2 | policy_module(ssh, 2.1.2) |
0404a390 CP |
3 | |
4 | ######################################## | |
5 | # | |
6 | # Declarations | |
7 | # | |
8 | ||
56e1b3d2 CP |
9 | ## <desc> |
10 | ## <p> | |
11 | ## allow host key based authentication | |
12 | ## </p> | |
13 | ## </desc> | |
0bfccda4 | 14 | gen_tunable(allow_ssh_keysign, false) |
56e1b3d2 CP |
15 | |
16 | ## <desc> | |
17 | ## <p> | |
18 | ## Allow ssh logins as sysadm_r:sysadm_t | |
19 | ## </p> | |
20 | ## </desc> | |
0bfccda4 | 21 | gen_tunable(ssh_sysadm_login, false) |
56e1b3d2 | 22 | |
45239964 | 23 | attribute ssh_server; |
296273a7 | 24 | attribute ssh_agent_type; |
0404a390 | 25 | |
75beb950 | 26 | type ssh_keygen_t; |
0404a390 | 27 | type ssh_keygen_exec_t; |
0bfccda4 | 28 | init_system_domain(ssh_keygen_t, ssh_keygen_exec_t) |
75beb950 | 29 | role system_r types ssh_keygen_t; |
0404a390 | 30 | |
e070dd2d | 31 | type sshd_exec_t; |
fb63d0b5 | 32 | corecmd_executable_file(sshd_exec_t) |
c3812748 | 33 | |
6b19be33 | 34 | ssh_server_template(sshd) |
0bfccda4 | 35 | init_daemon_domain(sshd_t, sshd_exec_t) |
6b19be33 | 36 | |
375c2415 CP |
37 | type sshd_key_t; |
38 | files_type(sshd_key_t) | |
9ccd96df | 39 | |
6b19be33 CP |
40 | type sshd_tmp_t; |
41 | files_tmp_file(sshd_tmp_t) | |
42 | files_poly_parent(sshd_tmp_t) | |
e070dd2d | 43 | |
6b19be33 | 44 | ifdef(`enable_mcs',` |
3f67f722 | 45 | init_ranged_daemon_domain(sshd_t, sshd_exec_t, s0 - mcs_systemhigh) |
375c2415 | 46 | ') |
0404a390 | 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 }; | |
80 | files_type(ssh_home_t) | |
81 | userdom_user_home_content(ssh_home_t) | |
296273a7 CP |
82 | |
83 | ############################## | |
84 | # | |
85 | # SSH client local policy | |
86 | # | |
87 | ||
88 | allow ssh_t self:capability { setuid setgid dac_override dac_read_search }; | |
89 | allow ssh_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap }; | |
90 | allow ssh_t self:fd use; | |
91 | allow ssh_t self:fifo_file rw_fifo_file_perms; | |
92 | allow ssh_t self:unix_dgram_socket { create_socket_perms sendto }; | |
93 | allow ssh_t self:unix_stream_socket { create_stream_socket_perms connectto }; | |
94 | allow ssh_t self:shm create_shm_perms; | |
95 | allow ssh_t self:sem create_sem_perms; | |
96 | allow ssh_t self:msgq create_msgq_perms; | |
97 | allow ssh_t self:msg { send receive }; | |
cde15072 | 98 | allow ssh_t self:tcp_socket create_stream_socket_perms; |
296273a7 CP |
99 | |
100 | # Read the ssh key file. | |
101 | allow ssh_t sshd_key_t:file read_file_perms; | |
102 | ||
103 | # Access the ssh temporary files. | |
104 | allow ssh_t sshd_tmp_t:dir manage_dir_perms; | |
105 | allow ssh_t sshd_tmp_t:file manage_file_perms; | |
106 | files_tmp_filetrans(ssh_t, sshd_tmp_t, { file dir }) | |
107 | ||
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 }) | |
296273a7 CP |
117 | |
118 | # Allow the ssh program to communicate with ssh-agent. | |
119 | stream_connect_pattern(ssh_t, ssh_agent_tmp_t, ssh_agent_tmp_t, ssh_agent_type) | |
120 | ||
121 | allow ssh_t sshd_t:unix_stream_socket connectto; | |
122 | ||
123 | # ssh client can manage the keys and config | |
edc2f7de CP |
124 | manage_files_pattern(ssh_t, ssh_home_t, ssh_home_t) |
125 | read_lnk_files_pattern(ssh_t, ssh_home_t, ssh_home_t) | |
296273a7 CP |
126 | |
127 | # ssh servers can read the user keys and config | |
cde15072 CP |
128 | allow ssh_server ssh_home_t:dir list_dir_perms; |
129 | read_files_pattern(ssh_server, ssh_home_t, ssh_home_t) | |
130 | read_lnk_files_pattern(ssh_server, ssh_home_t, ssh_home_t) | |
296273a7 CP |
131 | |
132 | kernel_read_kernel_sysctls(ssh_t) | |
cde15072 | 133 | kernel_read_system_state(ssh_t) |
296273a7 CP |
134 | |
135 | corenet_all_recvfrom_unlabeled(ssh_t) | |
136 | corenet_all_recvfrom_netlabel(ssh_t) | |
668b3093 | 137 | corenet_tcp_sendrecv_generic_if(ssh_t) |
c1262146 | 138 | corenet_tcp_sendrecv_generic_node(ssh_t) |
296273a7 CP |
139 | corenet_tcp_sendrecv_all_ports(ssh_t) |
140 | corenet_tcp_connect_ssh_port(ssh_t) | |
141 | corenet_sendrecv_ssh_client_packets(ssh_t) | |
142 | ||
143 | dev_read_urand(ssh_t) | |
144 | ||
145 | fs_getattr_all_fs(ssh_t) | |
146 | fs_search_auto_mountpoints(ssh_t) | |
147 | ||
148 | # run helper programs - needed eg for x11-ssh-askpass | |
149 | corecmd_exec_shell(ssh_t) | |
150 | corecmd_exec_bin(ssh_t) | |
151 | ||
152 | domain_use_interactive_fds(ssh_t) | |
153 | ||
154 | files_list_home(ssh_t) | |
155 | files_read_usr_files(ssh_t) | |
156 | files_read_etc_runtime_files(ssh_t) | |
157 | files_read_etc_files(ssh_t) | |
158 | files_read_var_files(ssh_t) | |
159 | ||
160 | logging_send_syslog_msg(ssh_t) | |
161 | logging_read_generic_logs(ssh_t) | |
162 | ||
cde15072 CP |
163 | auth_use_nsswitch(ssh_t) |
164 | ||
296273a7 CP |
165 | miscfiles_read_localization(ssh_t) |
166 | ||
167 | seutil_read_config(ssh_t) | |
168 | ||
296273a7 CP |
169 | userdom_dontaudit_list_user_home_dirs(ssh_t) |
170 | userdom_search_user_home_dirs(ssh_t) | |
171 | # Write to the user domain tty. | |
172 | userdom_use_user_terminals(ssh_t) | |
173 | # needs to read krb tgt | |
174 | userdom_read_user_tmp_files(ssh_t) | |
175 | ||
176 | tunable_policy(`allow_ssh_keysign',` | |
177 | domain_auto_trans(ssh_t, ssh_keysign_exec_t, ssh_keysign_t) | |
178 | allow ssh_keysign_t ssh_t:fd use; | |
179 | allow ssh_keysign_t ssh_t:process sigchld; | |
180 | allow ssh_keysign_t ssh_t:fifo_file rw_file_perms; | |
181 | ') | |
182 | ||
296273a7 CP |
183 | tunable_policy(`use_nfs_home_dirs',` |
184 | fs_manage_nfs_dirs(ssh_t) | |
185 | fs_manage_nfs_files(ssh_t) | |
186 | ') | |
187 | ||
188 | tunable_policy(`use_samba_home_dirs',` | |
189 | fs_manage_cifs_dirs(ssh_t) | |
190 | fs_manage_cifs_files(ssh_t) | |
191 | ') | |
192 | ||
193 | # for port forwarding | |
194 | tunable_policy(`user_tcp_server',` | |
195 | corenet_tcp_bind_ssh_port(ssh_t) | |
cde15072 | 196 | corenet_tcp_bind_generic_node(ssh_t) |
296273a7 CP |
197 | ') |
198 | ||
199 | optional_policy(` | |
200 | xserver_user_x_domain_template(ssh, ssh_t, ssh_tmpfs_t) | |
201 | xserver_domtrans_xauth(ssh_t) | |
202 | ') | |
203 | ||
204 | ######################################## | |
205 | # | |
206 | # ssh_keygen local policy | |
207 | # | |
208 | ||
209 | # ssh_keygen_t is the type of the ssh-keygen program when run at install time | |
210 | # and by sysadm_t | |
211 | ||
212 | dontaudit ssh_keygen_t self:capability sys_tty_config; | |
213 | allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal }; | |
214 | ||
215 | allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms; | |
216 | ||
217 | allow ssh_keygen_t sshd_key_t:file manage_file_perms; | |
218 | files_etc_filetrans(ssh_keygen_t, sshd_key_t, file) | |
219 | ||
220 | kernel_read_kernel_sysctls(ssh_keygen_t) | |
221 | ||
222 | fs_search_auto_mountpoints(ssh_keygen_t) | |
223 | ||
224 | dev_read_sysfs(ssh_keygen_t) | |
225 | dev_read_urand(ssh_keygen_t) | |
226 | ||
227 | term_dontaudit_use_console(ssh_keygen_t) | |
228 | ||
229 | domain_use_interactive_fds(ssh_keygen_t) | |
230 | ||
231 | files_read_etc_files(ssh_keygen_t) | |
232 | ||
233 | init_use_fds(ssh_keygen_t) | |
234 | init_use_script_ptys(ssh_keygen_t) | |
235 | ||
236 | logging_send_syslog_msg(ssh_keygen_t) | |
237 | ||
238 | userdom_dontaudit_use_unpriv_user_fds(ssh_keygen_t) | |
239 | ||
240 | optional_policy(` | |
241 | nscd_socket_use(ssh_keygen_t) | |
242 | ') | |
243 | ||
244 | optional_policy(` | |
245 | seutil_sigchld_newrole(ssh_keygen_t) | |
246 | ') | |
247 | ||
248 | optional_policy(` | |
249 | udev_read_db(ssh_keygen_t) | |
250 | ') | |
251 | ||
252 | ############################## | |
253 | # | |
254 | # ssh_keysign_t local policy | |
255 | # | |
256 | ||
257 | tunable_policy(`allow_ssh_keysign',` | |
258 | allow ssh_keysign_t self:capability { setgid setuid }; | |
259 | allow ssh_keysign_t self:unix_stream_socket create_socket_perms; | |
260 | ||
261 | allow ssh_keysign_t sshd_key_t:file { getattr read }; | |
262 | ||
263 | dev_read_urand(ssh_keysign_t) | |
264 | ||
265 | files_read_etc_files(ssh_keysign_t) | |
266 | ') | |
267 | ||
268 | optional_policy(` | |
269 | tunable_policy(`allow_ssh_keysign',` | |
270 | nscd_socket_use(ssh_keysign_t) | |
271 | ') | |
272 | ') | |
273 | ||
0404a390 CP |
274 | ################################# |
275 | # | |
276 | # sshd local policy | |
277 | # | |
278 | # sshd_t is the domain for the sshd program. | |
279 | # | |
280 | ||
6b19be33 CP |
281 | # so a tunnel can point to another ssh tunnel |
282 | allow sshd_t self:netlink_route_socket r_netlink_socket_perms; | |
283 | allow sshd_t self:key { search link write }; | |
bbdbdb9e | 284 | |
0bfccda4 CP |
285 | manage_dirs_pattern(sshd_t, sshd_tmp_t, sshd_tmp_t) |
286 | manage_files_pattern(sshd_t, sshd_tmp_t, sshd_tmp_t) | |
287 | manage_sock_files_pattern(sshd_t, sshd_tmp_t, sshd_tmp_t) | |
6b19be33 | 288 | files_tmp_filetrans(sshd_t, sshd_tmp_t, { dir file sock_file }) |
44d5d93f | 289 | |
6b19be33 CP |
290 | kernel_search_key(sshd_t) |
291 | kernel_link_key(sshd_t) | |
292 | ||
c3c753f7 CP |
293 | term_use_all_ptys(sshd_t) |
294 | term_setattr_all_ptys(sshd_t) | |
295 | term_relabelto_all_ptys(sshd_t) | |
296273a7 | 296 | |
6b19be33 CP |
297 | # for X forwarding |
298 | corenet_tcp_bind_xserver_port(sshd_t) | |
299 | corenet_sendrecv_xserver_server_packets(sshd_t) | |
300 | ||
6b19be33 CP |
301 | tunable_policy(`ssh_sysadm_login',` |
302 | # Relabel and access ptys created by sshd | |
303 | # ioctl is necessary for logout() processing for utmp entry and for w to | |
304 | # display the tty. | |
305 | # some versions of sshd on the new SE Linux require setattr | |
6b19be33 CP |
306 | userdom_spec_domtrans_all_users(sshd_t) |
307 | userdom_signal_all_users(sshd_t) | |
308 | ',` | |
309 | userdom_spec_domtrans_unpriv_users(sshd_t) | |
310 | userdom_signal_unpriv_users(sshd_t) | |
6b19be33 CP |
311 | ') |
312 | ||
cde15072 CP |
313 | optional_policy(` |
314 | kerberos_keytab_template(sshd, sshd_t) | |
315 | ') | |
316 | ||
6b19be33 CP |
317 | optional_policy(` |
318 | daemontools_service_domain(sshd_t, sshd_exec_t) | |
319 | ') | |
320 | ||
321 | optional_policy(` | |
322 | inetd_tcp_service_domain(sshd_t, sshd_exec_t) | |
323 | ') | |
324 | ||
325 | optional_policy(` | |
326 | rpm_use_script_fds(sshd_t) | |
327 | ') | |
328 | ||
329 | optional_policy(` | |
296273a7 | 330 | rssh_spec_domtrans(sshd_t) |
6b19be33 | 331 | # For reading /home/user/.ssh |
296273a7 | 332 | rssh_read_ro_content(sshd_t) |
6b19be33 CP |
333 | ') |
334 | ||
350b6ab7 CP |
335 | optional_policy(` |
336 | unconfined_domain(sshd_t) | |
337 | unconfined_shell_domtrans(sshd_t) | |
338 | ') | |
339 | ||
6b19be33 CP |
340 | ifdef(`TODO',` |
341 | tunable_policy(`ssh_sysadm_login',` | |
342 | # Relabel and access ptys created by sshd | |
343 | # ioctl is necessary for logout() processing for utmp entry and for w to | |
344 | # display the tty. | |
345 | # some versions of sshd on the new SE Linux require setattr | |
346 | allow sshd_t ptyfile:chr_file relabelto; | |
375c2415 | 347 | |
5540e76a | 348 | optional_policy(` |
6b19be33 | 349 | domain_trans(sshd_t, xauth_exec_t, userdomain) |
5540e76a | 350 | ') |
6b19be33 CP |
351 | ',` |
352 | optional_policy(` | |
353 | domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain) | |
0404a390 | 354 | ') |
6b19be33 CP |
355 | # Relabel and access ptys created by sshd |
356 | # ioctl is necessary for logout() processing for utmp entry and for w to | |
357 | # display the tty. | |
358 | # some versions of sshd on the new SE Linux require setattr | |
359 | allow sshd_t userpty_type:chr_file { relabelto read write getattr ioctl setattr }; | |
9ccd96df | 360 | ') |
6b19be33 | 361 | ') dnl endif TODO |
0404a390 | 362 | |
0404a390 CP |
363 | ######################################## |
364 | # | |
365 | # ssh_keygen local policy | |
366 | # | |
367 | ||
75beb950 CP |
368 | # ssh_keygen_t is the type of the ssh-keygen program when run at install time |
369 | # and by sysadm_t | |
0404a390 | 370 | |
75beb950 CP |
371 | dontaudit ssh_keygen_t self:capability sys_tty_config; |
372 | allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal }; | |
0404a390 | 373 | |
75beb950 | 374 | allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms; |
0404a390 | 375 | |
c0868a7a | 376 | allow ssh_keygen_t sshd_key_t:file manage_file_perms; |
0bfccda4 | 377 | files_etc_filetrans(ssh_keygen_t, sshd_key_t, file) |
0404a390 | 378 | |
75beb950 | 379 | kernel_read_kernel_sysctls(ssh_keygen_t) |
0404a390 | 380 | |
75beb950 | 381 | fs_search_auto_mountpoints(ssh_keygen_t) |
ab940a4c | 382 | |
75beb950 CP |
383 | dev_read_sysfs(ssh_keygen_t) |
384 | dev_read_urand(ssh_keygen_t) | |
0404a390 | 385 | |
75beb950 | 386 | term_dontaudit_use_console(ssh_keygen_t) |
0404a390 | 387 | |
75beb950 | 388 | domain_use_interactive_fds(ssh_keygen_t) |
0404a390 | 389 | |
75beb950 | 390 | files_read_etc_files(ssh_keygen_t) |
0404a390 | 391 | |
75beb950 CP |
392 | init_use_fds(ssh_keygen_t) |
393 | init_use_script_ptys(ssh_keygen_t) | |
0404a390 | 394 | |
cde15072 CP |
395 | auth_use_nsswitch(ssh_keygen_t) |
396 | ||
75beb950 | 397 | logging_send_syslog_msg(ssh_keygen_t) |
0404a390 | 398 | |
75beb950 | 399 | userdom_dontaudit_use_unpriv_user_fds(ssh_keygen_t) |
0404a390 | 400 | |
75beb950 CP |
401 | optional_policy(` |
402 | seutil_sigchld_newrole(ssh_keygen_t) | |
403 | ') | |
404 | ||
405 | optional_policy(` | |
406 | udev_read_db(ssh_keygen_t) | |
c0d1566a | 407 | ') |