Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
1.99k stars 573 forks source link

Calling `icingacli` via the Icinga2 agent is blocked by SELinux #9796

Open NavidSassan opened 1 year ago

NavidSassan commented 1 year ago

Calling icingacli via the Icinga2 agent is blocked by SELinux. This results in the following error message:

Module path "/usr/share/icingaweb2/modules" does not exist
ERROR: Cannot read enabled modules. Config directory "/etc/icingaweb2" is not readable

To Reproduce

For example, when trying to check a business process on a host with SELinux enabled:

  1. Create some process in the businessprocess module.
  2. Create a service template and service that checks the state of the process using the icingacli-businessprocess external command:

    template Service "tpl-service-bp" {
    check_command = "icingacli-businessprocess"
    vars.icingacli_businessprocess_details = true
    }
    object Service "tpl-service-bp" {
    host_name = "myhost"
    import "tpl-service-bp"
    
    vars.icingacli_businessprocess_config = "test"
    vars.icingacli_businessprocess_process = "first"
    }
  3. Trigger the service via Icinga2. Note that the service is UNKNOWN.
  4. Disable SELinux: setenforce 0.
  5. Trigger the service via Icinga2. Note that the service is OK.

Note that the problem cannot be reproduced when using sudo, it only happens when executed via the Icinga2 agent:

sudo -u icinga icingacli businessprocess process check first --config test --details
Business Process OK: first

Expected behavior

Using icingacli to check the state of modules on a host with SELinux enabled should work out of the box, or at least via a SELinux boolean.

Your Environment

Additional context

SELinux Booleans:

getsebool -a | grep -E 'icinga|nagios'
httpd_can_connect_icinga2_api --> on
httpd_can_manage_icingaweb2_config --> on
httpd_can_write_icinga2_command --> on
icinga2_can_connect_all --> on
icinga2_run_sudo --> on
icinga2adm_exec_content --> on
logging_syslogd_run_nagios_plugins --> off
nagios_run_pnp4nagios --> off
nagios_run_sudo --> on
nagios_use_nfs --> off
tbauriedel commented 1 year ago

ref/NC/788116

RincewindsHat commented 1 month ago

ref/NC/825504

lippserd commented 3 weeks ago

ref/IP/54807