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 2177622

Summary: vncsession cannot create ~/.vnc directory, popping up an AVC
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: tigervncAssignee: Jan Grulich <jgrulich>
Status: CLOSED DUPLICATE QA Contact: Desktop QE <desktop-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.7Flags: pm-rhel: mirror+
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-13 07:43:33 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 Renaud Métrich 2023-03-13 07:40:43 UTC
Description of problem:

Trying to start the vncserver@<instance>.service unit for a user, I can see an AVC popping up:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
type=CWD msg=audit(03/13/2023 08:29:32.525:311) : cwd=/home/admin 
type=SYSCALL msg=audit(03/13/2023 08:29:32.525:311) : arch=x86_64 syscall=mkdir success=yes exit=0 a0=0x7ffd20d111d0 a1=0755 a2=0x0 a3=0x0 items=2 ppid=4724 pid=4745 auid=admin uid=admin gid=admin euid=admin suid=admin fsuid=admin egid=admin sgid=admin fsgid=admin tty=(none) ses=12 comm=vncsession exe=/usr/sbin/vncsession subj=system_u:system_r:vnc_session_t:s0 key=(null) 
type=AVC msg=audit(03/13/2023 08:29:32.525:311) : avc:  denied  { create } for  pid=4745 comm=vncsession name=.vnc scontext=system_u:system_r:vnc_session_t:s0 tcontext=system_u:object_r:vnc_home_t:s0 tclass=dir permissive=1 
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

The root cause for this is vncsession cannot create the directory ~/.vnc, even though it's already running as the target user, because there is no rule for that (unless polyinstantiation is enabled, which is not the default):
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# sesearch -A -s vnc_session_t -t vnc_home_t -c dir -p create
allow polydomain polymember:dir { create relabelto setattr }; [ polyinstantiation_enabled ]:True
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This happens when the administrator creates instantiable services for the users, but the user didn't set its password yet (hence no ~/.vnc directory exists).

See below the strace showing the call sequence:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
4014  [system_u:system_r:vnc_session_t:s0] 08:22:23.454536 execve("/usr/sbin/vncsession" [system_u:object_r:vnc_session_exec_t:s0], ["/usr/sbin/vncsession", "admin", ":2"], ["LANG=en_US.UTF-8", "INVOCATION_ID=5f566a3c40c84b8c805860b0923e0608", "PWD=/", "JOURNAL_STREAM=9:52741", "SHLVL=0", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"]) = 0 <0.000357>
 :
4014  [system_u:system_r:vnc_session_t:s0] 08:22:23.483095 <... clone resumed>, child_tidptr=0x7f5f09f63b10) = 4020 <0.000172>
 :
4020  [system_u:system_r:vnc_session_t:s0] 08:22:23.483433 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f5f09f63b10) = 4021 <0.000105>
 :
4021  [system_u:system_r:vnc_session_t:s0] 08:22:25.613369 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f5f09f63b10) = 4050 <0.000230>
 :
4050  [system_u:system_r:vnc_session_t:s0] 08:22:25.690701 setuid(1000 <unfinished ...>
4050  [system_u:system_r:vnc_session_t:s0] 08:22:25.690937 <... setuid resumed>) = 0 <0.000224>
 :
4050  [system_u:system_r:vnc_session_t:s0] 08:22:25.704411 mkdir("/home/admin/.vnc", 0755 <unfinished ...>
4050  [system_u:system_r:vnc_session_t:s0] 08:22:25.704539 <... mkdir resumed>) = -1 EACCES (Permission denied) <0.000100>
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

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

tigervnc-server-1.12.0-9.el8_7.1.x86_64

How reproducible:

Always

Steps to Reproduce:

1. Add a user to the system

   # useradd foouser

2. Add the user to /etc/tigervnc/vncserver.users

   # echo ":1=foouser" >> /etc/tigervnc/vncserver.users

3. Enable+Start the instance

   # systemctl enable vncserver@:1.service --now

Actual results:

AVC

Expected results:

No AVC and ~/.vnc created

Comment 1 Jan Grulich 2023-03-13 07:43:33 UTC

*** This bug has been marked as a duplicate of bug 2164704 ***