Chris PeBenito 0fbfa5
#DESC Courier - POP and IMAP servers
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Author:  Russell Coker <russell@coker.com.au>
Chris PeBenito 0fbfa5
# X-Debian-Packages: courier-base
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Type for files created during execution of courier.
Chris PeBenito 0fbfa5
type courier_var_run_t, file_type, sysadmfile, pidfile;
Chris PeBenito 0fbfa5
type courier_var_lib_t, file_type, sysadmfile;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
type courier_etc_t, file_type, sysadmfile;
Chris PeBenito 0fbfa5
typealias courier_etc_t alias etc_courier_t;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# allow start scripts to read the config
Chris PeBenito 0fbfa5
allow initrc_t courier_etc_t:file r_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
type courier_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 0fbfa5
type sqwebmail_cron_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
define(`courier_domain', `
Chris PeBenito 0fbfa5
#################################
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Rules for the courier_$1_t domain.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# courier_$1_exec_t is the type of the courier_$1 executables.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
daemon_base_domain(courier_$1, `$2')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow courier_$1_t var_run_t:dir search;
Chris PeBenito 0fbfa5
rw_dir_create_file(courier_$1_t, courier_var_run_t)
Chris PeBenito 0fbfa5
allow courier_$1_t courier_var_run_t:sock_file create_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# allow it to read config files etc
Chris PeBenito 0fbfa5
allow courier_$1_t { courier_etc_t var_t }:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t courier_etc_t:file r_file_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t etc_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t etc_t:file r_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# execute scripts etc
Chris PeBenito 0fbfa5
allow courier_$1_t { bin_t courier_$1_exec_t }:file rx_file_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t bin_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t fs_t:filesystem getattr;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# set process group and allow permissions over-ride
Chris PeBenito 0fbfa5
allow courier_$1_t self:process setpgid;
Chris PeBenito 0fbfa5
allow courier_$1_t self:capability dac_override;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use the network.
Chris PeBenito 0fbfa5
can_network_server(courier_$1_t)
Chris PeBenito 0fbfa5
allow courier_$1_t self:fifo_file { read write getattr };
Chris PeBenito 0fbfa5
allow courier_$1_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow courier_$1_t null_device_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# allow it to log to /dev/tty
Chris PeBenito 0fbfa5
allow courier_$1_t devtty_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow courier_$1_t { usr_t etc_runtime_t }:file r_file_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t usr_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t root_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
can_exec(courier_$1_t, courier_$1_exec_t)
Chris PeBenito 0fbfa5
can_exec(courier_$1_t, bin_t)
Chris PeBenito 0fbfa5
allow courier_$1_t bin_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow courier_$1_t proc_t:dir r_dir_perms;
Chris PeBenito 0fbfa5
allow courier_$1_t proc_t:file r_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
')dnl
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
courier_domain(authdaemon, `, auth_chkpwd')
Chris PeBenito 0fbfa5
allow courier_authdaemon_t sbin_t:dir search;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t lib_t:file { read getattr };
Chris PeBenito 0fbfa5
allow courier_authdaemon_t tmp_t:dir getattr;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t self:file { getattr read };
Chris PeBenito 0fbfa5
read_locale(courier_authdaemon_t)
Chris PeBenito 0fbfa5
can_exec(courier_authdaemon_t, courier_exec_t)
Chris PeBenito 0fbfa5
dontaudit courier_authdaemon_t selinux_config_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for SSP
Chris PeBenito 0fbfa5
allow courier_authdaemon_t urandom_device_t:chr_file read;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# should not be needed!
Chris PeBenito 0fbfa5
allow courier_authdaemon_t home_root_t:dir search;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t user_home_dir_type:dir search;
Chris PeBenito 0fbfa5
dontaudit courier_authdaemon_t sysadm_home_dir_t:dir search;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t self:unix_stream_socket connectto;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t self:capability { setuid setgid sys_tty_config };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
courier_domain(tcpd)
Chris PeBenito 0fbfa5
allow courier_tcpd_t self:capability { kill net_bind_service };
Chris PeBenito 0fbfa5
allow courier_tcpd_t pop_port_t:tcp_socket name_bind;
Chris PeBenito 0fbfa5
allow courier_tcpd_t sbin_t:dir search;
Chris PeBenito 0fbfa5
allow courier_tcpd_t var_lib_t:dir search;
Chris PeBenito 0fbfa5
# for TLS
Chris PeBenito 0fbfa5
allow courier_tcpd_t urandom_device_t:chr_file read;
Chris PeBenito 0fbfa5
read_locale(courier_tcpd_t)
Chris PeBenito 0fbfa5
can_exec(courier_tcpd_t, courier_exec_t)
Chris PeBenito 0fbfa5
allow courier_authdaemon_t courier_tcpd_t:{ unix_stream_socket tcp_socket } rw_stream_socket_perms;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t courier_tcpd_t:process sigchld;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
can_tcp_connect(userdomain, courier_tcpd_t)
Chris PeBenito 0fbfa5
rw_dir_create_file(courier_tcpd_t, courier_var_lib_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# domain for pop and imap
Chris PeBenito 0fbfa5
courier_domain(pop)
Chris PeBenito 0fbfa5
read_locale(courier_pop_t)
Chris PeBenito 0fbfa5
domain_auto_trans(courier_tcpd_t, courier_pop_exec_t, courier_pop_t)
Chris PeBenito 0fbfa5
allow courier_pop_t courier_tcpd_t:{ unix_stream_socket tcp_socket } rw_stream_socket_perms;
Chris PeBenito 0fbfa5
domain_auto_trans(courier_pop_t, courier_authdaemon_exec_t, courier_authdaemon_t)
Chris PeBenito 0fbfa5
allow courier_pop_t courier_authdaemon_t:tcp_socket rw_stream_socket_perms;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t courier_tcpd_t:fd use;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t courier_tcpd_t:tcp_socket rw_stream_socket_perms;
Chris PeBenito 0fbfa5
allow courier_authdaemon_t courier_tcpd_t:fifo_file rw_file_perms;
Chris PeBenito 0fbfa5
allow courier_pop_t courier_authdaemon_t:process sigchld;
Chris PeBenito 0fbfa5
domain_auto_trans(courier_authdaemon_t, courier_pop_exec_t, courier_pop_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# inherits file handle - should it?
Chris PeBenito 0fbfa5
allow courier_pop_t courier_var_lib_t:file { read write };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# do the actual work (read the Maildir)
Chris PeBenito 0fbfa5
# imap needs to write files
Chris PeBenito 0fbfa5
allow courier_pop_t home_root_t:dir { getattr search };
Chris PeBenito 0fbfa5
allow courier_pop_t user_home_dir_type:dir { getattr search };
Chris PeBenito 0fbfa5
# pop does not need to create subdirs, IMAP does
Chris PeBenito 0fbfa5
#rw_dir_create_file(courier_pop_t, user_home_type)
Chris PeBenito 0fbfa5
create_dir_file(courier_pop_t, user_home_type)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for calendaring
Chris PeBenito 0fbfa5
courier_domain(pcp)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow courier_pcp_t self:capability { setuid setgid };
Chris PeBenito 0fbfa5
allow courier_pcp_t random_device_t:chr_file r_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for webmail
Chris PeBenito 0fbfa5
courier_domain(sqwebmail)
Chris PeBenito 0fbfa5
ifdef(`crond.te', `
Chris PeBenito 0fbfa5
system_crond_entry(sqwebmail_cron_exec_t, courier_sqwebmail_t)
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
read_sysctl(courier_sqwebmail_t)