Chris PeBenito 31b7c0
#DESC Logrotate - Rotate log files
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil>   Timothy Fraser  
Chris PeBenito 31b7c0
#           Russell Coker <rcoker@redhat.com>
Chris PeBenito 31b7c0
# X-Debian-Packages: logrotate
Chris PeBenito 31b7c0
# Depends: crond.te
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the logrotate_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# logrotate_t is the domain for the logrotate program.
Chris PeBenito 31b7c0
# logrotate_exec_t is the type of the corresponding program.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
type logrotate_t, domain, privowner, privmail, priv_system_role, nscd_client_domain, mlsfileread, mlsfilewrite, mlsfileupgrade;
Chris PeBenito 31b7c0
role system_r types logrotate_t;
Chris PeBenito 31b7c0
role sysadm_r types logrotate_t;
Chris PeBenito 31b7c0
uses_shlib(logrotate_t)
Chris PeBenito 31b7c0
general_domain_access(logrotate_t)
Chris PeBenito 31b7c0
type logrotate_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
system_crond_entry(logrotate_exec_t, logrotate_t)
Chris PeBenito 31b7c0
allow logrotate_t cron_spool_t:dir search;
Chris PeBenito 31b7c0
allow crond_t logrotate_var_lib_t:dir search;
Chris PeBenito 31b7c0
domain_auto_trans(sysadm_t, logrotate_exec_t, logrotate_t)
Chris PeBenito 31b7c0
allow logrotate_t self:unix_stream_socket create_socket_perms;
Chris PeBenito 31b7c0
allow logrotate_t devtty_t:chr_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`distro_debian', `
Chris PeBenito 31b7c0
allow logrotate_t logrotate_tmp_t:file { relabelfrom relabelto };
Chris PeBenito 31b7c0
# for savelog
Chris PeBenito 31b7c0
can_exec(logrotate_t, logrotate_exec_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for perl
Chris PeBenito 31b7c0
allow logrotate_t usr_t:file { getattr read ioctl };
Chris PeBenito 31b7c0
allow logrotate_t usr_t:lnk_file read;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access files in /etc
Chris PeBenito 31b7c0
allow logrotate_t etc_t:file { getattr read ioctl };
Chris PeBenito 31b7c0
allow logrotate_t etc_t:lnk_file { getattr read };
Chris PeBenito 31b7c0
allow logrotate_t etc_runtime_t:file r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# it should not require this
Chris PeBenito 31b7c0
allow logrotate_t {staff_home_dir_t sysadm_home_dir_t}:dir { getattr read search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# create lock files
Chris PeBenito 31b7c0
lock_domain(logrotate)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Create temporary files.
Chris PeBenito 31b7c0
tmp_domain(logrotate)
Chris PeBenito 31b7c0
can_exec(logrotate_t, logrotate_tmp_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Run helper programs.
Chris PeBenito 31b7c0
allow logrotate_t { bin_t sbin_t }:dir r_dir_perms;
Chris PeBenito 31b7c0
allow logrotate_t { bin_t sbin_t }:lnk_file read;
Chris PeBenito 31b7c0
can_exec(logrotate_t, { bin_t sbin_t shell_exec_t ls_exec_t })
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read PID files.
Chris PeBenito 31b7c0
allow logrotate_t pidfile:file r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read /proc/PID directories for all domains.
Chris PeBenito 31b7c0
read_sysctl(logrotate_t)
Chris PeBenito 31b7c0
allow logrotate_t proc_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow logrotate_t proc_t:{ file lnk_file } r_file_perms;
Chris PeBenito 31b7c0
allow logrotate_t domain:notdevfile_class_set r_file_perms;
Chris PeBenito 31b7c0
allow logrotate_t domain:dir r_dir_perms;
Chris PeBenito 31b7c0
allow logrotate_t exec_type:file getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read /dev directories and any symbolic links.
Chris PeBenito 31b7c0
allow logrotate_t device_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow logrotate_t device_t:lnk_file r_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Signal processes.
Chris PeBenito 31b7c0
allow logrotate_t domain:process signal;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Modify /var/log and other log dirs.
Chris PeBenito 31b7c0
allow logrotate_t var_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow logrotate_t logfile:dir rw_dir_perms;
Chris PeBenito 31b7c0
allow logrotate_t logfile:lnk_file read;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Create, rename, and truncate log files.
Chris PeBenito 31b7c0
allow logrotate_t logfile:file create_file_perms;
Chris PeBenito 31b7c0
allow logrotate_t wtmp_t:file create_file_perms;
Chris PeBenito 31b7c0
ifdef(`squid.te', `
Chris PeBenito 31b7c0
allow squid_t { system_crond_t crond_t }:fd use;
Chris PeBenito 31b7c0
allow squid_t crond_t:fifo_file { read write };
Chris PeBenito 31b7c0
allow squid_t system_crond_t:fifo_file write;
Chris PeBenito 31b7c0
allow squid_t self:capability kill;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Set a context other than the default one for newly created files.
Chris PeBenito 31b7c0
can_setfscreate(logrotate_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Change ownership on log files.
Chris PeBenito 31b7c0
allow logrotate_t self:capability { chown dac_override dac_read_search kill fsetid fowner sys_resource sys_nice };
Chris PeBenito 31b7c0
# for mailx
Chris PeBenito 31b7c0
dontaudit logrotate_t self:capability { setuid setgid };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`mta.te', `
Chris PeBenito 31b7c0
allow { system_mail_t mta_user_agent } logrotate_tmp_t:file r_file_perms;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access /var/run
Chris PeBenito 31b7c0
allow logrotate_t var_run_t:dir r_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for /var/lib/logrotate.status and /var/lib/logcheck
Chris PeBenito 31b7c0
var_lib_domain(logrotate)
Chris PeBenito 31b7c0
allow logrotate_t logrotate_var_lib_t:dir create;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Write to /var/spool/slrnpull - should be moved into its own type.
Chris PeBenito 31b7c0
create_dir_file(logrotate_t, var_spool_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow logrotate_t urandom_device_t:chr_file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access terminals.
Chris PeBenito 31b7c0
allow logrotate_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito 31b7c0
ifdef(`gnome-pty-helper.te', `allow logrotate_t sysadm_gph_t:fd use;')
Chris PeBenito 31b7c0
allow logrotate_t privfd:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for /var/backups on Debian
Chris PeBenito 31b7c0
ifdef(`backup.te', `
Chris PeBenito 31b7c0
rw_dir_create_file(logrotate_t, backup_store_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
read_locale(logrotate_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow logrotate_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
can_exec(logrotate_t, shell_exec_t)
Chris PeBenito 31b7c0
ifdef(`hostname.te', `can_exec(logrotate_t, hostname_exec_t)')
Chris PeBenito 31b7c0
can_exec(logrotate_t,logfile)
Chris PeBenito 31b7c0
allow logrotate_t net_conf_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`consoletype.te', `
Chris PeBenito 31b7c0
can_exec(logrotate_t, consoletype_exec_t)
Chris PeBenito 31b7c0
dontaudit consoletype_t logrotate_t:fd use;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow logrotate_t syslogd_t:unix_dgram_socket sendto;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
domain_auto_trans(logrotate_t, initrc_exec_t, initrc_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Supress libselinux initialization denials
Chris PeBenito 31b7c0
dontaudit logrotate_t selinux_config_t:dir search;
Chris PeBenito 31b7c0
dontaudit logrotate_t selinux_config_t:file { read getattr };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow selinux_getenforce 
Chris PeBenito 31b7c0
allow logrotate_t security_t:dir search;
Chris PeBenito 31b7c0
allow logrotate_t security_t:file { getattr read };