Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1989858

Summary: at is not able to schedule jobs for a user which is mapped to selinux confined user - "user_u"
Product: Red Hat Enterprise Linux 7 Reporter: Ameya Patil <amepatil>
Component: atAssignee: Jan Staněk <jstanek>
Status: CLOSED ERRATA QA Contact: Jan Houska <jhouska>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.9CC: amkulkar, aperotti, jstanek, kpfleming, opohorel, rmetrich
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: at-3.1.13-25.el7_9 Doc Type: Bug Fix
Doc Text:
The RHEL 7 version of at contained an older version of selinux-enablement patch, which contained this bug. It was replaced with a version included in more recent upstream releases, bringing the selinux support to par with RHEL 8 and 9.
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-18 16:15:12 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 Ameya Patil 2021-08-04 08:35:14 UTC
Description of problem:

On RHEL 7 , When a confined user mapped to selinux user "user_u" , tries to execute a job with 'at' command. We get the following errors -

 "Not allowed to set exec context to user_u:user_r:user_t:s0 for user  test#012: Success"

Note that there are no selinux AVC for this.

# ausearch -m AVC -i
<no matches>


Version-Release number of selected component (if applicable):
at-3.1.13-24.el7.x86_64
selinux-policy-3.13.1-268.el7_9.2.noarch
selinux-policy-targeted-3.13.1-268.el7_9.2.noarch


How reproducible:
100%

Steps to Reproduce:
1. Add a confined user mapped with user_u

# useradd -Z user_u test
# echo "test" | passwd --stdin test

2. Login directly as this user and confirm you are mapped as user_u, execute at job

$ id -Z
user_u:user_r:user_t:s0

$ at now + 1 min
at> date > /home/test/date.txt
at> <EOT>
job 5 at Wed Aug  4 04:26:00 2021

3. Monitor the message logs for the error.

~~~
Aug  4 04:26:00 selinuxtest-rhel7 atd[19032]: Starting job 5 (a00005019e09da) for user 'test' (1001)
Aug  4 04:26:00 selinuxtest-rhel7 systemd: Started Session 20 of user test.
Aug  4 04:26:00 selinuxtest-rhel7 systemd-logind: New session 20 of user test.
Aug  4 04:26:00 selinuxtest-rhel7 atd[19034]: Not allowed to set exec context to user_u:user_r:user_t:s0 for user  test#012: Success
Aug  4 04:26:00 selinuxtest-rhel7 systemd-logind: Removed session 20.
~~~

4. There are no Selinux AVC present for this.

# ausearch -m AVC -i
<no matches>


Actual results:
'at' job fails to complete.


Expected results:
'at' job should complete.

Additional info:

This error does not takes place on RHEL 8.

Comment 14 Jan Houska 2022-04-01 08:36:18 UTC
VERIFIED:

NEW PASS:
version: 
at-3.1.13-25.el7_9


:   Test
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 04:21:42 ] :: [  BEGIN   ] :: Running './at.exp test_user test_user  localhost &> output-at.txt'
:: [ 04:21:42 ] :: [   PASS   ] :: Command './at.exp test_user test_user  localhost &> output-at.txt' (Expected 0, got 0)
====================
spawn ssh -t test_user@localhost 
test_user@localhost's password: spawn at now + 1 min
at> date >  /home/test_user/date.txt 
at> <EOT>
job 1 at Fri Apr  1 04:22:00 2022
====================
:: [ 04:21:42 ] :: [   PASS   ] :: File 'output-at.txt' should contain 'job' 
:: [ 04:22:42 ] :: [   PASS   ] :: File /home/test_user/date.txt should exist 
:: [ 04:22:42 ] :: [  BEGIN   ] :: Running 'ausearch -m AVC -i &> output-ausearch.txt'
:: [ 04:22:42 ] :: [   PASS   ] :: Command 'ausearch -m AVC -i &> output-ausearch.txt' (Expected 1, got 1)
:: [ 04:22:42 ] :: [   PASS   ] :: File 'output-ausearch.txt' should contain '<no matches>' 
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Duration: 60s
::   Assertions: 5 good, 0 bad
::   RESULT: PASS

Comment 19 errata-xmlrpc 2022-05-18 16:15:12 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 (at 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-2022:4638