Bug 1954993

Summary: SELinux prevents systemd-hostnam to access directory systemd
Product: [Fedora] Fedora Reporter: oli <olze>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 34CC: dwalsh, grepl.miroslav, lvrabec, mmalik, omosnace, plautrba, vmojzis, zpytela
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-04-29 10:02:41 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 oli 2021-04-29 08:39:43 UTC
Description of problem:
i installed fedora 34 mate spin and noticed that my hostname looks a bit wierd:
[root@localhost-live Downloads], so i wanted to change that with hostnamectl set-hostname mymachine

Version-Release number of selected component (if applicable):
selinux-policy-targeted-34.3-1.fc34.noarch

How reproducible:
always

Steps to Reproduce:
1. install fedora 34 mate
2. try to change the hostname with hostnamectl set-hostname mymachine

Actual results:
an SELinux warning browser pop up

Expected results:
to change the hostname as expected

Additional info:

Comment 1 oli 2021-04-29 08:40:18 UTC
SELinux hindert systemd-hostnam daran, mit write-Zugriff auf Verzeichnis systemd zuzugreifen.

*****  Plugin catchall (100. Wahrscheinlichkeit) schlägt vor    **************

Wenn Sie denken, dass es systemd-hostnam standardmäßig erlaubt sein sollte, write Zugriff auf systemd directory zu erhalten.
Dann sie sollten dies als Fehler melden.
Um diesen Zugriff zu erlauben, können Sie ein lokales Richtlinien-Modul erstellen.
Ausführen
zugriff jetzt erlauben, indem Sie die nachfolgenden Befehle ausführen:
# ausearch -c 'systemd-hostnam' --raw | audit2allow -M my-systemdhostnam
# semodule -X 300 -i my-systemdhostnam.pp

zusätzliche Information:
Quellkontext                  system_u:system_r:systemd_hostnamed_t:s0
Zielkontext                   system_u:object_r:init_var_run_t:s0
Zielobjekte                   systemd [ dir ]
Quelle                        systemd-hostnam
Quellpfad                     systemd-hostnam
Port                          <Unbekannt>
Host                          lucy
RPM-Pakete der Quelle         
RPM-Pakete des Ziels          
SELinux Policy RPM            selinux-policy-targeted-34.3-1.fc34.noarch
Local Policy RPM              selinux-policy-targeted-34.3-1.fc34.noarch
SELinux aktiviert             True
Richtlinientyp                targeted
Enforcing-Modus               Enforcing
Rechnername                   lucy
Plattform                     Linux lucy 5.11.15-300.fc34.x86_64 #1 SMP Fri Apr
                              16 13:41:48 UTC 2021 x86_64 x86_64
Anzahl der Alarme             1
Zuerst gesehen                2021-04-29 10:36:17 CEST
Zuletzt gesehen               2021-04-29 10:36:17 CEST
Lokale ID                     1b6218df-6cde-41c2-9786-3601648c0078

Raw-Audit-Meldungen
type=AVC msg=audit(1619685377.293:697): avc:  denied  { write } for  pid=28185 comm="systemd-hostnam" name="systemd" dev="tmpfs" ino=2 scontext=system_u:system_r:systemd_hostnamed_t:s0 tcontext=system_u:object_r:init_var_run_t:s0 tclass=dir permissive=0


Hash: systemd-hostnam,systemd_hostnamed_t,init_var_run_t,dir,write

Comment 2 Zdenek Pytela 2021-04-29 10:02:41 UTC

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