Bug 1433555

Summary: SELinux is preventing systemd-hostnam from 'create' accesses on the file .#hostnameC0Zq0X.
Product: [Fedora] Fedora Reporter: Adam Williamson <awilliam>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: dominick.grift, dwalsh, lvrabec, mgrepl, plautrba, pmoore, ssekidde
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: abrt_hash:197e93fba21a3b6a75434e2ce2a335eb04dda0b0c83d3bad016da0665e2505bb;VARIANT_ID=server;
Fixed In Version: selinux-policy-3.13.1-246.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-21 02:41:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Adam Williamson 2017-03-18 01:01:59 UTC
Description of problem:
After upgrading from selinux-policy 244 to 245,  `hostnamectl set-hostname some.hostname` prints an error and generates this AVC. With 244 it does not.
SELinux is preventing systemd-hostnam from 'create' accesses on the file .#hostnameC0Zq0X.

*****  Plugin catchall_labels (83.8 confidence) suggests   *******************

If you want to allow systemd-hostnam to have create access on the .#hostnameC0Zq0X file
Then you need to change the label on .#hostnameC0Zq0X
Do
# semanage fcontext -a -t FILE_TYPE '.#hostnameC0Zq0X'
where FILE_TYPE is one of the following: hostname_etc_t.
Then execute:
restorecon -v '.#hostnameC0Zq0X'


*****  Plugin catchall (17.1 confidence) suggests   **************************

If you believe that systemd-hostnam should be allowed create access on the .#hostnameC0Zq0X file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'systemd-hostnam' --raw | audit2allow -M my-systemdhostnam
# semodule -X 300 -i my-systemdhostnam.pp

Additional Information:
Source Context                system_u:system_r:systemd_hostnamed_t:s0
Target Context                system_u:object_r:etc_t:s0
Target Objects                .#hostnameC0Zq0X [ file ]
Source                        systemd-hostnam
Source Path                   systemd-hostnam
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-245.fc26.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 4.11.0-0.rc2.git2.2.fc26.x86_64 #1
                              SMP Wed Mar 15 19:55:36 UTC 2017 x86_64 x86_64
Alert Count                   1
First Seen                    2017-03-17 17:59:34 PDT
Last Seen                     2017-03-17 17:59:34 PDT
Local ID                      2c43f0fe-57e0-4b4d-b945-9dc8f1476942

Raw Audit Messages
type=AVC msg=audit(1489798774.378:269): avc:  denied  { create } for  pid=3807 comm="systemd-hostnam" name=".#hostnameC0Zq0X" scontext=system_u:system_r:systemd_hostnamed_t:s0 tcontext=system_u:object_r:etc_t:s0 tclass=file permissive=0


Hash: systemd-hostnam,systemd_hostnamed_t,etc_t,file,create

Version-Release number of selected component:
selinux-policy-3.13.1-245.fc26.noarch

Additional info:
component:      selinux-policy
reporter:       libreport-2.9.1
hashmarkername: setroubleshoot
kernel:         4.11.0-0.rc2.git2.2.fc26.x86_64
type:           libreport

Comment 1 Lukas Vrabec 2017-03-18 15:38:57 UTC
Adam, 

Did you update systemd with selinux-policy package? I don't this issue is connected to update but I improve rules for systemd_hostnamed_t domain. Should be fixed now.

Comment 2 Fedora Update System 2017-03-18 15:40:11 UTC
selinux-policy-3.13.1-246.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-58233b1a16

Comment 3 Adam Williamson 2017-03-19 03:10:49 UTC
No. I tested updating *just* selinux-policy. Before the update setting the hostname worked and produced no AVC. After the update, setting hostname produced the error and the AVC.

Comment 4 Fedora Update System 2017-03-19 14:22:14 UTC
selinux-policy-3.13.1-246.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-58233b1a16

Comment 5 Fedora Update System 2017-03-21 02:41:05 UTC
selinux-policy-3.13.1-246.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.