RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1883906 - selinux prevents timedatex (timedatectl) commands running from cron on RHEL8.x
Summary: selinux prevents timedatex (timedatectl) commands running from cron on RHEL8.x
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: ---
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.4
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-30 13:45 UTC by Eize Speerstra
Modified: 2021-05-18 14:58 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 14:58:17 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Eize Speerstra 2020-09-30 13:45:00 UTC
Description of problem:

When running timedatectl via cron I get a timeout. This happens on RHEL/CentOS 8 only. (tested on RHEL8.1, CentOS 8.1, RHEL8.2 and CentOS8.2)

timedatex send a message to dbus, but is denied access by selinux.

audit logging:
type=USER_AVC msg=audit(1600182869.302:16052): pid=1045 uid=81 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=method_return dest=:1.11257 spid=1128745 tpid=1128751 scontext=system_u:system_r:timedatex_t:s0 tcontext=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 tclass=dbus permissive=0  exe="/usr/bin/dbus-daemon" sauid=81 hostname=? addr=? terminal=?'

audit2why:
        Was caused by:
                Missing type enforcement (TE) allow rule.

I have created a local policy as a workaround, but I believe this should be in the generic policy

Version-Release number of selected component (if applicable):
0.5-3.el8

How reproducible:
Always

Steps to Reproduce:
1. create a shell script with timedatectl set-timezone Europe/Amsterdam 
2. create cron-job for it
3. wait for it to be executed by cron

Actual results:
Failed to set time zone: Connection timed out

Expected results:
time zone set without error

Additional info:

Comment 1 Milos Malik 2020-10-01 08:26:12 UTC
Reproducible on RHEL-8.3 too:
----
type=USER_AVC msg=audit(10/01/2020 10:23:01.668:335) : pid=1158 uid=dbus auid=unset ses=unset subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=method_return dest=:1.213 spid=7160 tpid=7159 scontext=system_u:system_r:timedatex_t:s0 tcontext=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 tclass=dbus permissive=0  exe=/usr/bin/dbus-daemon sauid=dbus hostname=? addr=? terminal=?' 
----

# rpm -qa selinux\*
selinux-policy-devel-3.14.3-54.el8.noarch
selinux-policy-3.14.3-54.el8.noarch
selinux-policy-doc-3.14.3-54.el8.noarch
selinux-policy-minimum-3.14.3-54.el8.noarch
selinux-policy-sandbox-3.14.3-54.el8.noarch
selinux-policy-mls-3.14.3-54.el8.noarch
selinux-policy-targeted-3.14.3-54.el8.noarch
# grep -v '#' /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root


* * * * * root timedatectl set-timezone Europe/Prague
#

Comment 2 Milos Malik 2020-10-01 08:29:08 UTC
The only SELinux denial which appeared in permissive mode is:
----
type=USER_AVC msg=audit(10/01/2020 10:27:01.641:394) : pid=1158 uid=dbus auid=unset ses=unset subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=method_return dest=:1.245 spid=8554 tpid=8553 scontext=system_u:system_r:timedatex_t:s0 tcontext=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 tclass=dbus permissive=1  exe=/usr/bin/dbus-daemon sauid=dbus hostname=? addr=? terminal=?' 
----

# sesearch -s timedatex_t -t system_cronjob_t -c dbus -A
# sesearch -s system_cronjob_t -t timedatex_t -c dbus -A
allow dbusd_unconfined timedatex_t:dbus send_msg;
#

Comment 6 Milos Malik 2020-10-23 09:31:24 UTC
Does the scenario work for normal or confined users?

Comment 7 Milos Malik 2020-11-09 20:28:29 UTC
The scenario executed under normal confined users does not produce any SELinux denials. Unfortunately, it fails to change the timezone - Not authorized.

Comment 8 Zdenek Pytela 2020-12-08 22:23:32 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/502

Comment 9 Zdenek Pytela 2020-12-09 17:59:36 UTC
This is the rawhide commit:
commit 4d2207194e25b20e9b2c52de49f4d550c1488ab3 (HEAD -> rawhide, upstream/rawhide)
Author: Zdenek Pytela <zpytela>
Date:   Tue Dec 8 22:49:21 2020 +0100

    Allow timedatex dbus chat with cron system domain
    
    Resolves: rhbz#1883906

Comment 18 errata-xmlrpc 2021-05-18 14:58:17 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 (selinux-policy bug fix and enhancement update), 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-2021:1639


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