]> git.ipfire.org Git - people/stevee/selinux-policy.git/blob - policy/modules/system/ipsec.te
trunk: Move user roles into individual modules.
[people/stevee/selinux-policy.git] / policy / modules / system / ipsec.te
1
2 policy_module(ipsec,1.6.1)
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
141 sysadm_dontaudit_search_home_dirs(ipsec_t)
142
143 optional_policy(`
144 nis_use_ypbind(ipsec_t)
145 ')
146
147 optional_policy(`
148 seutil_sigchld_newrole(ipsec_t)
149 ')
150
151 optional_policy(`
152 udev_read_db(ipsec_t)
153 ')
154
155 ########################################
156 #
157 # ipsec_mgmt Local policy
158 #
159
160 allow ipsec_mgmt_t self:capability { net_admin sys_tty_config dac_override dac_read_search };
161 allow ipsec_mgmt_t self:process { signal setrlimit };
162 allow ipsec_mgmt_t self:unix_stream_socket create_stream_socket_perms;
163 allow ipsec_mgmt_t self:tcp_socket create_socket_perms;
164 allow ipsec_mgmt_t self:udp_socket create_socket_perms;
165 allow ipsec_mgmt_t self:key_socket { create setopt };
166 allow ipsec_mgmt_t self:fifo_file rw_file_perms;
167
168 allow ipsec_mgmt_t ipsec_mgmt_lock_t:file manage_file_perms;
169 files_lock_filetrans(ipsec_mgmt_t,ipsec_mgmt_lock_t,file)
170
171 allow ipsec_mgmt_t ipsec_mgmt_var_run_t:file manage_file_perms;
172 files_pid_filetrans(ipsec_mgmt_t,ipsec_mgmt_var_run_t,file)
173
174 manage_files_pattern(ipsec_mgmt_t,ipsec_var_run_t,ipsec_var_run_t)
175 manage_lnk_files_pattern(ipsec_mgmt_t,ipsec_var_run_t,ipsec_var_run_t)
176
177 allow ipsec_mgmt_t ipsec_var_run_t:sock_file manage_sock_file_perms;
178 files_pid_filetrans(ipsec_mgmt_t,ipsec_var_run_t,sock_file)
179
180 # _realsetup needs to be able to cat /var/run/pluto.pid,
181 # run ps on that pid, and delete the file
182 read_files_pattern(ipsec_mgmt_t,ipsec_t,ipsec_t)
183 read_lnk_files_pattern(ipsec_mgmt_t,ipsec_t,ipsec_t)
184
185 # logger, running in ipsec_mgmt_t needs to use sockets
186 allow ipsec_mgmt_t self:unix_dgram_socket { create connect write };
187 allow ipsec_mgmt_t ipsec_t:unix_dgram_socket { create connect write };
188
189 allow ipsec_mgmt_t ipsec_conf_file_t:file { getattr read ioctl };
190
191 manage_files_pattern(ipsec_mgmt_t,ipsec_key_file_t,ipsec_key_file_t)
192 manage_lnk_files_pattern(ipsec_mgmt_t,ipsec_key_file_t,ipsec_key_file_t)
193 files_etc_filetrans(ipsec_mgmt_t,ipsec_key_file_t,file)
194
195 # whack needs to connect to pluto
196 stream_connect_pattern(ipsec_mgmt_t,ipsec_var_run_t,ipsec_var_run_t,ipsec_t)
197
198 can_exec(ipsec_mgmt_t, ipsec_exec_t)
199 can_exec(ipsec_mgmt_t, ipsec_mgmt_exec_t)
200 allow ipsec_mgmt_t ipsec_mgmt_exec_t:lnk_file read;
201
202 domtrans_pattern(ipsec_mgmt_t,ipsec_exec_t,ipsec_t)
203
204 kernel_rw_net_sysctls(ipsec_mgmt_t)
205 # allow pluto to access /proc/net/ipsec_eroute;
206 kernel_read_system_state(ipsec_mgmt_t)
207 kernel_read_network_state(ipsec_mgmt_t)
208 kernel_read_software_raid_state(ipsec_mgmt_t)
209 kernel_read_kernel_sysctls(ipsec_mgmt_t)
210 kernel_getattr_core_if(ipsec_mgmt_t)
211 kernel_getattr_message_if(ipsec_mgmt_t)
212
213 files_read_kernel_symbol_table(ipsec_mgmt_t)
214 files_getattr_kernel_modules(ipsec_mgmt_t)
215
216 dev_read_rand(ipsec_mgmt_t)
217 dev_read_urand(ipsec_mgmt_t)
218
219 fs_getattr_xattr_fs(ipsec_mgmt_t)
220 fs_list_tmpfs(ipsec_mgmt_t)
221
222 term_use_console(ipsec_mgmt_t)
223 term_dontaudit_getattr_unallocated_ttys(ipsec_mgmt_t)
224
225 # the default updown script wants to run route
226 # the ipsec wrapper wants to run /usr/bin/logger (should we put
227 # it in its own domain?)
228 corecmd_exec_bin(ipsec_mgmt_t)
229
230 domain_use_interactive_fds(ipsec_mgmt_t)
231 # denials when ps tries to search /proc. Do not audit these denials.
232 domain_dontaudit_list_all_domains_state(ipsec_mgmt_t)
233 # suppress audit messages about unnecessary socket access
234 # cjp: this seems excessive
235 domain_dontaudit_rw_all_udp_sockets(ipsec_mgmt_t)
236 domain_dontaudit_rw_all_key_sockets(ipsec_mgmt_t)
237
238 files_read_etc_files(ipsec_mgmt_t)
239 files_exec_etc_files(ipsec_mgmt_t)
240 files_read_etc_runtime_files(ipsec_mgmt_t)
241 files_dontaudit_getattr_default_dirs(ipsec_mgmt_t)
242 files_dontaudit_getattr_default_files(ipsec_mgmt_t)
243
244 init_use_script_ptys(ipsec_mgmt_t)
245 init_exec_script_files(ipsec_mgmt_t)
246 init_use_fds(ipsec_mgmt_t)
247
248 libs_use_ld_so(ipsec_mgmt_t)
249 libs_use_shared_libs(ipsec_mgmt_t)
250
251 miscfiles_read_localization(ipsec_mgmt_t)
252
253 modutils_domtrans_insmod(ipsec_mgmt_t)
254
255 seutil_dontaudit_search_config(ipsec_mgmt_t)
256
257 sysnet_domtrans_ifconfig(ipsec_mgmt_t)
258
259 sysadm_use_terms(ipsec_mgmt_t)
260
261 optional_policy(`
262 consoletype_exec(ipsec_mgmt_t)
263 ')
264
265 optional_policy(`
266 nscd_socket_use(ipsec_mgmt_t)
267 ')
268
269 ifdef(`TODO',`
270 # ideally it would not need this. It wants to write to /root/.rnd
271 file_type_auto_trans(ipsec_mgmt_t, sysadm_home_dir_t, sysadm_home_t, file)
272
273 allow ipsec_mgmt_t dev_fs:file_class_set getattr;
274 ') dnl end TODO
275
276 ########################################
277 #
278 # Racoon local policy
279 #
280
281 allow racoon_t self:capability { net_admin net_bind_service };
282 allow racoon_t self:netlink_route_socket create_netlink_socket_perms;
283 allow racoon_t self:unix_dgram_socket { connect create ioctl write };
284 allow racoon_t self:netlink_selinux_socket { bind create read };
285 allow racoon_t self:udp_socket create_socket_perms;
286 allow racoon_t self:key_socket { create read setopt write };
287
288 # manage pid file
289 manage_files_pattern(racoon_t,ipsec_var_run_t,ipsec_var_run_t)
290 manage_sock_files_pattern(racoon_t,ipsec_var_run_t,ipsec_var_run_t)
291 files_pid_filetrans(racoon_t,ipsec_var_run_t,file)
292
293 allow racoon_t ipsec_conf_file_t:dir list_dir_perms;
294 read_files_pattern(racoon_t,ipsec_conf_file_t,ipsec_conf_file_t)
295 read_lnk_files_pattern(racoon_t,ipsec_conf_file_t,ipsec_conf_file_t)
296
297 allow racoon_t ipsec_key_file_t:dir list_dir_perms;
298 read_files_pattern(racoon_t,ipsec_key_file_t,ipsec_key_file_t)
299 read_lnk_files_pattern(racoon_t,ipsec_key_file_t,ipsec_key_file_t)
300
301 kernel_read_system_state(racoon_t)
302 kernel_read_network_state(racoon_t)
303
304 corenet_all_recvfrom_unlabeled(racoon_t)
305 corenet_tcp_bind_all_nodes(racoon_t)
306 corenet_udp_bind_all_nodes(racoon_t)
307 corenet_udp_bind_isakmp_port(racoon_t)
308 corenet_udp_bind_ipsecnat_port(racoon_t)
309
310 dev_read_urand(racoon_t)
311
312 # allow racoon to set contexts on ipsec policy and SAs
313 domain_ipsec_setcontext_all_domains(racoon_t)
314
315 files_read_etc_files(racoon_t)
316
317 # allow racoon to use avc_has_perm to check context on proposed SA
318 selinux_compute_access_vector(racoon_t)
319
320 ipsec_setcontext_default_spd(racoon_t)
321
322 libs_use_ld_so(racoon_t)
323 libs_use_shared_libs(racoon_t)
324
325 locallogin_use_fds(racoon_t)
326
327 logging_send_syslog_msg(racoon_t)
328 logging_send_audit_msgs(racoon_t)
329
330 miscfiles_read_localization(racoon_t)
331
332 ########################################
333 #
334 # Setkey local policy
335 #
336
337 allow setkey_t self:capability net_admin;
338 allow setkey_t self:key_socket { create read setopt write };
339 allow setkey_t self:netlink_route_socket create_netlink_socket_perms;
340
341 allow setkey_t ipsec_conf_file_t:dir list_dir_perms;
342 read_files_pattern(setkey_t,ipsec_conf_file_t,ipsec_conf_file_t)
343 read_lnk_files_pattern(setkey_t,ipsec_conf_file_t,ipsec_conf_file_t)
344
345 # allow setkey utility to set contexts on SA's and policy
346 domain_ipsec_setcontext_all_domains(setkey_t)
347
348 files_read_etc_files(setkey_t)
349
350 init_dontaudit_use_fds(setkey_t)
351
352 # allow setkey to set the context for ipsec SAs and policy.
353 ipsec_setcontext_default_spd(setkey_t)
354
355 locallogin_use_fds(setkey_t)
356
357 libs_use_ld_so(setkey_t)
358 libs_use_shared_libs(setkey_t)
359
360 miscfiles_read_localization(setkey_t)
361
362 seutil_read_config(setkey_t)