Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# DCC - Distributed Checksum Clearinghouse
Chris PeBenito 31b7c0
# Author:  David Hampton <hampton@employees.org>
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# NOTE: DCC has writeable files in /etc/dcc that should probably be in
Chris PeBenito 31b7c0
# /var/lib/dcc.  For now this policy supports both directories being
Chris PeBenito 31b7c0
# writable.
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Files common to all dcc programs
Chris PeBenito 31b7c0
type dcc_client_map_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
type dcc_var_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
type dcc_var_run_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# common to all dcc variants
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
define(`dcc_common',`
Chris PeBenito 31b7c0
# Access files in /var/dcc. The map file can be updated
Chris PeBenito 31b7c0
r_dir_file($1_t, dcc_var_t)
Chris PeBenito 31b7c0
allow $1_t dcc_client_map_t:file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read mtab, nsswitch and locale
Chris PeBenito 31b7c0
allow $1_t { etc_t etc_runtime_t }:file { getattr read };
Chris PeBenito 31b7c0
read_locale($1_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#Networking
Chris PeBenito 31b7c0
can_resolve($1_t)
Chris PeBenito 31b7c0
ifelse($2, `server', `
Chris PeBenito 31b7c0
can_network_udp($1_t)
Chris PeBenito 31b7c0
', `
Chris PeBenito 31b7c0
can_network_udp($1_t, `dcc_port_t')
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
allow $1_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Create private temp files
Chris PeBenito 31b7c0
tmp_domain($1)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Triggered by a call to gethostid(2) in dcc client libs
Chris PeBenito 31b7c0
allow $1_t self:unix_stream_socket { connect create };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow $1_t sysadm_su_t:process { sigchld };
Chris PeBenito 31b7c0
allow $1_t dcc_script_t:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
dontaudit $1_t kernel_t:fd use;
Chris PeBenito 31b7c0
dontaudit $1_t root_t:file read;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow initrc_t dcc_var_run_t:dir rw_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# dccd - Server daemon that can be accessed over the net
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
daemon_domain(dccd, `, privlog, nscd_client_domain')
Chris PeBenito 31b7c0
dcc_common(dccd, server);
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Runs the dbclean program
Chris PeBenito 31b7c0
allow dccd_t bin_t:dir search;
Chris PeBenito 31b7c0
domain_auto_trans(dccd_t, dcc_dbclean_exec_t, dcc_dbclean_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# The daemon needs to listen on the dcc ports
Chris PeBenito 31b7c0
allow dccd_t dcc_port_t:udp_socket name_bind;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Updating dcc_db, flod, ...
Chris PeBenito 31b7c0
create_dir_file(dccd_t, dcc_var_t);
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow dccd_t self:capability net_admin;
Chris PeBenito 31b7c0
allow dccd_t self:netlink_route_socket { bind create getattr nlmsg_read read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Reading /proc/meminfo
Chris PeBenito 31b7c0
allow dccd_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# cdcc - control dcc daemon
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
application_domain(cdcc, `, nscd_client_domain')
Chris PeBenito 31b7c0
role system_r types cdcc_t;
Chris PeBenito 31b7c0
dcc_common(cdcc)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# suid program
Chris PeBenito 31b7c0
allow cdcc_t self:capability setuid;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Running from the command line
Chris PeBenito 31b7c0
allow cdcc_t sshd_t:fd use;
Chris PeBenito 31b7c0
allow cdcc_t sysadm_devpts_t:chr_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# DCC Clients
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# dccifd  - Spamassassin and general MTA persistent client
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
daemon_domain(dccifd, `, privlog, nscd_client_domain')
Chris PeBenito 31b7c0
dcc_common(dccifd);
Chris PeBenito 31b7c0
file_type_auto_trans(dccifd_t, dcc_var_run_t, dccifd_var_run_t, file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow the domain to communicate with other processes
Chris PeBenito 31b7c0
allow dccifd_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Updating dcc_db, flod, ...
Chris PeBenito 31b7c0
create_dir_notdevfile(dccifd_t, dcc_var_t);
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Updating map, ...
Chris PeBenito 31b7c0
allow dccifd_t dcc_client_map_t:file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# dccifd communications socket
Chris PeBenito 31b7c0
type dccifd_sock_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
file_type_auto_trans(dccifd_t, dcc_var_t, dccifd_sock_t, sock_file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Reading /proc/meminfo
Chris PeBenito 31b7c0
allow dccifd_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# dccm  - sendmail milter client
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
daemon_domain(dccm, `, privlog, nscd_client_domain')
Chris PeBenito 31b7c0
dcc_common(dccm);
Chris PeBenito 31b7c0
file_type_auto_trans(dccm_t, dcc_var_run_t, dccm_var_run_t, file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow the domain to communicate with other processes
Chris PeBenito 31b7c0
allow dccm_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Updating map, ...
Chris PeBenito 31b7c0
create_dir_notdevfile(dccm_t, dcc_var_t);
Chris PeBenito 31b7c0
allow dccm_t dcc_client_map_t:file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# dccm communications socket
Chris PeBenito 31b7c0
type dccm_sock_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
file_type_auto_trans(dccm_t, dcc_var_run_t, dccm_sock_t, sock_file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# dccproc - dcc procmail interface
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
application_domain(dcc_client, `, privlog, nscd_client_domain')
Chris PeBenito 31b7c0
role system_r types dcc_client_t;
Chris PeBenito 31b7c0
dcc_common(dcc_client)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# suid program
Chris PeBenito 31b7c0
allow dcc_client_t self:capability setuid;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Running from the command line
Chris PeBenito 31b7c0
allow dcc_client_t sshd_t:fd use;
Chris PeBenito 31b7c0
allow dcc_client_t sysadm_devpts_t:chr_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# DCC Utilities
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# dbclean - database cleanup tool
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
application_domain(dcc_dbclean, `, nscd_client_domain')
Chris PeBenito 31b7c0
role system_r types dcc_dbclean_t;
Chris PeBenito 31b7c0
dcc_common(dcc_dbclean)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Updating various files.
Chris PeBenito 31b7c0
create_dir_file(dcc_dbclean_t, dcc_var_t);
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# wants to look at /proc/meminfo
Chris PeBenito 31b7c0
allow dcc_dbclean_t proc_t:dir search;
Chris PeBenito 31b7c0
allow dcc_dbclean_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Running from the command line
Chris PeBenito 31b7c0
allow dcc_dbclean_t sshd_t:fd use;
Chris PeBenito 31b7c0
allow dcc_dbclean_t sysadm_devpts_t:chr_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# DCC Startup scripts
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# These are shell sccripts that start/stop/restart the various dcc
Chris PeBenito 31b7c0
# programs.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
init_service_domain(dcc_script, `, nscd_client_domain')
Chris PeBenito 31b7c0
general_domain_access(dcc_script_t)
Chris PeBenito 31b7c0
general_proc_read_access(dcc_script_t)
Chris PeBenito 31b7c0
can_exec_any(dcc_script_t)
Chris PeBenito 31b7c0
dcc_common(dcc_script)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow calling the script from an init script (initrt_t)
Chris PeBenito 31b7c0
domain_auto_trans(initrc_t, dcc_script_exec_t, dcc_script_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Start up the daemon process.  These scripts run 'su' to change to
Chris PeBenito 31b7c0
# the dcc user (even though the default dcc user is root).
Chris PeBenito 31b7c0
allow dcc_script_t self:capability setuid;
Chris PeBenito 31b7c0
su_restricted_domain(dcc_script, system)
Chris PeBenito 31b7c0
role system_r types dcc_script_su_t;
Chris PeBenito 31b7c0
domain_auto_trans(dcc_script_su_t, dccd_exec_t, dccd_t)
Chris PeBenito 31b7c0
domain_auto_trans(dcc_script_su_t, dccm_exec_t, dccm_t)
Chris PeBenito 31b7c0
domain_auto_trans(dcc_script_su_t, dccifd_exec_t, dccifd_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Stop the daemon process
Chris PeBenito 31b7c0
allow dcc_script_t { dccifd_t dccm_t }:process { sigkill signal };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access various DCC files
Chris PeBenito 31b7c0
allow dcc_script_t { var_t var_run_t dcc_var_run_t}:dir { getattr search };
Chris PeBenito 31b7c0
allow dcc_script_t { dccifd_var_run_t dccm_var_run_t }:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow { dcc_script_t dcc_script_su_t } initrc_t:fd use;
Chris PeBenito 31b7c0
allow { dcc_script_t dcc_script_su_t } devpts_t:dir search;
Chris PeBenito 31b7c0
allow { dcc_script_t dcc_script_su_t } initrc_devpts_t:chr_file rw_file_perms;
Chris PeBenito 31b7c0
allow dcc_script_t devtty_t:chr_file { read write };
Chris PeBenito 31b7c0
allow dcc_script_su_t sysadm_home_dir_t:dir search;
Chris PeBenito 31b7c0
allow dcc_script_su_t sysadm_t:process { noatsecure rlimitinh siginh transition };
Chris PeBenito 31b7c0
allow dcc_script_su_t initrc_devpts_t:chr_file { relabelfrom relabelto };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
dontaudit dcc_script_su_t kernel_t:fd use;
Chris PeBenito 31b7c0
dontaudit dcc_script_su_t root_t:file read;
Chris PeBenito 31b7c0
dontaudit dcc_script_t { home_root_t user_home_dir_t}:dir { getattr search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow sysadm_t dcc_script_t:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# External spam checkers need to run and/or talk to DCC
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
define(`access_dcc',`
Chris PeBenito 31b7c0
domain_auto_trans($1_t, dcc_client_exec_t, dcc_client_t);
Chris PeBenito 31b7c0
allow $1_t dcc_var_t:dir search;
Chris PeBenito 31b7c0
allow $1_t dccifd_sock_t:sock_file { getattr write };
Chris PeBenito 31b7c0
allow $1_t dccifd_t:unix_stream_socket connectto;
Chris PeBenito 31b7c0
allow $1_t dcc_script_t:unix_stream_socket connectto;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`amavis.te',`access_dcc(amavisd)')
Chris PeBenito 31b7c0
ifdef(`spamd.te',`access_dcc(spamd)')