selinux-policy/refpolicy/policy/modules/services/mta.te

230 lines
6.7 KiB
Plaintext
Raw Normal View History

2005-05-02 19:24:29 +00:00
policy_module(mta,1.0)
2005-05-12 20:50:09 +00:00
########################################
#
# Declarations
#
2005-05-02 19:24:29 +00:00
type etc_aliases_t;
files_type(etc_aliases_t)
2005-05-02 19:24:29 +00:00
type etc_mail_t;
files_type(etc_mail_t)
2005-05-02 19:24:29 +00:00
2005-05-13 14:37:13 +00:00
attribute mailserver_domain;
2005-05-02 19:24:29 +00:00
type mqueue_spool_t;
files_type(mqueue_spool_t)
2005-05-02 19:24:29 +00:00
type mail_spool_t;
files_type(mail_spool_t)
2005-05-12 20:50:09 +00:00
type sendmail_exec_t;
files_type(sendmail_exec_t)
2005-05-12 20:50:09 +00:00
type system_mail_t; #, user_mail_domain, nscd_client_domain;
2005-06-13 17:35:46 +00:00
domain_type(system_mail_t)
2005-05-12 20:50:09 +00:00
role system_r types system_mail_t;
ifdef(`targeted_policy',`',`
2005-05-13 14:37:13 +00:00
optional_policy(`sendmail.te', `
2005-06-13 17:35:46 +00:00
domain_entry_file(system_mail_t,sendmail_exec_t)
2005-05-13 14:37:13 +00:00
', `
2005-06-13 17:35:46 +00:00
init_system_domain(system_mail_t,sendmail_exec_t)
2005-05-13 14:37:13 +00:00
') dnl end if sendmail
') dnl end targeted_policy
2005-05-12 20:50:09 +00:00
########################################
#
# System mail local policy
#
allow system_mail_t self:capability { setuid setgid chown };
2005-06-10 01:01:13 +00:00
allow system_mail_t self:process { signal_perms setrlimit };
2005-05-12 20:50:09 +00:00
2005-06-09 15:32:23 +00:00
allow system_mail_t self:tcp_socket create_socket_perms;
2005-05-12 20:50:09 +00:00
# re-exec itself
2005-06-09 15:32:23 +00:00
can_exec(system_mail_t, sendmail_exec_t)
allow system_mail_t sendmail_exec_t:lnk_file r_file_perms;
2005-05-12 20:50:09 +00:00
kernel_read_kernel_sysctl(system_mail_t)
kernel_read_system_state(system_mail_t)
kernel_read_network_state(system_mail_t)
2005-06-10 01:01:13 +00:00
corenet_tcp_sendrecv_all_if(system_mail_t)
corenet_raw_sendrecv_all_if(system_mail_t)
corenet_tcp_sendrecv_all_nodes(system_mail_t)
corenet_raw_sendrecv_all_nodes(system_mail_t)
corenet_tcp_bind_all_nodes(system_mail_t)
corenet_tcp_sendrecv_all_ports(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-06-13 16:22:32 +00:00
dev_read_urand(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-06-10 01:01:13 +00:00
fs_getattr_xattr_fs(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-06-13 17:35:46 +00:00
init_use_script_pty(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-06-13 17:35:46 +00:00
files_read_etc_runtime_files(system_mail_t)
files_read_etc_files(system_mail_t)
2005-05-12 20:50:09 +00:00
# It wants to check for nscd
2005-06-13 17:35:46 +00:00
files_dontaudit_search_pids(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-06-13 17:35:46 +00:00
corecmd_exec_bin(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-06-13 17:35:46 +00:00
libs_use_ld_so(system_mail_t)
libs_use_shared_libs(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-06-13 17:35:46 +00:00
logging_send_syslog_msg(system_mail_t)
2005-05-12 20:50:09 +00:00
miscfiles_read_localization(system_mail_t)
2005-06-13 17:35:46 +00:00
sysnet_read_config(system_mail_t)
2005-05-12 20:50:09 +00:00
tunable_policy(`use_dns',`
2005-06-09 15:32:23 +00:00
allow system_mail_t self:udp_socket create_socket_perms;
2005-06-10 01:01:13 +00:00
corenet_udp_sendrecv_all_if(system_mail_t)
corenet_udp_sendrecv_all_nodes(system_mail_t)
corenet_udp_bind_all_nodes(system_mail_t)
corenet_udp_sendrecv_dns_port(system_mail_t)
2005-05-12 20:50:09 +00:00
')
2005-06-27 16:30:55 +00:00
optional_policy(`nis.te',`
nis_use_ypbind(system_mail_t)
')
2005-05-12 20:50:09 +00:00
optional_policy(`procmail.te',`
2005-06-27 16:30:55 +00:00
procmail_exec(system_mail_t)
2005-05-12 20:50:09 +00:00
')
ifdef(`TODO',`
2005-05-13 14:37:13 +00:00
optional_policy(`sendmail.te',`
allow system_mail_t etc_mail_t:dir { getattr search };
allow system_mail_t etc_runtime_t:file { getattr read };
allow system_mail_t proc_t:dir search;
allow system_mail_t proc_t:file { getattr read };
allow system_mail_t proc_t:lnk_file read;
dontaudit system_mail_t proc_net_t:dir search;
allow system_mail_t fs_t:filesystem getattr;
allow system_mail_t var_t:dir getattr;
allow system_mail_t var_spool_t:dir getattr;
dontaudit system_mail_t userpty_type:chr_file { getattr read write };
# sendmail -q
allow system_mail_t mqueue_spool_t:dir rw_dir_perms;
allow system_mail_t mqueue_spool_t:file create_file_perms;
ifdef(`crond.te', `
dontaudit system_mail_t system_crond_tmp_t:file append;
')
') dnl end if sendmail
2005-05-12 20:50:09 +00:00
allow system_mail_t device_t:dir search;
allow system_mail_t { var_t var_spool_t }:dir search;
allow system_mail_t sbin_t:dir search;
# Transition from a system domain to the derived domain.
domain_auto_trans(privmail, sendmail_exec_t, system_mail_t)
allow privmail sendmail_exec_t:lnk_file { getattr read };
ifdef(`crond.te', `
# Read cron temporary files.
2005-06-09 15:32:23 +00:00
allow system_mail_t system_crond_tmp_t:file r_file_perms;
allow mta_user_agent system_crond_tmp_t:file r_file_perms;
2005-05-12 20:50:09 +00:00
')
ifdef(`qmail.te', `
allow system_mail_t qmail_etc_t:dir search;
allow system_mail_t qmail_etc_t:{ file lnk_file } read;
')dnl end if qmail
ifdef(`targeted_policy', `
# rules are currently defined in sendmail.te, but it is not included in
# targeted policy. We could move these rules permanantly here.
ifdef(`postfix.te', `', `
2005-06-13 17:35:46 +00:00
domain_exec_all_entry_files(system_mail_t)
files_exec_etc_files(system_mail_t)
2005-06-13 17:35:46 +00:00
corecmd_exec_bin(system_mail_t)
corecmd_exec_sbin(system_mail_t)
libs_use_ld_so(system_mail_t)
libs_use_shared_libs(system_mail_t)
libs_exec_ld_so(system_mail_t)
libs_exec_lib_files(system_mail_t)
2005-05-12 20:50:09 +00:00
')
allow system_mail_t { var_t var_spool_t }:dir getattr;
2005-06-09 15:32:23 +00:00
allow system_mail_t mqueue_spool_t:dir create_dir_perms;
allow system_mail_t mqueue_spool_t:file create_file_perms;
allow system_mail_t mqueue_spool_t:lnk_file create_lnk_perms;
2005-05-12 20:50:09 +00:00
2005-06-09 15:32:23 +00:00
allow system_mail_t mail_spool_t:dir create_dir_perms;
allow system_mail_t mail_spool_t:file create_file_perms;
allow system_mail_t mail_spool_t:lnk_file create_lnk_perms;
2005-05-12 20:50:09 +00:00
allow system_mail_t mail_spool_t:fifo_file rw_file_perms;
2005-06-09 15:32:23 +00:00
allow system_mail_t etc_mail_t:file r_file_perms;
2005-05-12 20:50:09 +00:00
', ` dnl if not targeted policy:
2005-05-13 14:37:13 +00:00
optional_policy(`sendmail.te', `
2005-05-12 20:50:09 +00:00
# sendmail has an ugly design, the one process parses input from the user and
# then does system things with it.
domain_auto_trans(initrc_t, sendmail_exec_t, sendmail_t)
2005-05-13 14:37:13 +00:00
')
2005-05-12 20:50:09 +00:00
# allow the sysadmin to do "mail someone < /home/user/whatever"
allow sysadm_mail_t user_home_dir_type:dir search;
r_dir_file(sysadm_mail_t, user_home_type)
') dnl end ifdef targeted_policy
# for a mail server process that does things in response to a user command
allow mta_user_agent userdomain:process sigchld;
allow mta_user_agent { userdomain privfd }:fd use;
ifdef(`crond.te', `
allow mta_user_agent crond_t:process sigchld;
')
allow mta_user_agent sysadm_t:fifo_file { read write };
allow { system_mail_t mta_user_agent } privmail:fd use;
allow { system_mail_t mta_user_agent } privmail:process sigchld;
allow { system_mail_t mta_user_agent } privmail:fifo_file { read write };
allow { system_mail_t mta_user_agent } admin_tty_type:chr_file { read write };
ifdef(`arpwatch.te', `
# why is mail delivered to a directory of type arpwatch_data_t?
allow mta_delivery_agent arpwatch_data_t:dir search;
allow { system_mail_t mta_user_agent } arpwatch_tmp_t:file rw_file_perms;
ifdef(`hide_broken_symptoms', `
dontaudit { system_mail_t mta_user_agent } arpwatch_t:packet_socket { read write };
')
')dnl end if arpwatch.te
allow mta_delivery_agent home_root_t:dir { getattr search };
# for /var/spool/mail
ra_dir_create_file(mta_delivery_agent, mail_spool_t)
# for piping mail to a command
can_exec(mta_delivery_agent, shell_exec_t)
allow mta_delivery_agent bin_t:dir search;
allow mta_delivery_agent bin_t:lnk_file read;
2005-06-09 15:32:23 +00:00
allow mta_delivery_agent { etc_runtime_t proc_t }:file r_file_perms;
2005-05-12 20:50:09 +00:00
# Transition from a system domain to the derived domain.
domain_auto_trans(privmail, sendmail_exec_t, system_mail_t)
2005-06-09 15:32:23 +00:00
allow privmail sendmail_exec_t:lnk_file r_file_perms;
2005-05-12 20:50:09 +00:00
ifdef(`crond.te', `
# Read cron temporary files.
2005-06-09 15:32:23 +00:00
allow system_mail_t system_crond_tmp_t:file r_file_perms;
allow mta_user_agent system_crond_tmp_t:file r_file_perms;
2005-05-12 20:50:09 +00:00
')
2005-06-28 20:54:49 +00:00
optional_policy(`logrotate.te', `
allow { system_mail_t mta_user_agent } logrotate_tmp_t:file r_file_perms;
')
2005-05-12 20:50:09 +00:00
') dnl end TODO