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

265 lines
7.2 KiB
Plaintext
Raw Normal View History

2005-05-02 19:24:29 +00:00
2005-11-15 20:27:49 +00:00
policy_module(mta,1.0.1)
2005-05-02 19:24:29 +00:00
2005-05-12 20:50:09 +00:00
########################################
#
# Declarations
#
2005-08-30 20:47:41 +00:00
attribute mta_user_agent;
attribute mailserver_delivery;
attribute mailserver_domain;
attribute mailserver_sender;
2005-10-23 20:18:36 +00:00
attribute user_mail_domain;
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;
2005-10-24 18:40:24 +00:00
files_config_file(etc_mail_t)
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
2005-10-25 00:00:50 +00:00
type system_mail_t, user_mail_domain;
2005-06-13 17:35:46 +00:00
domain_type(system_mail_t)
2005-10-18 18:25:33 +00:00
domain_entry_file(system_mail_t,sendmail_exec_t)
2005-05-12 20:50:09 +00:00
role system_r types system_mail_t;
2005-10-28 18:38:04 +00:00
type system_mail_tmp_t;
files_tmp_file(system_mail_tmp_t)
2005-10-18 18:25:33 +00:00
# cjp: need to resolve this, but require{}
# does not work in the else part of the optional
#ifdef(`targeted_policy',`',`
# optional_policy(`sendmail',`',`
2005-10-18 18:25:33 +00:00
# init_system_domain(system_mail_t,sendmail_exec_t)
# ')
#')
2005-05-13 14:37:13 +00:00
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-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
allow system_mail_t etc_mail_t:dir { getattr search };
2005-10-25 20:27:08 +00:00
allow system_mail_t etc_mail_t:file r_file_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
2005-10-28 18:38:04 +00:00
allow system_mail_t system_mail_tmp_t:dir create_dir_perms;
allow system_mail_t system_mail_tmp_t:file create_file_perms;
files_create_tmp_files(system_mail_t, system_mail_tmp_t, { file dir })
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_sendrecv_all_ports(system_mail_t)
2005-09-15 21:03:29 +00:00
corenet_tcp_bind_all_nodes(system_mail_t)
2005-10-25 20:27:08 +00:00
corenet_tcp_connect_smtp_port(system_mail_t)
2005-10-31 14:55:34 +00:00
corenet_tcp_connect_all_ports(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-09-15 21:03:29 +00:00
dev_read_rand(system_mail_t)
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
files_read_etc_files(system_mail_t)
2005-08-30 20:47:41 +00:00
files_read_etc_runtime_files(system_mail_t)
files_search_spool(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-08-30 20:47:41 +00:00
corecmd_search_sbin(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-09-15 21:03:29 +00:00
sysnet_dns_name_resolve(system_mail_t)
2005-05-12 20:50:09 +00:00
2005-08-30 20:47:41 +00:00
userdom_use_sysadm_terms(system_mail_t)
2005-11-11 22:21:32 +00:00
ifdef(`hide_broken_symptoms',`
# Red Hat systems seem to have a stray
# fds open from the initrd
ifdef(`distro_redhat',`
kernel_dontaudit_use_fd(system_mail_t)
storage_dontaudit_read_fixed_disk(system_mail_t)
')
')
2005-08-30 20:47:41 +00:00
ifdef(`targeted_policy',`
2005-10-14 18:42:42 +00:00
typealias system_mail_t alias sysadm_mail_t;
2005-08-30 20:47:41 +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;
allow system_mail_t mail_spool_t:fifo_file rw_file_perms;
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-10-25 00:00:50 +00:00
# for reading .forward - maybe we need a new type for it?
# also for delivering mail to maildir
# cjp: fix this to generic_user interfaces
userdom_manage_user_home_subdirs(user,mailserver_delivery)
userdom_manage_user_home_subdir_files(user,mailserver_delivery)
userdom_manage_user_home_subdir_symlinks(user,mailserver_delivery)
userdom_manage_user_home_subdir_pipes(user,mailserver_delivery)
userdom_manage_user_home_subdir_sockets(user,mailserver_delivery)
userdom_create_user_home(user,mailserver_delivery,{ dir file lnk_file fifo_file sock_file })
# cjp: another require-in-else to resolve
# optional_policy(`postfix',`',`
2005-08-30 20:47:41 +00:00
corecmd_exec_bin(system_mail_t)
corecmd_exec_sbin(system_mail_t)
domain_exec_all_entry_files(system_mail_t)
files_exec_etc_files(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-08-30 20:47:41 +00:00
')
optional_policy(`apache',`
2005-10-17 17:55:38 +00:00
apache_read_squirrelmail_data(system_mail_t)
apache_append_squirrelmail_data(system_mail_t)
# apache should set close-on-exec
apache_dontaudit_append_log(system_mail_t)
apache_dontaudit_rw_stream_socket(system_mail_t)
apache_dontaudit_rw_tcp_socket(system_mail_t)
apache_dontaudit_rw_sys_script_stream_socket(system_mail_t)
')
optional_policy(`arpwatch',`
2005-10-25 20:27:08 +00:00
arpwatch_rw_tmp_files(system_mail_t)
')
optional_policy(`cron',`
2005-08-30 20:47:41 +00:00
cron_read_system_job_tmp_files(system_mail_t)
')
optional_policy(`cvs',`
2005-09-20 18:49:13 +00:00
cvs_read_data(system_mail_t)
')
optional_policy(`logrotate',`
2005-08-30 20:47:41 +00:00
logrotate_read_tmp_files(system_mail_t)
')
optional_policy(`nis',`
2005-06-27 16:30:55 +00:00
nis_use_ypbind(system_mail_t)
')
optional_policy(`nscd',`
2005-07-13 20:48:51 +00:00
nscd_use_socket(system_mail_t)
')
optional_policy(`postfix',`
2005-10-23 20:18:36 +00:00
postfix_stub(system_mail_t)
allow system_mail_t etc_aliases_t:dir create_dir_perms;
allow system_mail_t etc_aliases_t:file create_file_perms;
allow system_mail_t etc_aliases_t:lnk_file create_lnk_perms;
allow system_mail_t etc_aliases_t:sock_file create_file_perms;
allow system_mail_t etc_aliases_t:fifo_file create_file_perms;
2005-10-25 02:51:07 +00:00
files_create_etc_config(system_mail_t,etc_aliases_t,{ file lnk_file sock_file fifo_file })
2005-10-23 20:18:36 +00:00
2005-11-09 15:51:22 +00:00
domain_use_wide_inherit_fd(system_mail_t)
optional_policy(`crond',`
2005-10-23 20:18:36 +00:00
cron_crw_tcp_socket(system_mail_t)
')
2005-11-08 22:00:30 +00:00
allow mta_user_agent sysadm_t:fifo_file { read write };
type_transition postfix_master_t postfix_etc_t:dir etc_aliases_t;
2005-10-23 20:18:36 +00:00
')
optional_policy(`procmail',`
2005-11-15 20:27:49 +00:00
procmail_exec(system_mail_t)
')
optional_policy(`sendmail',`
2005-10-23 20:18:36 +00:00
sendmail_stub(system_mail_t)
2005-10-18 18:25:33 +00:00
allow system_mail_t etc_mail_t:dir { getattr search };
2005-05-13 14:37:13 +00:00
# sendmail -q
allow system_mail_t mqueue_spool_t:dir rw_dir_perms;
allow system_mail_t mqueue_spool_t:file create_file_perms;
2005-11-09 15:51:22 +00:00
# FIXME:
allow system_mail_t sendmail_log_t:file manage_file_perms;
logging_create_log(system_mail_t,sendmail_log_t)
2005-08-30 20:47:41 +00:00
')
ifdef(`TODO',`
optional_policy(`sendmail',`
2005-08-30 20:47:41 +00:00
allow system_mail_t { var_t var_spool_t }:dir getattr;
dontaudit system_mail_t userpty_type:chr_file { getattr read write };
optional_policy(`crond',`
dontaudit system_mail_t system_crond_tmp_t:file append;
')
2005-05-13 14:37:13 +00:00
')
2005-05-12 20:50:09 +00:00
2005-08-30 20:47:41 +00:00
ifdef(`targeted_policy',`
allow system_mail_t { var_t var_spool_t }:dir getattr;
',`
# 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)
2005-05-13 14:37:13 +00:00
')
2005-05-12 20:50:09 +00:00
optional_policy(`qmail',`
2005-08-30 20:47:41 +00:00
allow system_mail_t qmail_etc_t:dir search;
allow system_mail_t qmail_etc_t:{ file lnk_file } read;
2005-06-28 20:54:49 +00:00
')
2005-11-08 22:00:30 +00:00
') dnl end TODO
allow mta_user_agent system_crond_tmp_t:file { read getattr };
optional_policy(`arpwatch',`
# why is mail delivered to a directory of type arpwatch_data_t?
2005-11-08 22:00:30 +00:00
arpwatch_search_data(mailserver_delivery)
arpwatch_manage_tmp_files(system_mail_t)
arpwatch_manage_tmp_files(mta_user_agent)
ifdef(`hide_broken_symptoms', `
arpwatch_dontaudit_rw_packet_socket(system_mail_t)
arpwatch_dontaudit_rw_packet_socket(mta_user_agent)
')
')