Blob Blame History Raw
policy_module(zabbix, 1.5.0)

########################################
#
# Declarations
#

## <desc>
## <p>
## Allow zabbix to connect to unreserved ports
## </p>
## </desc>
gen_tunable(zabbix_can_network, false)

type zabbix_t;
type zabbix_exec_t;
init_daemon_domain(zabbix_t, zabbix_exec_t)

type zabbix_initrc_exec_t;
init_script_file(zabbix_initrc_exec_t)

type zabbix_agent_t;
type zabbix_agent_exec_t;
init_daemon_domain(zabbix_agent_t, zabbix_agent_exec_t)

type zabbix_agent_initrc_exec_t;
init_script_file(zabbix_agent_initrc_exec_t)

# log files
type zabbix_log_t;
logging_log_file(zabbix_log_t)

# tmp files
type zabbix_tmp_t;
files_tmp_file(zabbix_tmp_t)

# shared memory
type zabbix_tmpfs_t;
files_tmpfs_file(zabbix_tmpfs_t)

# pid files
type zabbix_var_run_t;
files_pid_file(zabbix_var_run_t)

########################################
#
# zabbix local policy
#

allow zabbix_t self:capability { dac_read_search dac_override setuid setgid };
allow zabbix_t self:process { setsched signal_perms };
allow zabbix_t self:sem create_sem_perms;
allow zabbix_t self:fifo_file rw_fifo_file_perms;
allow zabbix_t self:unix_stream_socket create_stream_socket_perms;
allow zabbix_t self:sem create_sem_perms;
allow zabbix_t self:shm create_shm_perms;
allow zabbix_t self:tcp_socket create_stream_socket_perms;

# log files
allow zabbix_t zabbix_log_t:dir setattr_dir_perms;
manage_files_pattern(zabbix_t, zabbix_log_t, zabbix_log_t)
logging_log_filetrans(zabbix_t, zabbix_log_t, file)

# tmp files
manage_dirs_pattern(zabbix_t, zabbix_tmp_t, zabbix_tmp_t)
manage_files_pattern(zabbix_t, zabbix_tmp_t, zabbix_tmp_t)
files_tmp_filetrans(zabbix_t, zabbix_tmp_t, { dir file })

# shared memory
rw_files_pattern(zabbix_t, zabbix_tmpfs_t, zabbix_tmpfs_t)
fs_tmpfs_filetrans(zabbix_t, zabbix_tmpfs_t, file)

# pid file
manage_dirs_pattern(zabbix_t, zabbix_var_run_t, zabbix_var_run_t)
manage_files_pattern(zabbix_t, zabbix_var_run_t, zabbix_var_run_t)
files_pid_filetrans(zabbix_t, zabbix_var_run_t, { dir file })

kernel_read_system_state(zabbix_t)
kernel_read_kernel_sysctls(zabbix_t)

corecmd_exec_bin(zabbix_t)
corecmd_exec_shell(zabbix_t)

corenet_tcp_bind_generic_node(zabbix_t)
corenet_tcp_bind_zabbix_port(zabbix_t)
# needed by zabbix-server-mysql
corenet_tcp_connect_http_port(zabbix_t)
# to monitor ftp urls
corenet_tcp_connect_ftp_port(zabbix_t)

dev_read_urand(zabbix_t)

files_read_usr_files(zabbix_t)

auth_use_nsswitch(zabbix_t)


zabbix_agent_tcp_connect(zabbix_t)

tunable_policy(`zabbix_can_network',`
	corenet_tcp_connect_all_ports(zabbix_t)
')

optional_policy(`
	mysql_stream_connect(zabbix_t)
')

optional_policy(`
	netutils_domtrans_ping(zabbix_t)
')

optional_policy(`
	postgresql_stream_connect(zabbix_t)
')

optional_policy(`
	snmp_read_snmp_var_lib_dirs(zabbix_t)
')

########################################
#
# zabbix agent local policy
#

allow zabbix_agent_t self:capability { setuid setgid };
allow zabbix_agent_t self:process { setsched getsched signal };
allow zabbix_agent_t self:fifo_file rw_file_perms;
allow zabbix_agent_t self:sem create_sem_perms;
allow zabbix_agent_t self:shm create_shm_perms;
allow zabbix_agent_t self:tcp_socket create_stream_socket_perms;
allow zabbix_agent_t self:unix_stream_socket create_stream_socket_perms;

# Logging access
filetrans_pattern(zabbix_agent_t, zabbix_log_t, zabbix_log_t, file)
manage_files_pattern(zabbix_agent_t, zabbix_log_t, zabbix_log_t)

# Shared Memory support
rw_files_pattern(zabbix_agent_t, zabbix_tmpfs_t, zabbix_tmpfs_t)
fs_tmpfs_filetrans(zabbix_agent_t, zabbix_tmpfs_t, file)

# PID file management
manage_files_pattern(zabbix_agent_t, zabbix_var_run_t, zabbix_var_run_t)
files_pid_filetrans(zabbix_agent_t, zabbix_var_run_t, file)

kernel_read_all_sysctls(zabbix_agent_t)
kernel_read_system_state(zabbix_agent_t)

corecmd_read_all_executables(zabbix_agent_t)

corenet_tcp_bind_generic_node(zabbix_agent_t)
corenet_tcp_bind_zabbix_agent_port(zabbix_agent_t)
corenet_tcp_connect_ssh_port(zabbix_agent_t)
corenet_tcp_connect_zabbix_port(zabbix_agent_t)

dev_getattr_all_blk_files(zabbix_agent_t)
dev_getattr_all_chr_files(zabbix_agent_t)

domain_search_all_domains_state(zabbix_agent_t)

files_getattr_all_dirs(zabbix_agent_t)
files_getattr_all_files(zabbix_agent_t)
files_read_all_symlinks(zabbix_agent_t)

fs_getattr_all_fs(zabbix_agent_t)

init_read_utmp(zabbix_agent_t)

logging_search_logs(zabbix_agent_t)


sysnet_dns_name_resolve(zabbix_agent_t)

# Network access to zabbix server
zabbix_tcp_connect(zabbix_agent_t)