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 1727342 - No default label for item in /var/spool/cron
Summary: No default label for item in /var/spool/cron
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.0
Hardware: All
OS: Linux
medium
low
Target Milestone: rc
: 8.1
Assignee: Lukas Vrabec
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-05 15:23 UTC by Steffen Froemer
Modified: 2023-09-07 20:13 UTC (History)
6 users (show)

Fixed In Version: selinux-policy-3.14.3-12.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-05 22:11:47 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:3547 0 None None None 2019-11-05 22:11:59 UTC

Description Steffen Froemer 2019-07-05 15:23:59 UTC
Description of problem:
There does not exist a default label for items in /var/spool/cron

Version-Release number of selected component (if applicable):
cronie-1.5.2-2.el8.x86_64

How reproducible:
always

Steps to Reproduce:
1. create a cronjob for user 
   crontab -e
   > 10 * * * * ksh -c '`date` > /dev/null 2>&1
   
2. sudo -i
3. # restorecon -Rnv /var/spool/cron/

Actual results:
restorecon:  Warning no default label for /var/spool/cron/sfroemer


Expected results:
context and labels should be set correctly

Additional info:

Comment 1 Lukas Vrabec 2019-07-08 14:53:46 UTC
Hi Steffen, 

Do you have some real issue with crontab? Or you just see Warning from bug description? I don't see this as a bug, so if you have some real example, please provide the reproducer. 

Thanks,
Lukas.

Comment 10 Milos Malik 2019-07-10 11:14:03 UTC
Following lines show the difference between RHEL-7 and RHEL-8:

RHEL-7
======
# ls -Z /var/spool/cron/
-rw-r--r--. root root unconfined_u:object_r:user_cron_spool_t:s0 staff-user
# restorecon -Rvn /var/spool/cron/
restorecon:  Warning no default label for /var/spool/cron/staff-user
# 

RHEL-8
======
# ls -Z /var/spool/cron/
unconfined_u:object_r:user_cron_spool_t:s0 staff-user
# restorecon -Rvn /var/spool/cron/
#

Comment 11 Milos Malik 2019-07-10 11:30:21 UTC
Please notice that file context patterns are the same on RHEL-7 and RHEL-8, but their order is different:

RHEL-7
======
# semanage fcontext -l | grep /var/spool/cron
/var/spool/cron/[^/]*                              regular file       <<None>>
/var/spool/cron/a?quota\.(user|group)              regular file       system_u:object_r:quota_db_t:s0 
/var/spool/cron/crontabs/.*                        regular file       <<None>>
/var/spool/cron                                    directory          system_u:object_r:user_cron_spool_t:s0 
/var/spool/cron/crontabs                           directory          system_u:object_r:cron_spool_t:s0 
#

RHEL-8
======
# semanage fcontext -l | grep '/var/spool/cron'
/var/spool/cron                                    directory          system_u:object_r:user_cron_spool_t:s0 
/var/spool/cron/[^/]*                              regular file       <<None>>
/var/spool/cron/a?quota\.(user|group)              regular file       system_u:object_r:quota_db_t:s0 
/var/spool/cron/crontabs                           directory          system_u:object_r:cron_spool_t:s0 
/var/spool/cron/crontabs/.*                        regular file       <<None>>
#

Is it possible that the different order of file context patterns causes the warning message?

Comment 12 Milos Malik 2019-07-10 11:47:18 UTC
RHEL-7
======
# ls -Z /var/spool/cron/
-rw-------. staff-user staff-user staff_u:object_r:user_cron_spool_t:s0 staff-user
-rw-------. user-user  user-user  user_u:object_r:user_cron_spool_t:s0 user-user
# restorecon -Rv /var/spool/cron/
restorecon:  Warning no default label for /var/spool/cron/staff-user
restorecon:  Warning no default label for /var/spool/cron/user-user
# restorecon -RvF /var/spool/cron/
restorecon:  Warning no default label for /var/spool/cron/staff-user
restorecon:  Warning no default label for /var/spool/cron/user-user
# ls -Z /var/spool/cron/
-rw-------. staff-user staff-user staff_u:object_r:user_cron_spool_t:s0 staff-user
-rw-------. user-user  user-user  user_u:object_r:user_cron_spool_t:s0 user-user
# 

RHEL-8
======
# ls -lZ /var/spool/cron/
total 8
-rw-------. 1 staff-user staff-user staff_u:object_r:user_cron_spool_t:s0 14 Jul 10 07:35 staff-user
-rw-------. 1 user-user  user-user  user_u:object_r:user_cron_spool_t:s0  14 Jul 10 07:38 user-user
# restorecon -Rv /var/spool/cron/
# restorecon -RvF /var/spool/cron/
# ls -lZ /var/spool/cron/
total 8
-rw-------. 1 staff-user staff-user staff_u:object_r:user_cron_spool_t:s0 14 Jul 10 07:35 staff-user
-rw-------. 1 user-user  user-user  user_u:object_r:user_cron_spool_t:s0  14 Jul 10 07:38 user-user
# 

If the different order of file context patterns is not the cause of the warning messages, then the restorecon behaviour must have changed.

Comment 13 Milos Malik 2019-07-10 11:55:12 UTC
Please answer questions in comment#11 and comment#12.

Comment 16 Milos Malik 2019-07-16 16:22:52 UTC
Here is a way how to define correct SELinux context for individual user crontabs.

First we need to modify the /var/lib/selinux/targeted/active/homedir_template file:

# grep cron/USER /var/lib/selinux/targeted/active/homedir_template
/var/spool/cron/USER	--	system_u:object_r:user_cron_spool_t:s0
#

Now, if we create a new user (not tested on already existing users):

# useradd -Z sysadm_u sysadm-user
#

the file context patterns will contain a new file context pattern:

# semanage fcontext -l | grep cron/sysadm-user
/var/spool/cron/sysadm-user                        regular file       sysadm_u:object_r:user_cron_spool_t:s0 
#

which means that restorecon will no longer produce above-mentioned warning messages and it will correct SELinux labels on files in /var/spool/cron directory:

# touch /var/spool/cron/sysadm-user
# ls -Z /var/spool/cron/sysadm-user
unconfined_u:object_r:user_cron_spool_t:s0 /var/spool/cron/sysadm-user
# restorecon -vF /var/spool/cron/sysadm-user
Relabeled /var/spool/cron/sysadm-user from unconfined_u:object_r:user_cron_spool_t:s0 to sysadm_u:object_r:user_cron_spool_t:s0
# ls -Z /var/spool/cron/sysadm-user
sysadm_u:object_r:user_cron_spool_t:s0 /var/spool/cron/sysadm-user
# restorecon -Rv /var/spool/cron/sysadm-user
#

Unfortunately, following command removes all my changes in /var/lib/selinux/targeted/active/homedir_template:

# semodule -B

We need to find a permanent way how to store the homedir_template changes.

Comment 18 Lukas Vrabec 2019-07-17 11:36:43 UTC
*** Bug 1727341 has been marked as a duplicate of this bug. ***

Comment 23 errata-xmlrpc 2019-11-05 22:11:47 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-2019:3547


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