Chris PeBenito e181fe
Chris PeBenito 960373
policy_module(logging,1.0)
Chris PeBenito 960373
Chris PeBenito eb7f9a
########################################
Chris PeBenito eb7f9a
#
Chris PeBenito eb7f9a
# Declarations
Chris PeBenito eb7f9a
#
Chris PeBenito eb7f9a
Chris PeBenito b4cd15
attribute logfile;
Chris PeBenito b4cd15
Chris PeBenito eb7f9a
type auditd_log_t;
Chris PeBenito c9428d
logging_log_file(auditd_t,auditd_log_t)
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
type auditd_t;
Chris PeBenito eb7f9a
type auditd_exec_t;
Chris PeBenito c9428d
init_daemon_domain(auditd_t,auditd_exec_t)
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
type auditd_var_run_t;
Chris PeBenito c9428d
files_pid_file(auditd_var_run_t)
Chris PeBenito eb7f9a
Chris PeBenito 4ddc1a
type devlog_t;
Chris PeBenito c9428d
files_file_type(devlog_t)
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
type klogd_t;
Chris PeBenito 4ddc1a
type klogd_exec_t;
Chris PeBenito c9428d
init_daemon_domain(klogd_t,klogd_exec_t)
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
type klogd_tmp_t;
Chris PeBenito c9428d
files_tmp_file(klogd_tmp_t)
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
type klogd_var_run_t;
Chris PeBenito c9428d
files_pid_file(klogd_var_run_t)
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
type syslogd_t;
Chris PeBenito 4ddc1a
type syslogd_exec_t;
Chris PeBenito c9428d
init_daemon_domain(syslogd_t,syslogd_exec_t)
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
type syslogd_tmp_t;
Chris PeBenito c9428d
files_tmp_file(syslogd_tmp_t)
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
type syslogd_var_run_t;
Chris PeBenito c9428d
files_pid_file(syslogd_var_run_t)
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
type var_log_t, logfile;
Chris PeBenito c9428d
files_file_type(var_log_t)
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
########################################
Chris PeBenito 4ddc1a
#
Chris PeBenito eb7f9a
# Auditd local policy
Chris PeBenito eb7f9a
#
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
allow auditd_t self:capability { audit_write audit_control };
Chris PeBenito eb7f9a
dontaudit auditd_t self:capability sys_tty_config;
Chris PeBenito eb7f9a
allow auditd_t self:netlink_audit_socket { bind create getattr nlmsg_read nlmsg_write read write };
Chris PeBenito eb7f9a
Chris PeBenito cc41a9
allow auditd_t auditd_log_t:file create_file_perms;
Chris PeBenito eb7f9a
Chris PeBenito cc41a9
allow auditd_t auditd_var_run_t:file create_file_perms;
Chris PeBenito c9428d
files_create_pid(auditd_t,auditd_var_run_t)
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
kernel_read_kernel_sysctl(auditd_t)
Chris PeBenito d35c62
Chris PeBenito 8bd678
dev_read_sysfs(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito 0fd9dc
fs_getattr_all_fs(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito 0fd9dc
term_dontaudit_use_console(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito c9428d
init_use_fd(auditd_t)
Chris PeBenito c9428d
init_use_script_pty(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito c9428d
domain_use_wide_inherit_fd(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito c9428d
files_read_generic_etc_files(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito c9428d
logging_send_syslog_msg(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito c9428d
libs_use_ld_so(auditd_t)
Chris PeBenito c9428d
libs_use_shared_libs(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
miscfiles_read_localization(auditd_t)
Chris PeBenito eb7f9a
Chris PeBenito 763c44
ifdef(`targeted_policy', `
Chris PeBenito 0fd9dc
	term_dontaudit_use_unallocated_tty(auditd_t)
Chris PeBenito 31908b
	term_dontaudit_use_generic_pty(auditd_t)
Chris PeBenito c9428d
	files_dontaudit_read_root_file(auditd_t)
Chris PeBenito eb7f9a
')
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
optional_policy(`selinux.te',`
Chris PeBenito 5e0da6
	seutil_newrole_sigchld(auditd_t)
Chris PeBenito eb7f9a
')
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
optional_policy(`udev.te', `
Chris PeBenito c9428d
	udev_read_db(auditd_t)
Chris PeBenito eb7f9a
')
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
ifdef(`TODO',`
Chris PeBenito eb7f9a
allow auditd_t proc_t:dir r_dir_perms;
Chris PeBenito eb7f9a
allow auditd_t proc_t:lnk_file read;
Chris PeBenito eb7f9a
dontaudit auditd_t unpriv_userdomain:fd use;
Chris PeBenito eb7f9a
allow auditd_t autofs_t:dir { search getattr };
Chris PeBenito eb7f9a
dontaudit auditd_t sysadm_home_dir_t:dir search;
Chris PeBenito eb7f9a
optional_policy(`rhgb.te', `
Chris PeBenito eb7f9a
allow auditd_t rhgb_t:process sigchld;
Chris PeBenito eb7f9a
allow auditd_t rhgb_t:fd use;
Chris PeBenito eb7f9a
allow auditd_t rhgb_t:fifo_file { read write };
Chris PeBenito eb7f9a
')
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
# cjp: this is questionable:
Chris PeBenito eb7f9a
allow auditd_t sysadm_tty_device_t:chr_file rw_file_perms;
Chris PeBenito eb7f9a
') dnl endif TODO
Chris PeBenito eb7f9a
Chris PeBenito eb7f9a
########################################
Chris PeBenito eb7f9a
#
Chris PeBenito 4ddc1a
# klogd local policy
Chris PeBenito 4ddc1a
#
Chris PeBenito 4ddc1a
Chris PeBenito 3b857e
allow klogd_t klogd_tmp_t:file create_file_perms;
Chris PeBenito c9428d
files_create_tmp_files(klogd_t,klogd_tmp_t)
Chris PeBenito daa0e0
Chris PeBenito 3b857e
allow klogd_t klogd_var_run_t:file create_file_perms;
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
allow klogd_t self:capability sys_admin;
Chris PeBenito 4ddc1a
dontaudit klogd_t self:capability sys_resource;
Chris PeBenito 4ddc1a
Chris PeBenito 4ddc1a
kernel_read_system_state(klogd_t)
Chris PeBenito 219bcf
kernel_read_messages(klogd_t)
Chris PeBenito 219bcf
# Control syslog and console logging
Chris PeBenito 219bcf
kernel_clear_ring_buffer(klogd_t)
Chris PeBenito 219bcf
kernel_change_ring_buffer_level(klogd_t)
Chris PeBenito 219bcf
Chris PeBenito 219bcf
bootloader_read_kernel_symbol_table(klogd_t)
Chris PeBenito 4ddc1a
Karl MacMillan f0c985
dev_read_raw_memory(klogd_t)
Chris PeBenito 4ddc1a
Chris PeBenito 0fd9dc
fs_getattr_all_fs(klogd_t)
Chris PeBenito 4ddc1a
Chris PeBenito c9428d
files_create_pid(klogd_t,klogd_var_run_t)
Chris PeBenito c9428d
files_read_etc_runtime_files(klogd_t)
Chris PeBenito 4ddc1a
# read /etc/nsswitch.conf
Chris PeBenito c9428d
files_read_generic_etc_files(klogd_t)
Chris PeBenito 4ddc1a
Chris PeBenito c9428d
init_use_fd(klogd_t)
Chris PeBenito 3b857e
Chris PeBenito c9428d
libs_use_ld_so(klogd_t)
Chris PeBenito c9428d
libs_use_shared_libs(klogd_t)
Chris PeBenito 4ddc1a
Chris PeBenito c9428d
logging_send_syslog_msg(klogd_t)
Chris PeBenito 4ddc1a
Chris PeBenito daa0e0
miscfiles_read_localization(klogd_t)
Chris PeBenito daa0e0
Chris PeBenito 4ddc1a
########################################
Chris PeBenito 4ddc1a
#
Chris PeBenito 4ddc1a
# syslogd local policy
Chris PeBenito 4ddc1a
#
Chris PeBenito 219bcf
Chris PeBenito 219bcf
allow syslogd_t self:capability { dac_override net_bind_service sys_resource sys_tty_config };
Chris PeBenito 55f456
dontaudit syslogd_t self:capability sys_tty_config;
Chris PeBenito d115b2
allow syslogd_t self:process signal_perms;
Chris PeBenito d115b2
Chris PeBenito d115b2
# receive messages to be logged
Chris PeBenito cc41a9
allow syslogd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito cc41a9
allow syslogd_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito d115b2
allow syslogd_t self:unix_dgram_socket sendto;
Chris PeBenito cc41a9
allow syslogd_t self:fifo_file rw_file_perms;
Chris PeBenito cc41a9
allow syslogd_t self:udp_socket { connected_socket_perms connect };
Chris PeBenito 219bcf
Chris PeBenito 55f456
# create/append log files.
Chris PeBenito 3b857e
allow syslogd_t var_log_t:dir rw_dir_perms;
Chris PeBenito 3b857e
allow syslogd_t var_log_t:file create_file_perms;
Chris PeBenito 4ddc1a
Chris PeBenito 55f456
# manage temporary files
Chris PeBenito 3b857e
allow syslogd_t syslogd_tmp_t:file create_file_perms;
Chris PeBenito c9428d
files_create_tmp_files(syslogd_t,syslogd_tmp_t)
Chris PeBenito 3b857e
Chris PeBenito 3b857e
allow syslogd_t syslogd_var_run_t:file create_file_perms;
Chris PeBenito c9428d
files_create_pid(syslogd_t,syslogd_var_run_t,file)
Chris PeBenito 219bcf
Chris PeBenito 219bcf
# Create and bind to /dev/log or /var/run/log.
Chris PeBenito cc41a9
allow syslogd_t devlog_t:sock_file create_file_perms;
Chris PeBenito c9428d
files_create_pid(syslogd_t,devlog_t,sock_file)
Chris PeBenito d115b2
# I belive these are not needed:
Chris PeBenito d115b2
allow syslogd_t devlog_t:unix_stream_socket name_bind;
Chris PeBenito d115b2
allow syslogd_t devlog_t:unix_dgram_socket name_bind;
Chris PeBenito 219bcf
Chris PeBenito 55f456
# manage pid file
Chris PeBenito cc41a9
allow syslogd_t syslogd_var_run_t:file create_file_perms;
Chris PeBenito c9428d
files_create_pid(syslogd_t,syslogd_var_run_t)
Chris PeBenito 55f456
Chris PeBenito 55f456
kernel_read_kernel_sysctl(syslogd_t)
Chris PeBenito 219bcf
Karl MacMillan f0c985
dev_create_dev_node(syslogd_t,devlog_t,sock_file)
Chris PeBenito d35c62
dev_read_sysfs(syslogd_t)
Chris PeBenito 55f456
Chris PeBenito 0fd9dc
term_dontaudit_use_console(syslogd_t)
Chris PeBenito daa0e0
# Allow syslog to a terminal
Chris PeBenito 0fd9dc
term_write_unallocated_ttys(syslogd_t)
Chris PeBenito daa0e0
Chris PeBenito daa0e0
# for sending messages to logged in users
Chris PeBenito c9428d
init_read_script_pid(syslogd_t)
Chris PeBenito c9428d
init_dontaudit_write_script_pid(syslogd_t)
Chris PeBenito 0fd9dc
term_write_all_user_ttys(syslogd_t)
Chris PeBenito 219bcf
Chris PeBenito 0fd9dc
corenet_raw_sendrecv_all_if(syslogd_t)
Chris PeBenito 0fd9dc
corenet_udp_sendrecv_all_if(syslogd_t)
Chris PeBenito 0fd9dc
corenet_raw_sendrecv_all_nodes(syslogd_t)
Chris PeBenito 0fd9dc
corenet_udp_sendrecv_all_nodes(syslogd_t)
Chris PeBenito 0fd9dc
corenet_udp_sendrecv_all_ports(syslogd_t)
Chris PeBenito 0fd9dc
corenet_udp_bind_all_nodes(syslogd_t)
Chris PeBenito 0fd9dc
corenet_udp_bind_syslogd_port(syslogd_t)
Chris PeBenito 219bcf
Chris PeBenito 0fd9dc
fs_getattr_all_fs(syslogd_t)
Chris PeBenito 219bcf
Chris PeBenito c9428d
init_use_fd(syslogd_t)
Chris PeBenito c9428d
init_use_script_pty(syslogd_t)
Chris PeBenito 55f456
Chris PeBenito c9428d
domain_use_wide_inherit_fd(syslogd_t)
Chris PeBenito 25baab
Chris PeBenito c9428d
files_read_generic_etc_files(syslogd_t)
Chris PeBenito 219bcf
Chris PeBenito c9428d
libs_use_ld_so(syslogd_t)
Chris PeBenito c9428d
libs_use_shared_libs(syslogd_t)
Chris PeBenito 219bcf
Chris PeBenito c9428d
sysnet_read_config(syslogd_t)
Chris PeBenito 91a7ab
Chris PeBenito 219bcf
miscfiles_read_localization(syslogd_t)
Chris PeBenito 219bcf
Chris PeBenito c9428d
userdom_dontaudit_use_unpriv_user_fd(syslogd_t)
Chris PeBenito daa0e0
Chris PeBenito 219bcf
#
Chris PeBenito 219bcf
# /initrd is not umounted before minilog starts
Chris PeBenito 219bcf
#
Chris PeBenito c9428d
files_dontaudit_search_isid_type_dir(syslogd_t)
Chris PeBenito daa0e0
#allow syslogd_t tmpfs_t:dir search;
Chris PeBenito 219bcf
#dontaudit syslogd_t unlabeled_t:file read;
Chris PeBenito 219bcf
#dontaudit syslogd_t { userpty_type devpts_t }:chr_file getattr;
Chris PeBenito 219bcf
allow syslogd_t self:capability net_admin;
Chris PeBenito cc41a9
allow syslogd_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito 219bcf
Chris PeBenito 219bcf
ifdef(`klogd.te', `', `
Chris PeBenito 0c73cd
	# Allow access to /proc/kmsg for syslog-ng
Chris PeBenito 0c73cd
	kernel_read_messages(syslogd_t)
Chris PeBenito 0c73cd
	kernel_clear_ring_buffer(syslogd_t)
Chris PeBenito 0c73cd
	kernel_change_ring_buffer_level(syslogd_t)
Chris PeBenito 219bcf
')
Chris PeBenito 219bcf
Chris PeBenito 763c44
ifdef(`targeted_policy', `
Chris PeBenito 0fd9dc
	term_dontaudit_use_unallocated_tty(syslogd_t)
Chris PeBenito 31908b
	term_dontaudit_use_generic_pty(syslogd_t)
Chris PeBenito c9428d
	files_dontaudit_read_root_file(syslogd_t)
Chris PeBenito 3b857e
')
Chris PeBenito 3b857e
Chris PeBenito 25baab
optional_policy(`selinux.te',`
Chris PeBenito 5e0da6
	seutil_newrole_sigchld(syslogd_t)
Chris PeBenito 25baab
')
Chris PeBenito 25baab
Chris PeBenito 300981
optional_policy(`udev.te', `
Chris PeBenito c9428d
	udev_read_db(syslogd_t)
Chris PeBenito 25baab
')
Chris PeBenito 25baab
Chris PeBenito 3b857e
optional_policy(`cron.te',`
Chris PeBenito c9428d
	cron_rw_log(syslogd_t)
Chris PeBenito 25baab
')
Chris PeBenito 55f456
Chris PeBenito 219bcf
ifdef(`TODO',`
Chris PeBenito 55f456
allow syslogd_t proc_t:lnk_file read;
Chris PeBenito 55f456
allow syslogd_t autofs_t:dir { search getattr };
Chris PeBenito 55f456
dontaudit syslogd_t sysadm_home_dir_t:dir search;
Chris PeBenito 25baab
optional_policy(`rhgb.te', `
Chris PeBenito 0c73cd
	allow syslogd_t rhgb_t:process sigchld;
Chris PeBenito 0c73cd
	allow syslogd_t rhgb_t:fd use;
Chris PeBenito 0c73cd
	allow syslogd_t rhgb_t:fifo_file { read write };
Chris PeBenito 55f456
')
Chris PeBenito 25baab
tunable_policy(`direct_sysadm_daemon',`
Chris PeBenito 0c73cd
	dontaudit syslogd_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito 55f456
')
Chris PeBenito 219bcf
Chris PeBenito 254bbc
ifdef(`distro_suse', `
Chris PeBenito 0c73cd
	# suse creates a /dev/log under /var/lib/stunnel for chrooted stunnel
Chris PeBenito 0c73cd
	file_type_auto_trans(syslogd_t, var_lib_t, devlog_t, sock_file)
Chris PeBenito 1e5c2a
')
Chris PeBenito 1e5c2a
Chris PeBenito 219bcf
# can_network is for the UDP socket
Chris PeBenito 219bcf
can_ypbind(syslogd_t)
Chris PeBenito 219bcf
Chris PeBenito 219bcf
# log to the xconsole
Chris PeBenito 219bcf
allow syslogd_t xconsole_device_t:fifo_file { ioctl read write };
Chris PeBenito 219bcf
Chris PeBenito 219bcf
ifdef(`crond.te', `
Chris PeBenito 0c73cd
	# for daemon re-start
Chris PeBenito 0c73cd
	allow system_crond_t syslogd_t:lnk_file read;
Chris PeBenito 219bcf
')
Chris PeBenito 219bcf
Chris PeBenito 219bcf
ifdef(`logrotate.te', `
Chris PeBenito 0c73cd
	allow logrotate_t syslogd_exec_t:file r_file_perms;
Chris PeBenito 219bcf
')
Chris PeBenito 219bcf
Chris PeBenito 219bcf
#
Chris PeBenito 219bcf
# Special case to handle crashes
Chris PeBenito 219bcf
#
Chris PeBenito 219bcf
allow syslogd_t { device_t file_t }:sock_file unlink;
Chris PeBenito 219bcf
') dnl end TODO