Bug 1410034

Summary: Systemd selinux code seems to be broken
Product: Red Hat Enterprise Linux 7 Reporter: Supreet <srandhaw>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: awilliam, bruno, chepioq, dac.override, dwalsh, eparis, extras-qa, germano.massullo, icon, igor, johannbg, john.ellson, jpazdziora, jsynacek, kevin, linuxdev-kernel-it, lnykryn, lvrabec, mgrepl, mokomull, msekleta, muep, pmoore, pschindl, robatino, sdsmall, sgaikwad, s, stanley.king, steevithak, systemd-maint-list, systemd-maint, thestonewell, thorsten.kohfeldt, vlee, zbyszek
Target Milestone: rc   
Target Release: 7.4   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1224211 Environment:
Last Closed: 2017-01-04 16:37:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Supreet 2017-01-04 09:44:17 UTC
+++ This bug was initially created as a clone of Bug #1224211 +++

Selinux is preventing enableing/disableing services through systemd on some of the systems.
[root@test ~]# systemctl enable exim.service
Failed to execute operation: Access denied

Below are the AVC's :

type=SERVICE_START msg=audit(1483089948.172:27148): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1483089948.172:27149): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1483176408.172:30189): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1483176408.172:30190): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1483262868.168:33223): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1483262868.169:33224): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1483349328.169:36286): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1483349328.169:36287): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=USER_AVC msg=audit(1483361523.675:37464): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  received setenforce notice (enforcing=0)  exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1483361702.184:37469): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  received setenforce notice (enforcing=1)  exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1483361924.719:37501): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:  denied  { enable } for auid=0 uid=0 gid=0 cmdline="systemctl enable exim.service" scontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tcontext=system_u:system_r:init_t:s0 tclass=service  exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'

Even tried this but it didn't worked : # systemctl daemon-reexec

And also in permissive mode, it is giving the same AVC's.

Comment 2 Michal Sekletar 2017-01-04 13:19:12 UTC
Is exim actually installed on the system?

Comment 3 Suresh 2017-01-04 15:21:34 UTC
Hello Michal,

exim does not seems to be installed in the system. Along with that, we do not ship exim in RHEL7.

I was get this working after installing exim from epel.

<snip>

[root@localhost test]# getenforce 
Enforcing

[root@localhost test]# systemctl status exim.service
● exim.service - Exim Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/exim.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

[root@localhost test]# systemctl enable exim.service
Created symlink from /etc/systemd/system/multi-user.target.wants/exim.service to /usr/lib/systemd/system/exim.service.

[root@localhost test]# systemctl start exim.service

[root@localhost test]# systemctl status exim.service
● exim.service - Exim Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/exim.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2017-01-04 10:10:12 EST; 3s ago
  Process: 19798 ExecStartPre=/usr/libexec/exim-gen-cert (code=exited, status=0/SUCCESS)
 Main PID: 19800 (exim)
   CGroup: /system.slice/exim.service
           └─19800 /usr/sbin/exim -bd -q1h

Jan 04 10:10:12 localhost.example.com systemd[1]: Starting Exim Mail Transport Agent...
Jan 04 10:10:12 localhost.example.com systemd[1]: Started Exim Mail Transport Agent.

[root@localhost test]# ps -eZ | grep exim
system_u:system_r:exim_t:s0     19800 ?        00:00:00 exim

</snip>

I think we can close this bugzilla as Not a bug. If required, I will follow up with you again.

Comment 4 Lukáš Nykrýn 2017-01-04 16:37:53 UTC
The problem is that before we do anything in systemd we perform a check against selinux policy, if that action can be perform. And in the case of not existing unit file selinux forbids such action before we can say that the unit file is not there (hence the Access denied message)