Bug 1380697 - selinux prevents executing scripts by zabbix-agent
Summary: selinux prevents executing scripts by zabbix-agent
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.2
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Lukas Vrabec
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-30 11:09 UTC by Eugene Peregudov
Modified: 2018-10-30 10:00 UTC (History)
6 users (show)

Fixed In Version: selinux-policy-3.13.1-203.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-30 09:59:46 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3111 None None None 2018-10-30 10:00:50 UTC

Description Eugene Peregudov 2016-09-30 11:09:53 UTC
Description of problem:

I'm trying to monitor Haproxy instance via custom script for Zabbix agent.
Default system policy contains contexts for directories with external scripts:

# semanage fcontext -l | grep zabbix | grep script
/usr/lib/zabbix/externalscripts(/.*)?              all files          system_u:object_r:zabbix_script_exec_t:s0
/var/lib/zabbix/externalscripts(/.*)?              all files          system_u:object_r:zabbix_script_exec_t:s0

SELinux prevents executing scripts by zabbix-agent with this audit message:

type=AVC msg=audit(1475181608.675:258818): avc:  denied  { execute_no_trans } for  pid=18046 comm="sh" path="/var/lib/zabbix/externalscripts/haproxy_stats.sh" dev="dm-8" ino=29564421 scontext=system_u:system_r:zabbix_agent_t:s0 tcontext=unconfined_u:object_r:zabbix_script_exec_t:s0 tclass=file

Version-Release number of selected component (if applicable):
RHEL 7.2 x86_64
selinux-policy-targeted-3.13.1-60.el7_2.9.noarch
selinux-policy-3.13.1-60.el7_2.9.noarch

How reproducible:
Always.

Steps to Reproduce:
1. Install RHEL 7.2 x86_64
2. Install zabbix-agent
3. Call custom script from /var/lib/zabbix/externalscripts/ with zabbix-agent (or call direct with source domain zabbix_agent_t)

Actual results:

SELinux prevents executing the script

Expected results:

Script will be run with zabbix_script_t domain

Additional info:

Scripts are working after installing custom module:

module zabbix_agent 1.0.1;

require {
    type zabbix_script_exec_t;
    type zabbix_script_t;
    type zabbix_agent_t;
    class file { ioctl read getattr execute open };
    class dir { ioctl read getattr lock search open };
    class process { transition sigchld };
    class fifo_file { ioctl read write getattr lock append };
    class fd use;
}

#============= zabbix_agent_t ==============
allow zabbix_agent_t zabbix_script_exec_t : file { ioctl read getattr execute open } ;
allow zabbix_agent_t zabbix_script_exec_t : dir { ioctl read getattr lock search open } ;
allow zabbix_agent_t zabbix_script_t : process transition ;
type_transition zabbix_agent_t zabbix_script_exec_t : process zabbix_script_t;

#============= zabbix_script_t =============
allow zabbix_script_t zabbix_agent_t : process sigchld ;
allow zabbix_script_t zabbix_agent_t : fd use ;
allow zabbix_script_t zabbix_agent_t : fifo_file { ioctl read write getattr lock append } ;

Please, update zabbix module in default system policy.

Comment 7 errata-xmlrpc 2018-10-30 09:59:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3111


Note You need to log in before you can comment on or make changes to this bug.