Skip to content

Commit 2abb91f

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 df1ffd4 commit 2abb91f

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

init/relabel-rw.sh

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

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
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)