]> git.ipfire.org Git - people/stevee/selinux-policy.git/blob - policy/modules/system/ipsec.te
Bump module versions for release.
[people/stevee/selinux-policy.git] / policy / modules / system / ipsec.te
1
2 policy_module(ipsec, 1.11.0)
3
4 ########################################
5 #
6 # Declarations
7 #
8
9 ## <desc>
10 ## <p>
11 ## Allow racoon to read shadow
12 ## </p>
13 ## </desc>
14 gen_tunable(racoon_read_shadow, false)
15
16 type ipsec_t;
17 type ipsec_exec_t;
18 init_daemon_domain(ipsec_t, ipsec_exec_t)
19 role system_r types ipsec_t;
20
21 # type for ipsec configuration file(s) - not for keys
22 type ipsec_conf_file_t;
23 files_type(ipsec_conf_file_t)
24
25 type ipsec_initrc_exec_t;
26 init_script_file(ipsec_initrc_exec_t)
27
28 # type for file(s) containing ipsec keys - RSA or preshared
29 type ipsec_key_file_t;
30 files_type(ipsec_key_file_t)
31
32 type ipsec_log_t;
33 logging_log_file(ipsec_log_t)
34
35 # Default type for IPSEC SPD entries
36 type ipsec_spd_t;
37
38 type ipsec_tmp_t;
39 files_tmp_file(ipsec_tmp_t)
40
41 # type for runtime files, including pluto.ctl
42 type ipsec_var_run_t;
43 files_pid_file(ipsec_var_run_t)
44
45 type ipsec_mgmt_t;
46 type ipsec_mgmt_exec_t;
47 init_system_domain(ipsec_mgmt_t, ipsec_mgmt_exec_t)
48 corecmd_shell_entry_type(ipsec_mgmt_t)
49 role system_r types ipsec_mgmt_t;
50
51 type ipsec_mgmt_lock_t;
52 files_lock_file(ipsec_mgmt_lock_t)
53
54 type ipsec_mgmt_var_run_t;
55 files_pid_file(ipsec_mgmt_var_run_t)
56
57 type racoon_t;
58 type racoon_exec_t;
59 init_daemon_domain(racoon_t, racoon_exec_t)
60 role system_r types racoon_t;
61
62 type racoon_tmp_t;
63 files_tmp_file(racoon_tmp_t)
64
65 type setkey_t;
66 type setkey_exec_t;
67 init_system_domain(setkey_t, setkey_exec_t)
68 role system_r types setkey_t;
69
70 ########################################
71 #
72 # ipsec Local policy
73 #
74
75 allow ipsec_t self:capability { net_admin dac_override dac_read_search setpcap sys_nice };
76 dontaudit ipsec_t self:capability sys_tty_config;
77 allow ipsec_t self:process { getcap setcap getsched signal setsched };
78 allow ipsec_t self:tcp_socket create_stream_socket_perms;
79 allow ipsec_t self:udp_socket create_socket_perms;
80 allow ipsec_t self:key_socket create_socket_perms;
81 allow ipsec_t self:fifo_file read_fifo_file_perms;
82 allow ipsec_t self:netlink_xfrm_socket { create_netlink_socket_perms nlmsg_write };
83
84 allow ipsec_t ipsec_initrc_exec_t:file read_file_perms;
85
86 allow ipsec_t ipsec_conf_file_t:dir list_dir_perms;
87 read_files_pattern(ipsec_t, ipsec_conf_file_t, ipsec_conf_file_t)
88 read_lnk_files_pattern(ipsec_t, ipsec_conf_file_t, ipsec_conf_file_t)
89
90 allow ipsec_t ipsec_key_file_t:dir list_dir_perms;
91 manage_files_pattern(ipsec_t, ipsec_key_file_t, ipsec_key_file_t)
92 read_lnk_files_pattern(ipsec_t, ipsec_key_file_t, ipsec_key_file_t)
93
94 manage_dirs_pattern(ipsec_t, ipsec_tmp_t, ipsec_tmp_t)
95 manage_files_pattern(ipsec_t, ipsec_tmp_t, ipsec_tmp_t)
96 files_tmp_filetrans(ipsec_t, ipsec_tmp_t, { dir file })
97
98 manage_files_pattern(ipsec_t, ipsec_var_run_t, ipsec_var_run_t)
99 manage_sock_files_pattern(ipsec_t, ipsec_var_run_t, ipsec_var_run_t)
100 files_pid_filetrans(ipsec_t, ipsec_var_run_t, { file sock_file })
101
102 can_exec(ipsec_t, ipsec_mgmt_exec_t)
103
104 # pluto runs an updown script (by calling popen()!) as this is by default
105 # a shell script, we need to find a way to make things work without
106 # letting all sorts of stuff possibly be run...
107 # so try flipping back into the ipsec_mgmt_t domain
108 corecmd_shell_domtrans(ipsec_t, ipsec_mgmt_t)
109 allow ipsec_mgmt_t ipsec_t:fd use;
110 allow ipsec_mgmt_t ipsec_t:fifo_file rw_fifo_file_perms;
111 dontaudit ipsec_mgmt_t ipsec_t:unix_stream_socket { read write };
112 allow ipsec_mgmt_t ipsec_t:process sigchld;
113
114 kernel_read_kernel_sysctls(ipsec_t)
115 kernel_list_proc(ipsec_t)
116 kernel_read_proc_symlinks(ipsec_t)
117 # allow pluto to access /proc/net/ipsec_eroute;
118 kernel_read_system_state(ipsec_t)
119 kernel_read_network_state(ipsec_t)
120 kernel_read_software_raid_state(ipsec_t)
121 kernel_request_load_module(ipsec_t)
122 kernel_getattr_core_if(ipsec_t)
123 kernel_getattr_message_if(ipsec_t)
124
125 corecmd_exec_shell(ipsec_t)
126 corecmd_exec_bin(ipsec_t)
127
128 # Pluto needs network access
129 corenet_all_recvfrom_unlabeled(ipsec_t)
130 corenet_tcp_sendrecv_all_if(ipsec_t)
131 corenet_raw_sendrecv_all_if(ipsec_t)
132 corenet_tcp_sendrecv_all_nodes(ipsec_t)
133 corenet_raw_sendrecv_all_nodes(ipsec_t)
134 corenet_tcp_sendrecv_all_ports(ipsec_t)
135 corenet_tcp_bind_all_nodes(ipsec_t)
136 corenet_udp_bind_all_nodes(ipsec_t)
137 corenet_tcp_bind_reserved_port(ipsec_t)
138 corenet_tcp_bind_isakmp_port(ipsec_t)
139 corenet_udp_bind_isakmp_port(ipsec_t)
140 corenet_udp_bind_ipsecnat_port(ipsec_t)
141 corenet_sendrecv_generic_server_packets(ipsec_t)
142 corenet_sendrecv_isakmp_server_packets(ipsec_t)
143
144 dev_read_sysfs(ipsec_t)
145 dev_read_rand(ipsec_t)
146 dev_read_urand(ipsec_t)
147
148 domain_use_interactive_fds(ipsec_t)
149
150 files_list_tmp(ipsec_t)
151 files_read_etc_files(ipsec_t)
152 files_read_usr_files(ipsec_t)
153
154 fs_getattr_all_fs(ipsec_t)
155 fs_search_auto_mountpoints(ipsec_t)
156
157 term_use_console(ipsec_t)
158 term_dontaudit_use_all_ttys(ipsec_t)
159
160 auth_use_nsswitch(ipsec_t)
161
162 init_use_fds(ipsec_t)
163 init_use_script_ptys(ipsec_t)
164
165 logging_send_syslog_msg(ipsec_t)
166
167 miscfiles_read_localization(ipsec_t)
168
169 sysnet_domtrans_ifconfig(ipsec_t)
170
171 userdom_dontaudit_use_unpriv_user_fds(ipsec_t)
172 userdom_dontaudit_search_user_home_dirs(ipsec_t)
173
174 optional_policy(`
175 seutil_sigchld_newrole(ipsec_t)
176 ')
177
178 optional_policy(`
179 udev_read_db(ipsec_t)
180 ')
181
182 ########################################
183 #
184 # ipsec_mgmt Local policy
185 #
186
187 allow ipsec_mgmt_t self:capability { dac_override dac_read_search net_admin setpcap sys_nice };
188 dontaudit ipsec_mgmt_t self:capability sys_tty_config;
189 allow ipsec_mgmt_t self:process { getsched ptrace setrlimit signal };
190 allow ipsec_mgmt_t self:unix_stream_socket create_stream_socket_perms;
191 allow ipsec_mgmt_t self:tcp_socket create_stream_socket_perms;
192 allow ipsec_mgmt_t self:udp_socket create_socket_perms;
193 allow ipsec_mgmt_t self:key_socket create_socket_perms;
194 allow ipsec_mgmt_t self:fifo_file rw_fifo_file_perms;
195
196 allow ipsec_mgmt_t ipsec_mgmt_lock_t:file manage_file_perms;
197 files_lock_filetrans(ipsec_mgmt_t, ipsec_mgmt_lock_t, file)
198
199 manage_dirs_pattern(ipsec_mgmt_t, ipsec_tmp_t, ipsec_tmp_t)
200 manage_files_pattern(ipsec_mgmt_t, ipsec_tmp_t, ipsec_tmp_t)
201 files_tmp_filetrans(ipsec_mgmt_t, ipsec_tmp_t, { dir file })
202
203 manage_files_pattern(ipsec_mgmt_t, ipsec_log_t, ipsec_log_t)
204 logging_log_filetrans(ipsec_mgmt_t, ipsec_log_t, file)
205
206 allow ipsec_mgmt_t ipsec_mgmt_var_run_t:file manage_file_perms;
207 files_pid_filetrans(ipsec_mgmt_t, ipsec_mgmt_var_run_t, file)
208
209 manage_files_pattern(ipsec_mgmt_t, ipsec_var_run_t, ipsec_var_run_t)
210 manage_lnk_files_pattern(ipsec_mgmt_t, ipsec_var_run_t, ipsec_var_run_t)
211
212 allow ipsec_mgmt_t ipsec_var_run_t:sock_file manage_sock_file_perms;
213 files_pid_filetrans(ipsec_mgmt_t, ipsec_var_run_t, sock_file)
214
215 # _realsetup needs to be able to cat /var/run/pluto.pid,
216 # run ps on that pid, and delete the file
217 read_files_pattern(ipsec_mgmt_t, ipsec_t, ipsec_t)
218 read_lnk_files_pattern(ipsec_mgmt_t, ipsec_t, ipsec_t)
219
220 # logger, running in ipsec_mgmt_t needs to use sockets
221 allow ipsec_mgmt_t self:unix_dgram_socket { create connect write };
222 allow ipsec_mgmt_t ipsec_t:unix_dgram_socket { create connect write };
223
224 allow ipsec_mgmt_t ipsec_conf_file_t:file read_file_perms;
225
226 manage_files_pattern(ipsec_mgmt_t, ipsec_key_file_t, ipsec_key_file_t)
227 manage_lnk_files_pattern(ipsec_mgmt_t, ipsec_key_file_t, ipsec_key_file_t)
228 files_etc_filetrans(ipsec_mgmt_t, ipsec_key_file_t, file)
229
230 # whack needs to connect to pluto
231 stream_connect_pattern(ipsec_mgmt_t, ipsec_var_run_t, ipsec_var_run_t, ipsec_t)
232
233 can_exec(ipsec_mgmt_t, ipsec_mgmt_exec_t)
234 allow ipsec_mgmt_t ipsec_mgmt_exec_t:lnk_file read;
235
236 domtrans_pattern(ipsec_mgmt_t, ipsec_exec_t, ipsec_t)
237
238 kernel_rw_net_sysctls(ipsec_mgmt_t)
239 # allow pluto to access /proc/net/ipsec_eroute;
240 kernel_read_system_state(ipsec_mgmt_t)
241 kernel_read_network_state(ipsec_mgmt_t)
242 kernel_read_software_raid_state(ipsec_mgmt_t)
243 kernel_read_kernel_sysctls(ipsec_mgmt_t)
244 kernel_getattr_core_if(ipsec_mgmt_t)
245 kernel_getattr_message_if(ipsec_mgmt_t)
246
247 files_read_kernel_symbol_table(ipsec_mgmt_t)
248 files_getattr_kernel_modules(ipsec_mgmt_t)
249
250 # the default updown script wants to run route
251 # the ipsec wrapper wants to run /usr/bin/logger (should we put
252 # it in its own domain?)
253 corecmd_exec_bin(ipsec_mgmt_t)
254 corecmd_exec_shell(ipsec_mgmt_t)
255
256 dev_read_rand(ipsec_mgmt_t)
257 dev_read_urand(ipsec_mgmt_t)
258
259 domain_use_interactive_fds(ipsec_mgmt_t)
260 # denials when ps tries to search /proc. Do not audit these denials.
261 domain_dontaudit_list_all_domains_state(ipsec_mgmt_t)
262 # suppress audit messages about unnecessary socket access
263 # cjp: this seems excessive
264 domain_dontaudit_rw_all_udp_sockets(ipsec_mgmt_t)
265 domain_dontaudit_rw_all_key_sockets(ipsec_mgmt_t)
266
267 files_read_etc_files(ipsec_mgmt_t)
268 files_exec_etc_files(ipsec_mgmt_t)
269 files_read_etc_runtime_files(ipsec_mgmt_t)
270 files_read_usr_files(ipsec_mgmt_t)
271 files_dontaudit_getattr_default_dirs(ipsec_mgmt_t)
272 files_dontaudit_getattr_default_files(ipsec_mgmt_t)
273 files_list_tmp(ipsec_mgmt_t)
274
275 fs_getattr_xattr_fs(ipsec_mgmt_t)
276 fs_list_tmpfs(ipsec_mgmt_t)
277
278 term_use_console(ipsec_mgmt_t)
279 term_dontaudit_getattr_unallocated_ttys(ipsec_mgmt_t)
280
281 init_use_script_ptys(ipsec_mgmt_t)
282 init_exec_script_files(ipsec_mgmt_t)
283 init_use_fds(ipsec_mgmt_t)
284 init_labeled_script_domtrans(ipsec_mgmt_t, ipsec_initrc_exec_t)
285
286 logging_send_syslog_msg(ipsec_mgmt_t)
287
288 miscfiles_read_localization(ipsec_mgmt_t)
289
290 modutils_domtrans_insmod(ipsec_mgmt_t)
291
292 seutil_dontaudit_search_config(ipsec_mgmt_t)
293
294 sysnet_domtrans_ifconfig(ipsec_mgmt_t)
295
296 userdom_use_user_terminals(ipsec_mgmt_t)
297
298 optional_policy(`
299 consoletype_exec(ipsec_mgmt_t)
300 ')
301
302 optional_policy(`
303 nscd_socket_use(ipsec_mgmt_t)
304 ')
305
306 ifdef(`TODO',`
307 # ideally it would not need this. It wants to write to /root/.rnd
308 file_type_auto_trans(ipsec_mgmt_t, sysadm_home_dir_t, sysadm_home_t, file)
309
310 allow ipsec_mgmt_t dev_fs:file_class_set getattr;
311 ') dnl end TODO
312
313 ########################################
314 #
315 # Racoon local policy
316 #
317
318 allow racoon_t self:capability { net_admin net_bind_service };
319 allow racoon_t self:netlink_route_socket create_netlink_socket_perms;
320 allow racoon_t self:unix_dgram_socket { connect create ioctl write };
321 allow racoon_t self:netlink_selinux_socket { bind create read };
322 allow racoon_t self:udp_socket create_socket_perms;
323 allow racoon_t self:key_socket create_socket_perms;
324 allow racoon_t self:fifo_file rw_fifo_file_perms;
325
326 manage_dirs_pattern(racoon_t, racoon_tmp_t, racoon_tmp_t)
327 manage_files_pattern(racoon_t, racoon_tmp_t, racoon_tmp_t)
328 files_tmp_filetrans(racoon_t, racoon_tmp_t, { dir file })
329
330 can_exec(racoon_t, racoon_exec_t)
331
332 can_exec(racoon_t, setkey_exec_t)
333
334 # manage pid file
335 manage_files_pattern(racoon_t, ipsec_var_run_t, ipsec_var_run_t)
336 manage_sock_files_pattern(racoon_t, ipsec_var_run_t, ipsec_var_run_t)
337 files_pid_filetrans(racoon_t, ipsec_var_run_t, file)
338
339 allow racoon_t ipsec_conf_file_t:dir list_dir_perms;
340 read_files_pattern(racoon_t, ipsec_conf_file_t, ipsec_conf_file_t)
341 read_lnk_files_pattern(racoon_t, ipsec_conf_file_t, ipsec_conf_file_t)
342
343 allow racoon_t ipsec_key_file_t:dir list_dir_perms;
344 read_files_pattern(racoon_t, ipsec_key_file_t, ipsec_key_file_t)
345 read_lnk_files_pattern(racoon_t, ipsec_key_file_t, ipsec_key_file_t)
346
347 kernel_read_system_state(racoon_t)
348 kernel_read_network_state(racoon_t)
349 kernel_request_load_module(racoon_t)
350
351 corecmd_exec_shell(racoon_t)
352 corecmd_exec_bin(racoon_t)
353
354 corenet_all_recvfrom_unlabeled(racoon_t)
355 corenet_tcp_sendrecv_all_if(racoon_t)
356 corenet_udp_sendrecv_all_if(racoon_t)
357 corenet_tcp_sendrecv_all_nodes(racoon_t)
358 corenet_udp_sendrecv_all_nodes(racoon_t)
359 corenet_tcp_bind_all_nodes(racoon_t)
360 corenet_udp_bind_all_nodes(racoon_t)
361 corenet_udp_bind_isakmp_port(racoon_t)
362 corenet_udp_bind_ipsecnat_port(racoon_t)
363
364 dev_read_urand(racoon_t)
365
366 # allow racoon to set contexts on ipsec policy and SAs
367 domain_ipsec_setcontext_all_domains(racoon_t)
368
369 files_read_etc_files(racoon_t)
370
371 fs_dontaudit_getattr_xattr_fs(racoon_t)
372
373 # allow racoon to use avc_has_perm to check context on proposed SA
374 selinux_compute_access_vector(racoon_t)
375
376 auth_use_nsswitch(racoon_t)
377
378 ipsec_setcontext_default_spd(racoon_t)
379
380 locallogin_use_fds(racoon_t)
381
382 logging_send_syslog_msg(racoon_t)
383 logging_send_audit_msgs(racoon_t)
384
385 miscfiles_read_localization(racoon_t)
386
387 sysnet_exec_ifconfig(racoon_t)
388
389 auth_can_read_shadow_passwords(racoon_t)
390 tunable_policy(`racoon_read_shadow',`
391 auth_tunable_read_shadow(racoon_t)
392 ')
393
394 ########################################
395 #
396 # Setkey local policy
397 #
398
399 allow setkey_t self:capability net_admin;
400 allow setkey_t self:key_socket create_socket_perms;
401 allow setkey_t self:netlink_route_socket create_netlink_socket_perms;
402
403 allow setkey_t ipsec_conf_file_t:dir list_dir_perms;
404 read_files_pattern(setkey_t, ipsec_conf_file_t, ipsec_conf_file_t)
405 read_lnk_files_pattern(setkey_t, ipsec_conf_file_t, ipsec_conf_file_t)
406
407 kernel_request_load_module(setkey_t)
408
409 # allow setkey utility to set contexts on SA's and policy
410 domain_ipsec_setcontext_all_domains(setkey_t)
411
412 files_read_etc_files(setkey_t)
413
414 init_dontaudit_use_fds(setkey_t)
415
416 # allow setkey to set the context for ipsec SAs and policy.
417 ipsec_setcontext_default_spd(setkey_t)
418
419 locallogin_use_fds(setkey_t)
420
421 miscfiles_read_localization(setkey_t)
422
423 seutil_read_config(setkey_t)
424
425 userdom_use_user_terminals(setkey_t)