Chris PeBenito 31b7c0
#DESC Amavis - Anti-virus
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Author:  Brian May <bam@snoopy.apana.org.au>
Chris PeBenito 31b7c0
# X-Debian-Packages: amavis-ng amavisd-new amavisd-new-milter amavisd-new-milter-helper
Chris PeBenito 31b7c0
# Depends: clamav.te
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the amavisd_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
type amavisd_etc_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
type amavisd_lib_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Virus and spam found and quarantined.
Chris PeBenito 31b7c0
type amavisd_quarantine_t, file_type, sysadmfile, tmpfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
daemon_domain(amavisd)
Chris PeBenito 31b7c0
tmp_domain(amavisd)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow initrc_t amavisd_etc_t:file { getattr read };
Chris PeBenito 31b7c0
allow initrc_t amavisd_lib_t:dir { search read write rmdir remove_name unlink };
Chris PeBenito 31b7c0
allow initrc_t amavisd_lib_t:file unlink;
Chris PeBenito 31b7c0
allow initrc_t amavisd_var_run_t:dir setattr;
Chris PeBenito 31b7c0
allow amavisd_t self:capability { chown dac_override setgid setuid };
Chris PeBenito 31b7c0
dontaudit amavisd_t self:capability sys_tty_config;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow amavisd_t usr_t:{ file lnk_file } { getattr read };
Chris PeBenito 31b7c0
dontaudit amavisd_t usr_t:file ioctl;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# networking
Chris PeBenito 31b7c0
can_network_server_tcp(amavisd_t, amavisd_recv_port_t)
Chris PeBenito 31b7c0
allow amavisd_t amavisd_recv_port_t:tcp_socket name_bind;
Chris PeBenito 31b7c0
allow mta_delivery_agent amavisd_recv_port_t:tcp_socket name_connect;
Chris PeBenito 31b7c0
# The next line doesn't work right so drop the port specification.
Chris PeBenito 31b7c0
#can_network_client_tcp(amavisd_t, amavisd_send_port_t)
Chris PeBenito 31b7c0
can_network_client_tcp(amavisd_t)
Chris PeBenito 31b7c0
allow amavisd_t amavisd_send_port_t:tcp_socket name_connect;
Chris PeBenito 31b7c0
can_resolve(amavisd_t);
Chris PeBenito 31b7c0
can_ypbind(amavisd_t);
Chris PeBenito 31b7c0
can_tcp_connect(mail_server_sender, amavisd_t);
Chris PeBenito 31b7c0
can_tcp_connect(amavisd_t, mail_server_domain)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`scannerdaemon.te', `
Chris PeBenito 31b7c0
can_tcp_connect(amavisd_t, scannerdaemon_t);
Chris PeBenito 31b7c0
allow scannerdaemon_t amavisd_lib_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow scannerdaemon_t amavisd_lib_t:file r_file_perms;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`clamav.te', `
Chris PeBenito 31b7c0
clamscan_domain(amavisd)
Chris PeBenito 31b7c0
role system_r types amavisd_clamscan_t;
Chris PeBenito 31b7c0
domain_auto_trans(amavisd_t, clamscan_exec_t, amavisd_clamscan_t)
Chris PeBenito 31b7c0
allow amavisd_clamscan_t amavisd_lib_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow amavisd_clamscan_t amavisd_lib_t:file r_file_perms;
Chris PeBenito 31b7c0
can_clamd_connect(amavisd)
Chris PeBenito 31b7c0
allow clamd_t amavisd_lib_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow clamd_t amavisd_lib_t:file r_file_perms;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# DCC
Chris PeBenito 31b7c0
ifdef(`dcc.te', `
Chris PeBenito 31b7c0
allow dcc_client_t amavisd_lib_t:file r_file_perms;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Pyzor
Chris PeBenito 31b7c0
ifdef(`pyzor.te',`
Chris PeBenito 31b7c0
domain_auto_trans(amavisd_t, pyzor_exec_t, pyzor_t)
Chris PeBenito 31b7c0
#allow pyzor_t amavisd_data_t:dir search;
Chris PeBenito 31b7c0
# Pyzor creates a temp file adjacent to the working file.
Chris PeBenito 31b7c0
create_dir_file(pyzor_t, amavisd_lib_t);
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# SpamAssassin is executed from within amavisd, but needs to read its
Chris PeBenito 31b7c0
# config
Chris PeBenito 31b7c0
ifdef(`spamd.te', `
Chris PeBenito 31b7c0
r_dir_file(amavisd_t, etc_mail_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Can create unix sockets
Chris PeBenito 31b7c0
allow amavisd_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow amavisd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 31b7c0
allow amavisd_t self:fifo_file getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
read_locale(amavisd_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access config files (amavisd).
Chris PeBenito 31b7c0
allow amavisd_t amavisd_etc_t:file r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
log_domain(amavisd)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access amavisd var/lib files.
Chris PeBenito 31b7c0
create_dir_file(amavisd_t, amavisd_lib_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access amavisd quarantined files.
Chris PeBenito 31b7c0
create_dir_file(amavisd_t, amavisd_quarantine_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Run helper programs.
Chris PeBenito 31b7c0
can_exec_any(amavisd_t,bin_t)
Chris PeBenito 31b7c0
allow amavisd_t bin_t:dir { getattr search };
Chris PeBenito 31b7c0
allow amavisd_t sbin_t:dir search;
Chris PeBenito 31b7c0
allow amavisd_t var_lib_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# allow access to files for scanning (required for amavis):
Chris PeBenito 31b7c0
allow clamd_t self:capability { dac_override dac_read_search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# unknown stuff
Chris PeBenito 31b7c0
allow amavisd_t self:fifo_file { ioctl read write };
Chris PeBenito 31b7c0
allow amavisd_t { random_device_t urandom_device_t }:chr_file read;
Chris PeBenito 31b7c0
allow amavisd_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
allow amavisd_t etc_runtime_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# broken stuff
Chris PeBenito 31b7c0
dontaudit amavisd_t sysadm_home_dir_t:dir search;
Chris PeBenito 31b7c0
dontaudit amavisd_t shadow_t:file { getattr read };
Chris PeBenito 31b7c0
dontaudit amavisd_t sysadm_devpts_t:chr_file { read write };
Chris PeBenito 31b7c0