2 policy_module(postfix, 1.9.0)
4 ########################################
9 attribute postfix_user_domains;
10 # domains that transition to the
11 # postfix user domains
12 attribute postfix_user_domtrans;
14 postfix_server_domain_template(bounce)
16 type postfix_spool_bounce_t;
17 files_type(postfix_spool_bounce_t)
19 postfix_server_domain_template(cleanup)
22 files_type(postfix_etc_t)
25 application_executable_file(postfix_exec_t)
27 postfix_server_domain_template(local)
28 mta_mailserver_delivery(postfix_local_t)
30 type postfix_local_tmp_t;
31 files_tmp_file(postfix_local_tmp_t)
33 # Program for creating database files
35 type postfix_map_exec_t;
36 application_domain(postfix_map_t, postfix_map_exec_t)
38 type postfix_map_tmp_t;
39 files_tmp_file(postfix_map_tmp_t)
41 postfix_domain_template(master)
42 typealias postfix_master_t alias postfix_t;
43 # alias is a hack to make the disable trans bool
44 # generation macro work
45 mta_mailserver(postfix_t, postfix_master_exec_t)
47 postfix_server_domain_template(pickup)
49 postfix_server_domain_template(pipe)
51 postfix_user_domain_template(postdrop)
52 mta_mailserver_user_agent(postfix_postdrop_t)
54 postfix_user_domain_template(postqueue)
56 type postfix_private_t;
57 files_type(postfix_private_t)
60 files_type(postfix_prng_t)
62 postfix_server_domain_template(qmgr)
64 postfix_user_domain_template(showq)
66 postfix_server_domain_template(smtp)
67 mta_mailserver_sender(postfix_smtp_t)
69 postfix_server_domain_template(smtpd)
72 files_type(postfix_spool_t)
74 type postfix_spool_maildrop_t;
75 files_type(postfix_spool_maildrop_t)
77 type postfix_spool_flush_t;
78 files_type(postfix_spool_flush_t)
80 type postfix_public_t;
81 files_type(postfix_public_t)
83 type postfix_var_run_t;
84 files_pid_file(postfix_var_run_t)
86 # the data_directory config parameter
88 files_type(postfix_data_t)
90 postfix_server_domain_template(virtual)
91 mta_mailserver_delivery(postfix_virtual_t)
93 type postfix_virtual_tmp_t;
94 files_tmp_file(postfix_virtual_tmp_t)
96 ########################################
98 # Postfix master process local policy
101 # chown is to set the correct ownership of queue dirs
102 allow postfix_master_t self:capability { chown dac_override kill setgid setuid net_bind_service sys_tty_config };
103 allow postfix_master_t self:fifo_file rw_fifo_file_perms;
104 allow postfix_master_t self:tcp_socket create_stream_socket_perms;
105 allow postfix_master_t self:udp_socket create_socket_perms;
107 allow postfix_master_t postfix_etc_t:file rw_file_perms;
109 can_exec(postfix_master_t,postfix_exec_t)
111 allow postfix_master_t postfix_data_t:dir manage_dir_perms;
112 allow postfix_master_t postfix_data_t:file manage_file_perms;
114 allow postfix_master_t postfix_map_exec_t:file { mmap_file_perms ioctl lock };
116 allow postfix_master_t postfix_postdrop_exec_t:file getattr;
118 allow postfix_master_t postfix_postqueue_exec_t:file getattr;
120 manage_fifo_files_pattern(postfix_master_t, postfix_private_t, postfix_private_t)
121 manage_sock_files_pattern(postfix_master_t, postfix_private_t, postfix_private_t)
123 domtrans_pattern(postfix_master_t, postfix_postqueue_exec_t, postfix_postqueue_t)
125 allow postfix_master_t postfix_prng_t:file rw_file_perms;
127 manage_fifo_files_pattern(postfix_master_t, postfix_public_t, postfix_public_t)
128 manage_sock_files_pattern(postfix_master_t, postfix_public_t, postfix_public_t)
130 domtrans_pattern(postfix_master_t, postfix_showq_exec_t, postfix_showq_t)
132 # allow access to deferred queue and allow removing bogus incoming entries
133 manage_dirs_pattern(postfix_master_t, postfix_spool_t, postfix_spool_t)
134 manage_files_pattern(postfix_master_t, postfix_spool_t, postfix_spool_t)
136 allow postfix_master_t postfix_spool_bounce_t:dir manage_dir_perms;
137 allow postfix_master_t postfix_spool_bounce_t:file getattr;
139 manage_dirs_pattern(postfix_master_t, postfix_spool_flush_t, postfix_spool_flush_t)
140 manage_files_pattern(postfix_master_t, postfix_spool_flush_t, postfix_spool_flush_t)
141 manage_lnk_files_pattern(postfix_master_t, postfix_spool_flush_t, postfix_spool_flush_t)
143 delete_files_pattern(postfix_master_t, postfix_spool_maildrop_t, postfix_spool_maildrop_t)
144 rename_files_pattern(postfix_master_t, postfix_spool_maildrop_t, postfix_spool_maildrop_t)
146 kernel_read_all_sysctls(postfix_master_t)
148 corenet_all_recvfrom_unlabeled(postfix_master_t)
149 corenet_all_recvfrom_netlabel(postfix_master_t)
150 corenet_tcp_sendrecv_all_if(postfix_master_t)
151 corenet_udp_sendrecv_all_if(postfix_master_t)
152 corenet_tcp_sendrecv_all_nodes(postfix_master_t)
153 corenet_udp_sendrecv_all_nodes(postfix_master_t)
154 corenet_tcp_sendrecv_all_ports(postfix_master_t)
155 corenet_udp_sendrecv_all_ports(postfix_master_t)
156 corenet_tcp_bind_all_nodes(postfix_master_t)
157 corenet_tcp_bind_amavisd_send_port(postfix_master_t)
158 corenet_tcp_bind_smtp_port(postfix_master_t)
159 corenet_tcp_connect_all_ports(postfix_master_t)
160 corenet_sendrecv_amavisd_send_server_packets(postfix_master_t)
161 corenet_sendrecv_smtp_server_packets(postfix_master_t)
162 corenet_sendrecv_all_client_packets(postfix_master_t)
165 selinux_dontaudit_search_fs(postfix_master_t)
167 corecmd_exec_shell(postfix_master_t)
168 corecmd_exec_bin(postfix_master_t)
170 domain_use_interactive_fds(postfix_master_t)
172 files_read_usr_files(postfix_master_t)
174 term_dontaudit_search_ptys(postfix_master_t)
176 miscfiles_read_man_pages(postfix_master_t)
178 seutil_sigchld_newrole(postfix_master_t)
179 # postfix does a "find" on startup for some reason - keep it quiet
180 seutil_dontaudit_search_config(postfix_master_t)
182 mta_rw_aliases(postfix_master_t)
183 mta_read_sendmail_bin(postfix_master_t)
185 ifdef(`distro_redhat',`
186 # for newer main.cf that uses /etc/aliases
187 mta_manage_aliases(postfix_master_t)
188 mta_etc_filetrans_aliases(postfix_master_t)
192 cyrus_stream_connect(postfix_master_t)
197 mailman_manage_data_files(postfix_master_t)
201 mysql_stream_connect(postfix_master_t)
205 sendmail_signal(postfix_master_t)
208 ########################################
210 # Postfix bounce local policy
213 allow postfix_bounce_t self:capability dac_read_search;
214 allow postfix_bounce_t self:tcp_socket create_socket_perms;
216 allow postfix_bounce_t postfix_public_t:sock_file write;
217 allow postfix_bounce_t postfix_public_t:dir search;
219 manage_dirs_pattern(postfix_bounce_t, postfix_spool_t, postfix_spool_t)
220 manage_files_pattern(postfix_bounce_t, postfix_spool_t, postfix_spool_t)
221 manage_lnk_files_pattern(postfix_bounce_t, postfix_spool_t, postfix_spool_t)
223 manage_dirs_pattern(postfix_bounce_t, postfix_spool_bounce_t, postfix_spool_bounce_t)
224 manage_files_pattern(postfix_bounce_t, postfix_spool_bounce_t, postfix_spool_bounce_t)
225 manage_lnk_files_pattern(postfix_bounce_t, postfix_spool_bounce_t, postfix_spool_bounce_t)
227 ########################################
229 # Postfix cleanup local policy
232 allow postfix_cleanup_t self:process setrlimit;
234 # connect to master process
235 stream_connect_pattern(postfix_cleanup_t, postfix_private_t, postfix_private_t, postfix_master_t)
237 rw_fifo_files_pattern(postfix_cleanup_t, postfix_public_t, postfix_public_t)
238 write_sock_files_pattern(postfix_cleanup_t, postfix_public_t, postfix_public_t)
240 manage_dirs_pattern(postfix_cleanup_t, postfix_spool_t, postfix_spool_t)
241 manage_files_pattern(postfix_cleanup_t, postfix_spool_t, postfix_spool_t)
242 manage_lnk_files_pattern(postfix_cleanup_t, postfix_spool_t, postfix_spool_t)
244 allow postfix_cleanup_t postfix_spool_bounce_t:dir list_dir_perms;
246 corecmd_exec_bin(postfix_cleanup_t)
248 ########################################
250 # Postfix local local policy
253 allow postfix_local_t self:fifo_file rw_fifo_file_perms;
254 allow postfix_local_t self:process { setsched setrlimit };
256 manage_dirs_pattern(postfix_local_t, postfix_local_tmp_t, postfix_local_tmp_t)
257 manage_files_pattern(postfix_local_t, postfix_local_tmp_t, postfix_local_tmp_t)
258 files_tmp_filetrans(postfix_local_t, postfix_local_tmp_t, { file dir })
260 # connect to master process
261 stream_connect_pattern(postfix_local_t, postfix_public_t, postfix_public_t, postfix_master_t)
263 # for .forward - maybe we need a new type for it?
264 rw_sock_files_pattern(postfix_local_t, postfix_private_t, postfix_private_t)
266 allow postfix_local_t postfix_spool_t:file rw_file_perms;
268 corecmd_exec_shell(postfix_local_t)
269 corecmd_exec_bin(postfix_local_t)
271 files_read_etc_files(postfix_local_t)
273 mta_read_aliases(postfix_local_t)
274 mta_delete_spool(postfix_local_t)
275 # For reading spamassasin
276 mta_read_config(postfix_local_t)
279 clamav_search_lib(postfix_local_t)
284 mailman_manage_data_files(postfix_local_t)
288 procmail_domtrans(postfix_local_t)
291 ########################################
293 # Postfix map local policy
296 allow postfix_map_t self:capability setgid;
297 allow postfix_map_t self:unix_stream_socket create_stream_socket_perms;
298 allow postfix_map_t self:unix_dgram_socket create_socket_perms;
299 allow postfix_map_t self:tcp_socket create_stream_socket_perms;
300 allow postfix_map_t self:udp_socket create_socket_perms;
302 manage_dirs_pattern(postfix_map_t, postfix_etc_t, postfix_etc_t)
303 manage_files_pattern(postfix_map_t, postfix_etc_t, postfix_etc_t)
304 manage_lnk_files_pattern(postfix_map_t, postfix_etc_t, postfix_etc_t)
306 manage_dirs_pattern(postfix_map_t, postfix_map_tmp_t, postfix_map_tmp_t)
307 manage_files_pattern(postfix_map_t, postfix_map_tmp_t, postfix_map_tmp_t)
308 files_tmp_filetrans(postfix_map_t, postfix_map_tmp_t, { file dir })
310 kernel_read_kernel_sysctls(postfix_map_t)
311 kernel_dontaudit_list_proc(postfix_map_t)
312 kernel_dontaudit_read_system_state(postfix_map_t)
314 corenet_all_recvfrom_unlabeled(postfix_map_t)
315 corenet_all_recvfrom_netlabel(postfix_map_t)
316 corenet_tcp_sendrecv_all_if(postfix_map_t)
317 corenet_udp_sendrecv_all_if(postfix_map_t)
318 corenet_tcp_sendrecv_all_nodes(postfix_map_t)
319 corenet_udp_sendrecv_all_nodes(postfix_map_t)
320 corenet_tcp_sendrecv_all_ports(postfix_map_t)
321 corenet_udp_sendrecv_all_ports(postfix_map_t)
322 corenet_tcp_connect_all_ports(postfix_map_t)
323 corenet_sendrecv_all_client_packets(postfix_map_t)
325 corecmd_list_bin(postfix_map_t)
326 corecmd_read_bin_symlinks(postfix_map_t)
327 corecmd_read_bin_files(postfix_map_t)
328 corecmd_read_bin_pipes(postfix_map_t)
329 corecmd_read_bin_sockets(postfix_map_t)
331 files_list_home(postfix_map_t)
332 files_read_usr_files(postfix_map_t)
333 files_read_etc_files(postfix_map_t)
334 files_read_etc_runtime_files(postfix_map_t)
335 files_dontaudit_search_var(postfix_map_t)
337 auth_use_nsswitch(postfix_map_t)
339 libs_use_ld_so(postfix_map_t)
340 libs_use_shared_libs(postfix_map_t)
342 logging_send_syslog_msg(postfix_map_t)
344 miscfiles_read_localization(postfix_map_t)
346 seutil_read_config(postfix_map_t)
348 tunable_policy(`read_default_t',`
349 files_list_default(postfix_map_t)
350 files_read_default_files(postfix_map_t)
351 files_read_default_symlinks(postfix_map_t)
352 files_read_default_sockets(postfix_map_t)
353 files_read_default_pipes(postfix_map_t)
357 locallogin_dontaudit_use_fds(postfix_map_t)
360 ########################################
362 # Postfix pickup local policy
365 allow postfix_pickup_t self:tcp_socket create_socket_perms;
367 stream_connect_pattern(postfix_pickup_t,postfix_private_t,postfix_private_t,postfix_master_t)
369 rw_fifo_files_pattern(postfix_pickup_t, postfix_public_t, postfix_public_t)
370 rw_sock_files_pattern(postfix_pickup_t, postfix_public_t, postfix_public_t)
372 postfix_list_spool(postfix_pickup_t)
374 allow postfix_pickup_t postfix_spool_maildrop_t:dir list_dir_perms;
375 read_files_pattern(postfix_pickup_t, postfix_spool_maildrop_t, postfix_spool_maildrop_t)
376 delete_files_pattern(postfix_pickup_t, postfix_spool_maildrop_t, postfix_spool_maildrop_t)
378 ########################################
380 # Postfix pipe local policy
383 allow postfix_pipe_t self:fifo_file rw_fifo_file_perms;
385 write_sock_files_pattern(postfix_pipe_t, postfix_private_t, postfix_private_t)
387 write_fifo_files_pattern(postfix_pipe_t, postfix_public_t, postfix_public_t)
389 rw_files_pattern(postfix_pipe_t, postfix_spool_t, postfix_spool_t)
392 procmail_domtrans(postfix_pipe_t)
396 mailman_domtrans_queue(postfix_pipe_t)
400 uucp_domtrans_uux(postfix_pipe_t)
403 ########################################
405 # Postfix postdrop local policy
408 # usually it does not need a UDP socket
409 allow postfix_postdrop_t self:capability sys_resource;
410 allow postfix_postdrop_t self:tcp_socket create;
411 allow postfix_postdrop_t self:udp_socket create_socket_perms;
413 rw_fifo_files_pattern(postfix_postdrop_t, postfix_public_t, postfix_public_t)
415 postfix_list_spool(postfix_postdrop_t)
416 manage_files_pattern(postfix_postdrop_t, postfix_spool_maildrop_t, postfix_spool_maildrop_t)
418 corenet_udp_sendrecv_all_if(postfix_postdrop_t)
419 corenet_udp_sendrecv_all_nodes(postfix_postdrop_t)
421 term_dontaudit_use_all_user_ptys(postfix_postdrop_t)
422 term_dontaudit_use_all_user_ttys(postfix_postdrop_t)
424 mta_rw_user_mail_stream_sockets(postfix_postdrop_t)
427 cron_system_entry(postfix_postdrop_t, postfix_postdrop_exec_t)
430 # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=239951
432 fstools_read_pipes(postfix_postdrop_t)
436 ppp_use_fds(postfix_postqueue_t)
437 ppp_sigchld(postfix_postqueue_t)
440 #######################################
442 # Postfix postqueue local policy
445 allow postfix_postqueue_t self:tcp_socket create;
446 allow postfix_postqueue_t self:udp_socket { create ioctl };
448 # wants to write to /var/spool/postfix/public/showq
449 stream_connect_pattern(postfix_postqueue_t, postfix_public_t, postfix_public_t,postfix_master_t)
451 # write to /var/spool/postfix/public/qmgr
452 write_fifo_files_pattern(postfix_postqueue_t, postfix_public_t, postfix_public_t)
454 domtrans_pattern(postfix_postqueue_t, postfix_showq_exec_t, postfix_showq_t)
456 # to write the mailq output, it really should not need read access!
457 term_use_all_user_ptys(postfix_postqueue_t)
458 term_use_all_user_ttys(postfix_postqueue_t)
460 init_sigchld_script(postfix_postqueue_t)
461 init_use_script_fds(postfix_postqueue_t)
463 ########################################
465 # Postfix qmgr local policy
468 stream_connect_pattern(postfix_qmgr_t, { postfix_private_t postfix_public_t }, { postfix_private_t postfix_public_t },postfix_master_t)
470 rw_fifo_files_pattern(postfix_qmgr_t, postfix_public_t, postfix_public_t)
472 # for /var/spool/postfix/active
473 manage_dirs_pattern(postfix_qmgr_t, postfix_spool_t, postfix_spool_t)
474 manage_files_pattern(postfix_qmgr_t, postfix_spool_t, postfix_spool_t)
475 manage_lnk_files_pattern(postfix_qmgr_t, postfix_spool_t, postfix_spool_t)
477 allow postfix_qmgr_t postfix_spool_bounce_t:dir list_dir_perms;
478 allow postfix_qmgr_t postfix_spool_bounce_t:file read_file_perms;
479 allow postfix_qmgr_t postfix_spool_bounce_t:lnk_file { getattr read };
481 corecmd_exec_bin(postfix_qmgr_t)
483 ########################################
485 # Postfix showq local policy
488 allow postfix_showq_t self:capability { setuid setgid };
489 allow postfix_showq_t self:tcp_socket create_socket_perms;
491 allow postfix_showq_t postfix_master_t:unix_stream_socket { accept rw_socket_perms };
493 allow postfix_showq_t postfix_spool_t:file read_file_perms;
495 postfix_list_spool(postfix_showq_t)
497 allow postfix_showq_t postfix_spool_maildrop_t:dir list_dir_perms;
498 allow postfix_showq_t postfix_spool_maildrop_t:file read_file_perms;
499 allow postfix_showq_t postfix_spool_maildrop_t:lnk_file { getattr read };
501 # to write the mailq output, it really should not need read access!
502 term_use_all_user_ptys(postfix_showq_t)
503 term_use_all_user_ttys(postfix_showq_t)
505 ########################################
507 # Postfix smtp delivery local policy
510 # connect to master process
511 stream_connect_pattern(postfix_smtp_t, { postfix_private_t postfix_public_t }, { postfix_private_t postfix_public_t },postfix_master_t)
513 allow postfix_smtp_t postfix_prng_t:file rw_file_perms;
515 allow postfix_smtp_t postfix_spool_t:file rw_file_perms;
517 files_dontaudit_getattr_home_dir(postfix_smtp_t)
520 cyrus_stream_connect(postfix_smtp_t)
523 ########################################
525 # Postfix smtpd local policy
527 allow postfix_smtpd_t postfix_master_t:tcp_socket rw_stream_socket_perms;
529 # connect to master process
530 stream_connect_pattern(postfix_smtpd_t, { postfix_private_t postfix_public_t }, { postfix_private_t postfix_public_t },postfix_master_t)
532 # Connect to policy server
533 corenet_tcp_connect_postfix_policyd_port(postfix_smtpd_t)
536 allow postfix_smtpd_t postfix_spool_t:file rw_file_perms;
537 allow postfix_smtpd_t postfix_prng_t:file rw_file_perms;
539 corecmd_exec_bin(postfix_smtpd_t)
541 # for OpenSSL certificates
542 files_read_usr_files(postfix_smtpd_t)
543 mta_read_aliases(postfix_smtpd_t)
546 mailman_read_data_files(postfix_smtpd_t)
550 postgrey_stream_connect(postfix_smtpd_t)
554 sasl_connect(postfix_smtpd_t)
557 ########################################
559 # Postfix virtual local policy
562 allow postfix_virtual_t self:fifo_file rw_fifo_file_perms;
563 allow postfix_virtual_t self:process { setsched setrlimit };
565 allow postfix_virtual_t postfix_spool_t:file rw_file_perms;
567 manage_dirs_pattern(postfix_virtual_t, postfix_virtual_tmp_t, postfix_virtual_tmp_t)
568 manage_files_pattern(postfix_virtual_t, postfix_virtual_tmp_t, postfix_virtual_tmp_t)
569 files_tmp_filetrans(postfix_virtual_t, postfix_virtual_tmp_t, { file dir })
571 # connect to master process
572 stream_connect_pattern(postfix_virtual_t, postfix_public_t, postfix_public_t, postfix_master_t)
574 corecmd_exec_shell(postfix_virtual_t)
575 corecmd_exec_bin(postfix_virtual_t)
577 files_read_etc_files(postfix_virtual_t)
579 mta_read_aliases(postfix_virtual_t)
580 mta_delete_spool(postfix_virtual_t)
581 # For reading spamassasin
582 mta_read_config(postfix_virtual_t)
583 mta_manage_spool(postfix_virtual_t)