From 99bbe348818654e983d471c18eb4d36249417f77 Mon Sep 17 00:00:00 2001 From: Jeremy Solt Date: Mon, 24 May 2010 09:42:59 -0400 Subject: [PATCH] Nagios patch from Dan Walsh Edits: - Removed permissive lines - Removed tunable for broken symptoms - Style and whitespace fixes --- policy/modules/services/nagios.fc | 92 +++++++++-- policy/modules/services/nagios.if | 140 ++++++++++++++++- policy/modules/services/nagios.te | 245 +++++++++++++++++++++++++----- 3 files changed, 426 insertions(+), 51 deletions(-) diff --git a/policy/modules/services/nagios.fc b/policy/modules/services/nagios.fc index 4f8477c3f..1fc990575 100644 --- a/policy/modules/services/nagios.fc +++ b/policy/modules/services/nagios.fc @@ -1,16 +1,88 @@ -/etc/nagios(/.*)? gen_context(system_u:object_r:nagios_etc_t,s0) -/etc/nagios/nrpe\.cfg -- gen_context(system_u:object_r:nrpe_etc_t,s0) +/etc/nagios(/.*)? gen_context(system_u:object_r:nagios_etc_t,s0) +/etc/nagios/nrpe\.cfg -- gen_context(system_u:object_r:nrpe_etc_t,s0) +/etc/rc\.d/init\.d/nagios -- gen_context(system_u:object_r:nagios_initrc_exec_t,s0) +/etc/rc\.d/init\.d/nrpe -- gen_context(system_u:object_r:nagios_initrc_exec_t,s0) -/usr/bin/nagios -- gen_context(system_u:object_r:nagios_exec_t,s0) -/usr/bin/nrpe -- gen_context(system_u:object_r:nrpe_exec_t,s0) +/usr/s?bin/nagios -- gen_context(system_u:object_r:nagios_exec_t,s0) +/usr/s?bin/nrpe -- gen_context(system_u:object_r:nrpe_exec_t,s0) -/usr/lib(64)?/cgi-bin/netsaint/.+ -- gen_context(system_u:object_r:nagios_cgi_exec_t,s0) -/usr/lib(64)?/nagios/cgi/.+ -- gen_context(system_u:object_r:nagios_cgi_exec_t,s0) +/usr/lib(64)?/cgi-bin/netsaint(/.*)? gen_context(system_u:object_r:httpd_nagios_script_exec_t,s0) +/usr/lib(64)?/nagios/cgi(/.*)? gen_context(system_u:object_r:httpd_nagios_script_exec_t,s0) -/var/log/nagios(/.*)? gen_context(system_u:object_r:nagios_log_t,s0) -/var/log/netsaint(/.*)? gen_context(system_u:object_r:nagios_log_t,s0) +/var/log/nagios(/.*)? gen_context(system_u:object_r:nagios_log_t,s0) +/var/log/netsaint(/.*)? gen_context(system_u:object_r:nagios_log_t,s0) + +/var/run/nagios.* gen_context(system_u:object_r:nagios_var_run_t,s0) + +/var/spool/nagios(/.*)? gen_context(system_u:object_r:nagios_spool_t,s0) ifdef(`distro_debian',` -/usr/sbin/nagios -- gen_context(system_u:object_r:nagios_exec_t,s0) -/usr/lib/cgi-bin/nagios/.+ -- gen_context(system_u:object_r:nagios_cgi_exec_t,s0) +/usr/sbin/nagios -- gen_context(system_u:object_r:nagios_exec_t,s0) ') +/usr/lib(64)?/cgi-bin/nagios(/.+)? gen_context(system_u:object_r:httpd_nagios_script_exec_t,s0) +/usr/lib(64)?/nagios/cgi-bin(/.*)? gen_context(system_u:object_r:httpd_nagios_script_exec_t,s0) + +# admin plugins +/usr/lib(64)?/nagios/plugins/check_file_age -- gen_context(system_u:object_r:nagios_admin_plugin_exec_t,s0) + +# check disk plugins +/usr/lib(64)?/nagios/plugins/check_disk -- gen_context(system_u:object_r:nagios_checkdisk_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_disk_smb -- gen_context(system_u:object_r:nagios_checkdisk_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ide_smart -- gen_context(system_u:object_r:nagios_checkdisk_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_linux_raid -- gen_context(system_u:object_r:nagios_checkdisk_plugin_exec_t,s0) + +# mail plugins +/usr/lib(64)?/nagios/plugins/check_mailq -- gen_context(system_u:object_r:nagios_mail_plugin_exec_t,s0) + +# system plugins +/usr/lib(64)?/nagios/plugins/check_breeze -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_dummy -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_flexlm -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ifoperstatus -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ifstatus -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_load -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_log -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_mrtg -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_mrtgtraf -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_nagios -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_nwstat -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_overcr -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_procs -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_sensors -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_swap -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_users -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_wave -- gen_context(system_u:object_r:nagios_system_plugin_exec_t,s0) + +# services plugins +/usr/lib(64)?/nagios/plugins/check_cluster -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_dhcp -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_dig -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_dns -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_game -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_fping -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_hpjd -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_http -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_icmp -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ircd -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ldap -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_mysql -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_mysql_query -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_nrpe -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_nt -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ntp.* -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_oracle -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_pgsql -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ping -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_radius -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_real -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_rpc -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_tcp -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_time -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_sip -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_smtp -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_snmp.* -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ssh -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) +/usr/lib(64)?/nagios/plugins/check_ups -- gen_context(system_u:object_r:nagios_services_plugin_exec_t,s0) + +# unconfined plugins +/usr/lib(64)?/nagios/plugins/check_by_ssh -- gen_context(system_u:object_r:nagios_unconfined_plugin_exec_t,s0) diff --git a/policy/modules/services/nagios.if b/policy/modules/services/nagios.if index 82691c053..2f041734f 100644 --- a/policy/modules/services/nagios.if +++ b/policy/modules/services/nagios.if @@ -1,5 +1,44 @@ ## Net Saint / NAGIOS - network monitoring server +######################################## +## +## Create a set of derived types for various +## nagios plugins, +## +## +## +## The name to be used for deriving type names. +## +## +# +template(`nagios_plugin_template',` + + gen_require(` + type nagios_t, nrpe_t; + type nagios_log_t; + ') + + type nagios_$1_plugin_t; + type nagios_$1_plugin_exec_t; + application_domain(nagios_$1_plugin_t, nagios_$1_plugin_exec_t) + role system_r types nagios_$1_plugin_t; + + allow nagios_$1_plugin_t self:fifo_file rw_fifo_file_perms; + + domtrans_pattern(nrpe_t, nagios_$1_plugin_exec_t, nagios_$1_plugin_t) + + # needed by command.cfg + domtrans_pattern(nagios_t, nagios_$1_plugin_exec_t, nagios_$1_plugin_t) + + allow nagios_t nagios_$1_plugin_t:process signal_perms; + + # cjp: leaked file descriptor + dontaudit nagios_$1_plugin_t nrpe_t:tcp_socket { read write }; + dontaudit nagios_$1_plugin_t nagios_log_t:file { read write }; + + miscfiles_read_localization(nagios_$1_plugin_t) +') + ######################################## ## ## Do not audit attempts to read or write nagios @@ -42,6 +81,44 @@ interface(`nagios_read_config',` files_search_etc($1) ') +###################################### +## +## Read nagios logs. +## +## +## +## Domain allowed access. +## +## +# +interface(`nagios_read_log',` + gen_require(` + type nagios_log_t; + ') + + logging_search_logs($1) + read_files_pattern($1, nagios_log_t, nagios_log_t) +') + +######################################## +## +## Search nagios spool directories. +## +## +## +## Domain allowed access. +## +## +# +interface(`nagios_search_spool',` + gen_require(` + type nagios_spool_t; + ') + + allow $1 nagios_spool_t:dir search_dir_perms; + files_search_spool($1) +') + ######################################## ## ## Allow the specified domain to read @@ -64,8 +141,8 @@ interface(`nagios_read_tmp_files',` ######################################## ## -## Execute the nagios CGI with -## a domain transition. +## Allow the specified domain to read +## nagios temporary files. ## ## ## @@ -73,12 +150,13 @@ interface(`nagios_read_tmp_files',` ## ## # -interface(`nagios_domtrans_cgi',` +interface(`nagios_rw_inherited_tmp_files',` gen_require(` - type nagios_cgi_t, nagios_cgi_exec_t; + type nagios_tmp_t; ') - domtrans_pattern($1, nagios_cgi_exec_t, nagios_cgi_t) + allow $1 nagios_tmp_t:file rw_inherited_file_perms; + files_search_tmp($1) ') ######################################## @@ -99,3 +177,55 @@ interface(`nagios_domtrans_nrpe',` domtrans_pattern($1, nrpe_exec_t, nrpe_t) ') + +######################################## +## +## All of the rules required to administrate +## an nagios environment +## +## +## +## Domain allowed access. +## +## +## +## +## The role to be allowed to manage the nagios domain. +## +## +## +# +interface(`nagios_admin',` + gen_require(` + type nagios_t, nrpe_t; + type nagios_tmp_t, nagios_log_t; + type nagios_etc_t, nrpe_etc_t; + type nagios_spool_t, nagios_var_run_t; + type nagios_initrc_exec_t; + ') + + allow $1 nagios_t:process { ptrace signal_perms }; + ps_process_pattern($1, nagios_t) + + init_labeled_script_domtrans($1, nagios_initrc_exec_t) + domain_system_change_exemption($1) + role_transition $2 nagios_initrc_exec_t system_r; + allow $2 system_r; + + files_list_tmp($1) + admin_pattern($1, nagios_tmp_t) + + logging_list_logs($1) + admin_pattern($1, nagios_log_t) + + files_list_etc($1) + admin_pattern($1, nagios_etc_t) + + files_list_spool($1) + admin_pattern($1, nagios_spool_t) + + files_list_pids($1) + admin_pattern($1, nagios_var_run_t) + + admin_pattern($1, nrpe_etc_t) +') diff --git a/policy/modules/services/nagios.te b/policy/modules/services/nagios.te index 32aabdcb2..6436e2655 100644 --- a/policy/modules/services/nagios.te +++ b/policy/modules/services/nagios.te @@ -10,13 +10,12 @@ type nagios_t; type nagios_exec_t; init_daemon_domain(nagios_t, nagios_exec_t) -type nagios_cgi_t; -type nagios_cgi_exec_t; -init_system_domain(nagios_cgi_t, nagios_cgi_exec_t) - type nagios_etc_t; files_config_file(nagios_etc_t) +type nagios_initrc_exec_t; +init_script_file(nagios_initrc_exec_t) + type nagios_log_t; logging_log_file(nagios_log_t) @@ -26,6 +25,20 @@ files_tmp_file(nagios_tmp_t) type nagios_var_run_t; files_pid_file(nagios_var_run_t) +type nagios_spool_t; +files_type(nagios_spool_t) + +nagios_plugin_template(admin) +nagios_plugin_template(checkdisk) +nagios_plugin_template(mail) +nagios_plugin_template(services) +nagios_plugin_template(system) + +type nagios_system_plugin_tmp_t; +files_tmp_file(nagios_system_plugin_tmp_t) + +nagios_plugin_template(unconfined) + type nrpe_t; type nrpe_exec_t; init_daemon_domain(nrpe_t, nrpe_exec_t) @@ -33,6 +46,13 @@ init_daemon_domain(nrpe_t, nrpe_exec_t) type nrpe_etc_t; files_config_file(nrpe_etc_t) +type nrpe_var_run_t; +files_pid_file(nrpe_var_run_t) + +optional_policy(` + unconfined_domain(nagios_unconfined_plugin_t) +') + ######################################## # # Nagios local policy @@ -60,6 +80,9 @@ files_tmp_filetrans(nagios_t, nagios_tmp_t, { file dir }) manage_files_pattern(nagios_t, nagios_var_run_t, nagios_var_run_t) files_pid_filetrans(nagios_t, nagios_var_run_t, file) +manage_fifo_files_pattern(nagios_t, nagios_spool_t, nagios_spool_t) +files_spool_filetrans(nagios_t, nagios_spool_t, fifo_file) + kernel_read_system_state(nagios_t) kernel_read_kernel_sysctls(nagios_t) @@ -76,6 +99,9 @@ corenet_tcp_sendrecv_all_ports(nagios_t) corenet_udp_sendrecv_all_ports(nagios_t) corenet_tcp_connect_all_ports(nagios_t) +corenet_dontaudit_tcp_bind_all_reserved_ports(nagios_t) +corenet_dontaudit_udp_bind_all_reserved_ports(nagios_t) + dev_read_sysfs(nagios_t) dev_read_urand(nagios_t) @@ -86,6 +112,7 @@ domain_read_all_domains_state(nagios_t) files_read_etc_files(nagios_t) files_read_etc_runtime_files(nagios_t) files_read_kernel_symbol_table(nagios_t) +files_search_spool(nagios_t) fs_getattr_all_fs(nagios_t) fs_search_auto_mountpoints(nagios_t) @@ -118,76 +145,82 @@ optional_policy(` udev_read_db(nagios_t) ') -# cjp: leaked file descriptors: -# for open file handles -#dontaudit system_mail_t nagios_etc_t:file read; -#dontaudit system_mail_t nagios_log_t:fifo_file read; - ######################################## # # Nagios CGI local policy # +apache_content_template(nagios) +typealias httpd_nagios_script_t alias nagios_cgi_t; +typealias httpd_nagios_script_exec_t alias nagios_cgi_exec_t; -allow nagios_cgi_t self:process signal_perms; -allow nagios_cgi_t self:fifo_file rw_fifo_file_perms; +allow httpd_nagios_script_t self:process signal_perms; -read_files_pattern(nagios_cgi_t, nagios_t, nagios_t) -read_lnk_files_pattern(nagios_cgi_t, nagios_t, nagios_t) +read_files_pattern(httpd_nagios_script_t, nagios_t, nagios_t) +read_lnk_files_pattern(httpd_nagios_script_t, nagios_t, nagios_t) -allow nagios_cgi_t nagios_etc_t:dir list_dir_perms; -read_files_pattern(nagios_cgi_t, nagios_etc_t, nagios_etc_t) -read_lnk_files_pattern(nagios_cgi_t, nagios_etc_t, nagios_etc_t) +files_search_spool(httpd_nagios_script_t) +rw_fifo_files_pattern(httpd_nagios_script_t, nagios_spool_t, nagios_spool_t) -allow nagios_cgi_t nagios_log_t:dir list_dir_perms; -read_files_pattern(nagios_cgi_t, nagios_etc_t, nagios_log_t) -read_lnk_files_pattern(nagios_cgi_t, nagios_etc_t, nagios_log_t) +allow httpd_nagios_script_t nagios_etc_t:dir list_dir_perms; +read_files_pattern(httpd_nagios_script_t, nagios_etc_t, nagios_etc_t) +read_lnk_files_pattern(httpd_nagios_script_t, nagios_etc_t, nagios_etc_t) -kernel_read_system_state(nagios_cgi_t) +allow httpd_nagios_script_t nagios_log_t:dir list_dir_perms; +read_files_pattern(httpd_nagios_script_t, nagios_etc_t, nagios_log_t) +read_lnk_files_pattern(httpd_nagios_script_t, nagios_etc_t, nagios_log_t) -corecmd_exec_bin(nagios_cgi_t) +kernel_read_system_state(httpd_nagios_script_t) -domain_dontaudit_read_all_domains_state(nagios_cgi_t) +domain_dontaudit_read_all_domains_state(httpd_nagios_script_t) -files_read_etc_files(nagios_cgi_t) -files_read_etc_runtime_files(nagios_cgi_t) -files_read_kernel_symbol_table(nagios_cgi_t) +files_read_etc_runtime_files(httpd_nagios_script_t) +files_read_kernel_symbol_table(httpd_nagios_script_t) -logging_send_syslog_msg(nagios_cgi_t) -logging_search_logs(nagios_cgi_t) - -miscfiles_read_localization(nagios_cgi_t) - -optional_policy(` - apache_append_log(nagios_cgi_t) -') +logging_send_syslog_msg(httpd_nagios_script_t) ######################################## # # Nagios remote plugin executor local policy # -dontaudit nrpe_t self:capability sys_tty_config; -allow nrpe_t self:process { setpgid signal_perms }; +allow nrpe_t self:capability { setuid setgid }; +dontaudit nrpe_t self:capability {sys_tty_config sys_resource}; +allow nrpe_t self:process { setpgid signal_perms setsched setrlimit }; allow nrpe_t self:fifo_file rw_fifo_file_perms; +allow nrpe_t self:tcp_socket create_stream_socket_perms; -allow nrpe_t nrpe_etc_t:file read_file_perms; +domtrans_pattern(nrpe_t, nagios_checkdisk_plugin_exec_t, nagios_checkdisk_plugin_t) + +read_files_pattern(nrpe_t, nagios_etc_t, nagios_etc_t) files_search_etc(nrpe_t) +manage_files_pattern(nrpe_t, nrpe_var_run_t, nrpe_var_run_t) +files_pid_filetrans(nrpe_t, nrpe_var_run_t, file) +files_read_etc_files(nrpe_t) + kernel_read_system_state(nrpe_t) kernel_read_kernel_sysctls(nrpe_t) corecmd_exec_bin(nrpe_t) corecmd_exec_shell(nrpe_t) +corenet_tcp_bind_generic_node(nrpe_t) +corenet_tcp_bind_inetd_child_port(nrpe_t) +corenet_sendrecv_unlabeled_packets(nrpe_t) + dev_read_sysfs(nrpe_t) dev_read_urand(nrpe_t) domain_use_interactive_fds(nrpe_t) +domain_read_all_domains_state(nrpe_t) files_read_etc_runtime_files(nrpe_t) +fs_getattr_all_fs(nrpe_t) fs_search_auto_mountpoints(nrpe_t) +auth_use_nsswitch(nrpe_t) + logging_send_syslog_msg(nrpe_t) miscfiles_read_localization(nrpe_t) @@ -198,6 +231,10 @@ optional_policy(` inetd_tcp_service_domain(nrpe_t, nrpe_exec_t) ') +optional_policy(` + mta_send_mail(nrpe_t) +') + optional_policy(` seutil_sigchld_newrole(nrpe_t) ') @@ -209,3 +246,139 @@ optional_policy(` optional_policy(` udev_read_db(nrpe_t) ') + +##################################### +# +# local policy for admin check plugins +# + +corecmd_read_bin_files(nagios_admin_plugin_t) +corecmd_read_bin_symlinks(nagios_admin_plugin_t) + +dev_read_urand(nagios_admin_plugin_t) + +files_read_etc_files(nagios_admin_plugin_t) + +# for check_file_age plugin +files_getattr_all_dirs(nagios_admin_plugin_t) +files_getattr_all_files(nagios_admin_plugin_t) +files_getattr_all_symlinks(nagios_admin_plugin_t) +files_getattr_all_pipes(nagios_admin_plugin_t) +files_getattr_all_sockets(nagios_admin_plugin_t) +files_getattr_all_file_type_fs(nagios_admin_plugin_t) +dev_getattr_all_chr_files(nagios_admin_plugin_t) +dev_getattr_all_blk_files(nagios_admin_plugin_t) + +###################################### +# +# local policy for mail check plugins +# + +allow nagios_mail_plugin_t self:capability { setuid setgid dac_override }; + +allow nagios_mail_plugin_t self:netlink_route_socket r_netlink_socket_perms; +allow nagios_mail_plugin_t self:tcp_socket create_stream_socket_perms; +allow nagios_mail_plugin_t self:udp_socket create_socket_perms; + +kernel_read_system_state(nagios_mail_plugin_t) +kernel_read_kernel_sysctls(nagios_mail_plugin_t) + +corecmd_read_bin_files(nagios_mail_plugin_t) +corecmd_read_bin_symlinks(nagios_mail_plugin_t) + +dev_read_urand(nagios_mail_plugin_t) + +files_read_etc_files(nagios_mail_plugin_t) + +logging_send_syslog_msg(nagios_mail_plugin_t) + +sysnet_read_config(nagios_mail_plugin_t) + +nscd_dontaudit_search_pid(nagios_mail_plugin_t) + +optional_policy(` + mta_send_mail(nagios_mail_plugin_t) +') + +optional_policy(` + postfix_stream_connect_master(nagios_mail_plugin_t) + posftix_exec_postqueue(nagios_mail_plugin_t) +') + +###################################### +# +# local policy for disk check plugins +# + +# needed by ioctl() +allow nagios_checkdisk_plugin_t self:capability { sys_admin sys_rawio }; + +files_read_etc_runtime_files(nagios_checkdisk_plugin_t) + +fs_getattr_all_fs(nagios_checkdisk_plugin_t) + +storage_raw_read_fixed_disk(nagios_checkdisk_plugin_t) + +####################################### +# +# local policy for service check plugins +# +allow nagios_services_plugin_t self:capability { net_bind_service net_raw }; +allow nagios_services_plugin_t self:process { signal sigkill }; + +allow nagios_services_plugin_t self:tcp_socket create_stream_socket_perms; +allow nagios_services_plugin_t self:udp_socket create_socket_perms; + +corecmd_exec_bin(nagios_services_plugin_t) + +corenet_tcp_connect_all_ports(nagios_services_plugin_t) +corenet_udp_bind_dhcpc_port(nagios_services_plugin_t) + +auth_use_nsswitch(nagios_services_plugin_t) + +domain_read_all_domains_state(nagios_services_plugin_t) + +files_read_usr_files(nagios_services_plugin_t) + +optional_policy(` + netutils_domtrans_ping(nagios_services_plugin_t) +') + +optional_policy(` + mysql_stream_connect(nagios_services_plugin_t) +') + +optional_policy(` + snmp_read_snmp_var_lib_files(nagios_services_plugin_t) +') + +###################################### +# +# local policy for system check plugins +# + +allow nagios_system_plugin_t self:capability dac_override; +dontaudit nagios_system_plugin_t self:capability { setuid setgid }; + +# check_log +manage_files_pattern(nagios_system_plugin_t, nagios_system_plugin_tmp_t, nagios_system_plugin_tmp_t) +manage_dirs_pattern(nagios_system_plugin_t, nagios_system_plugin_tmp_t, nagios_system_plugin_tmp_t) +files_tmp_filetrans(nagios_system_plugin_t, nagios_system_plugin_tmp_t, { dir file }) + +corecmd_exec_bin(nagios_system_plugin_t) +corecmd_exec_shell(nagios_system_plugin_t) + +kernel_read_system_state(nagios_system_plugin_t) +kernel_read_kernel_sysctls(nagios_system_plugin_t) + +files_read_etc_files(nagios_system_plugin_t) + +dev_read_sysfs(nagios_system_plugin_t) +dev_read_urand(nagios_system_plugin_t) + +domain_read_all_domains_state(nagios_system_plugin_t) + +# needed by check_users plugin +optional_policy(` + init_read_utmp(nagios_system_plugin_t) +')