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