Skip to content

Commit 523b6d5

Browse files
committed
Relabel / and /rw if needed
Creating /.autorelabel must cause a Qubes OS VM to relabel everything, as otherwise users will not be able to troubleshoot their systems and upstream packages that create it will break. However, it was ignored, so fix that. Furthermore, relabel the filesystem of a TemplateBasedVM whenever its TemplateVM has been relabeled since the TemplateBasedVM was. This ensures that policy changes propagate to TemplateBasedVMs too.
1 parent 00297d4 commit 523b6d5

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ install-init:
130130
install -m 0644 init/functions $(DESTDIR)$(LIBDIR)/qubes/init/
131131
ifneq ($(ENABLE_SELINUX),1)
132132
rm -f $(DESTDIR)$(LIBDIR)/qubes/init/relabel-root.sh
133+
rm -f $(DESTDIR)$(LIBDIR)/qubes/init/relabel-rw.sh
133134
endif
134135

135136
# Systemd service files

init/relabel-rw.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash --
2+
set -eu
3+
if [ /.qubes-relabeled -nt /rw/.autorelabel ]; then
4+
restorecon -RF /rw /home /usr/local
5+
touch /rw/.autorelabel
6+
fi

rpm_spec/core-agent.spec.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ a VM with SELinux enforcing, as is the default on Red Hat-family distributions.
426426
%dir %_unitdir/selinux-autorelabel.service.d
427427
%_unitdir/selinux-autorelabel.service.d/30_qubes.conf
428428
/usr/lib/qubes/init/relabel-root.sh
429+
/usr/lib/qubes/init/relabel-rw.sh
429430

430431
%postun selinux
431432
if [ "$1" -eq 0 ]; then

vm-systemd/qubes-relabel-root.service

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Description=Relabel /
33
After=qubes-sysinit.service
44
Requires=qubes-sysinit.service
55
ConditionSecurity=selinux
6-
ConditionPathExists=!/.qubes-relabeled
6+
ConditionPathExists=|/.autorelabel
7+
ConditionPathExists=|!/.qubes-relabeled
78
ConditionPathExists=/run/qubes/persistent-full
89
DefaultDependencies=no
910
Conflicts=shutdown.target

vm-systemd/qubes-relabel-rw.service

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
[Unit]
22
Description=Relabel /rw and /home
3-
After=qubes-mount-dirs.service qubes-sysinit.service
4-
Requires=qubes-mount-dirs.service qubes-sysinit.service
3+
After=qubes-mount-dirs.service qubes-sysinit.service qubes-relabel-root.service
4+
Requires=qubes-mount-dirs.service qubes-sysinit.service qubes-relabel-root.service
55
ConditionSecurity=selinux
6-
ConditionPathExists=!/rw/.autorelabel
76
DefaultDependencies=no
87
Conflicts=selinux-autorelabel.service
98
Before=local-fs.target rw.mount home.mount qubes-gui-agent.service qubes-qrexec-agent.service
109

1110
[Service]
1211
Type=oneshot
1312
RemainAfterExit=yes
14-
ExecStart=/usr/sbin/restorecon -RF /rw /home /usr/local
15-
ExecStart=/bin/touch /rw/.autorelabel
13+
ExecStart=/usr/lib/qubes/init/relabel-rw.sh
1614

1715
[Install]
1816
WantedBy=multi-user.target

0 commit comments

Comments
 (0)