Debian Codegraph @

test/units/autorelabel.service

raw
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 # We use a custom autorelabel service instead of the SELinux provided set of
4 # units & a generator, since the generator overrides the default target to the
5 # SELinux one when it detects /.autorelabel. However, we use systemd.unit= on
6 # the kernel command cmdline which always takes precedence, rendering all
7 # SELinux efforts useless. Also, pulling in selinux-autorelabel.service
8 # explicitly doesn't work either, as it doesn't check for the presence of
9 # /.autorelabel and does the relabeling unconditionally which always ends with
10 # a reboot, so we end up in a reboot loop (and it also spews quite a lot of
11 # errors as it wants /etc/fstab and dracut-initramfs-restore).
12
13 [Unit]
14 Description=Relabel all filesystems
15 DefaultDependencies=no
16 Requires=local-fs.target
17 After=local-fs.target
18 Conflicts=shutdown.target
19 Before=shutdown.target basic.target
20 ConditionSecurity=selinux
21 ConditionPathExists=|/.autorelabel
22 SuccessAction=reboot
23
24 [Service]
25 ExecStart=bash -xec 'echo 0 >/sys/fs/selinux/enforce; fixfiles -f -F relabel; rm /.autorelabel;'
26 Type=oneshot
27 TimeoutSec=infinity
28
29 [Install]
30 WantedBy=basic.target