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 1078983

Summary: /tmp/.X11-unix selinux file context wrong when Xvfb runs before Xorg
Product: Red Hat Enterprise Linux 6 Reporter: Andreas Luik <andreas.luik>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED CANTFIX QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5CC: andreas.luik, dwalsh, mmalik
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-25 12:31:17 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:
Attachments:
Description Flags
audit.log AVCs as described in comment #3 none

Description Andreas Luik 2014-03-20 16:55:02 UTC
Description of problem:

We use Xvfb and it is started from upstart, as well as gdm/Xorg.  When Xorg starts first, /tmp/.X11-unix directory is created with the correct SElinux context:

[root@laptest tmp]# ls -dZ /tmp/.X11-unix
drwxrwxrwt. root root unconfined_u:object_r:xdm_tmp_t:s0 /tmp/.X11-unix

When Xvfb is started first, the context is wrong:

[root@laptest tmp]# ls -dZ /tmp/.X11-unix
drwxrwxrwt. root root unconfined_u:object_r:user_tmp_t:s0 /tmp/.X11-unix

(One consequence of this wrong context is that nm-applet does not run, similar as described in  https://bugzilla.redhat.com/show_bug.cgi?id=549253 .)


Version-Release number of selected component (if applicable):

selinux-policy-3.7.19-231.el6.noarch
xorg-x11-server-Xvfb-1.13.0-23.el6.x86_64

How reproducible: always


Steps to Reproduce:
1. rm -fr /tmp/.X11-unix
2. run Xvfb, then terminate
3. restart gdm

Actual results:

nm-applet is gone


Expected results:

nm-applet is shown


Additional info:

Comment 2 Miroslav Grepl 2014-03-24 09:37:27 UTC
What AVC are you getting with

[root@laptest tmp]# ls -dZ /tmp/.X11-unix
drwxrwxrwt. root root unconfined_u:object_r:user_tmp_t:s0 /tmp/.X11-unix

?

The problem is we are not able to set the correct labeling in RHEL6 if you run it as a user.

Comment 3 Andreas Luik 2014-03-24 16:58:37 UTC
(In reply to Miroslav Grepl from comment #2)

When the wrong settings are in effect:
No AVCs are reported with the default settings.
With "semodule -DB" enabled, a lot of AVCs are reported when logging in, I've added an attachment.  I think the relevant ones are:

type=AVC msg=audit(1395676556.665:88): avc:  denied  { rlimitinh } for  pid=3221 comm="udisks-daemon" scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:devicekit_disk_t:s0-s0:c0.c1023 tclass=process
type=AVC msg=audit(1395676556.665:88): avc:  denied  { siginh } for  pid=3221 comm="udisks-daemon" scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:devicekit_disk_t:s0-s0:c0.c1023 tclass=process
type=AVC msg=audit(1395676556.665:88): avc:  denied  { noatsecure } for  pid=3221 comm="udisks-daemon" scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:devicekit_disk_t:s0-s0:c0.c1023 tclass=process
type=AVC msg=audit(1395676556.906:89): avc:  denied  { rlimitinh } for  pid=3358 comm="packagekitd" scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:rpm_t:s0-s0:c0.c1023 tclass=process
type=AVC msg=audit(1395676556.906:89): avc:  denied  { siginh } for  pid=3358 comm="packagekitd" scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:rpm_t:s0-s0:c0.c1023 tclass=process
type=AVC msg=audit(1395676556.906:89): avc:  denied  { noatsecure } for  pid=3358 comm="packagekitd" scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:rpm_t:s0-s0:c0.c1023 tclass=process

Anyways, I think it is not possible to fix this problem by SElinux policies.  The wrong file context of /tmp/.X11-unix must be prevented/fixed somehow.
Please have a look at https://bugzilla.redhat.com/show_bug.cgi?id=499183 especially comments 22 and 23.

Comment 4 Andreas Luik 2014-03-24 17:00:12 UTC
Created attachment 878129 [details]
audit.log AVCs as described in comment #3

Comment 5 Andreas Luik 2014-03-25 10:45:14 UTC
(In reply to Miroslav Grepl from comment #2)
> The problem is we are not able to set the correct labeling in RHEL6 if you
> run it as a user.

Additional information: Xvfb does also not set the correct context for /tmp/.X11-unix if started by "root".

I have now implemented the following workaround, which avoids the problem: create the directory with the correct file context before starting Xvfb:

mkdir -m 1777 /tmp/.X11-unix
test -x /sbin/restorecon && /sbin/restorecon /tmp/.X11-unix
su nobody -s /bin/sh -c '/usr/bin/Xvfb :9 -screen 0 640x480x24 -dpi 100 -ac -s 0'

Comment 7 Miroslav Grepl 2015-02-25 12:31:17 UTC
We will need to go with this workaround in RHEL6.