Chris PeBenito ab58ad
#DESC Syslogd - System log daemon
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser  
Chris PeBenito ab58ad
# X-Debian-Packages: sysklogd syslog-ng
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the syslogd_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# syslogd_t is the domain of syslogd.
Chris PeBenito ab58ad
# syslogd_exec_t is the type of the syslogd executable.
Chris PeBenito ab58ad
# devlog_t is the type of the Unix domain socket created 
Chris PeBenito ab58ad
# by syslogd.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
ifdef(`klogd.te', `
Chris PeBenito ab58ad
daemon_domain(syslogd, `, privkmsg, nscd_client_domain')
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
daemon_domain(syslogd, `, privmem, privkmsg, nscd_client_domain')
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# can_network is for the UDP socket
Chris PeBenito ab58ad
can_network_udp(syslogd_t)
Chris PeBenito ab58ad
can_ypbind(syslogd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
r_dir_file(syslogd_t, sysfs_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
type devlog_t, file_type, sysadmfile, dev_fs, mlstrustedobject;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# if something can log to syslog they should be able to log to the console
Chris PeBenito ab58ad
allow privlog console_device_t:chr_file { ioctl read write getattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
tmp_domain(syslogd)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# read files in /etc
Chris PeBenito ab58ad
allow syslogd_t { etc_runtime_t etc_t }:file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities.
Chris PeBenito ab58ad
allow syslogd_t self:capability { dac_override net_admin net_bind_service sys_resource sys_tty_config };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Modify/create log files.
Chris PeBenito ab58ad
create_append_log_file(syslogd_t, var_log_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Create and bind to /dev/log or /var/run/log.
Chris PeBenito ab58ad
file_type_auto_trans(syslogd_t, { device_t var_run_t }, devlog_t, sock_file)
Chris PeBenito ab58ad
ifdef(`distro_suse', `
Chris PeBenito ab58ad
# suse creates a /dev/log under /var/lib/stunnel for chrooted stunnel
Chris PeBenito ab58ad
file_type_auto_trans(syslogd_t, var_lib_t, devlog_t, sock_file)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
allow syslogd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow syslogd_t self:unix_dgram_socket sendto;
Chris PeBenito ab58ad
allow syslogd_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
allow syslogd_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
allow syslogd_t devlog_t:unix_stream_socket name_bind;
Chris PeBenito ab58ad
allow syslogd_t devlog_t:unix_dgram_socket name_bind;
Chris PeBenito ab58ad
# log to the xconsole
Chris PeBenito ab58ad
allow syslogd_t xconsole_device_t:fifo_file { ioctl read write };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Domains with the privlog attribute may log to syslogd.
Chris PeBenito ab58ad
allow privlog devlog_t:sock_file rw_file_perms;
Chris PeBenito ab58ad
can_unix_send(privlog,syslogd_t)
Chris PeBenito ab58ad
can_unix_connect(privlog,syslogd_t)
Chris PeBenito ab58ad
# allow /dev/log to be a link elsewhere for chroot setup
Chris PeBenito ab58ad
allow privlog devlog_t:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`crond.te', `
Chris PeBenito ab58ad
# for daemon re-start
Chris PeBenito ab58ad
allow system_crond_t syslogd_t:lnk_file read;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`logrotate.te', `
Chris PeBenito ab58ad
allow logrotate_t syslogd_exec_t:file r_file_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for sending messages to logged in users
Chris PeBenito ab58ad
allow syslogd_t initrc_var_run_t:file { read lock };
Chris PeBenito ab58ad
dontaudit syslogd_t initrc_var_run_t:file write;
Chris PeBenito ab58ad
allow syslogd_t ttyfile:chr_file { getattr write };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Special case to handle crashes
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
allow syslogd_t { device_t file_t }:sock_file { getattr unlink };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow syslog to a terminal
Chris PeBenito ab58ad
allow syslogd_t tty_device_t:chr_file { getattr write ioctl append };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow name_bind for remote logging
Chris PeBenito ab58ad
allow syslogd_t syslogd_port_t:udp_socket name_bind;
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# /initrd is not umounted before minilog starts
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
dontaudit syslogd_t file_t:dir search;
Chris PeBenito ab58ad
allow syslogd_t { tmpfs_t devpts_t }:dir search;
Chris PeBenito ab58ad
dontaudit syslogd_t unlabeled_t:file { getattr read };
Chris PeBenito ab58ad
dontaudit syslogd_t { userpty_type devpts_t }:chr_file getattr;
Chris PeBenito ab58ad
allow syslogd_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito ab58ad
ifdef(`targeted_policy', `
Chris PeBenito ab58ad
allow syslogd_t var_run_t:fifo_file { ioctl read write };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow access to /proc/kmsg for syslog-ng
Chris PeBenito ab58ad
allow syslogd_t proc_t:dir search;
Chris PeBenito ab58ad
allow syslogd_t proc_kmsg_t:file { getattr read };
Chris PeBenito ab58ad
allow syslogd_t kernel_t:system { syslog_mod syslog_console };
Chris PeBenito ab58ad
allow syslogd_t self:capability { sys_admin chown fsetid };
Chris PeBenito ab58ad
allow syslogd_t var_log_t:dir { create setattr };
Chris PeBenito ab58ad
allow syslogd_t syslogd_port_t:tcp_socket name_bind;
Chris PeBenito ab58ad
allow syslogd_t rsh_port_t:tcp_socket name_connect;