Bug 1410034 - Systemd selinux code seems to be broken
Summary: Systemd selinux code seems to be broken
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.3
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: 7.4
Assignee: systemd-maint
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-01-04 09:44 UTC by Supreet
Modified: 2020-02-14 18:25 UTC (History)
36 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1224211
Environment:
Last Closed: 2017-01-04 16:37:53 UTC
Target Upstream Version:


Attachments (Terms of Use)

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)


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