]> git.ipfire.org Git - thirdparty/systemd.git/blame - mkosi.postinst
Merge pull request #27347 from bluca/sd_bus_nonce
[thirdparty/systemd.git] / mkosi.postinst
CommitLineData
1b6f9b98
DDM
1#!/bin/sh
2# SPDX-License-Identifier: LGPL-2.1-or-later
3
1ad84c9a
DDM
4if [ "$1" = "build" ]; then
5 exit 0
6fi
7
8if [ -n "$SANITIZERS" ]; then
9 LD_PRELOAD=$(ldd /usr/lib/systemd/systemd | grep libasan.so | awk '{print $3}')
01a07564 10
1ad84c9a 11 mkdir -p /etc/systemd/system.conf.d
01a07564 12
1ad84c9a 13 cat >/etc/systemd/system.conf.d/10-asan.conf <<EOF
01a07564
DDM
14[Manager]
15ManagerEnvironment=ASAN_OPTIONS=$MKOSI_ASAN_OPTIONS\\
16 UBSAN_OPTIONS=$MKOSI_UBSAN_OPTIONS\\
17 LD_PRELOAD=$LD_PRELOAD
18DefaultEnvironment=ASAN_OPTIONS=$MKOSI_ASAN_OPTIONS\\
19 UBSAN_OPTIONS=$MKOSI_UBSAN_OPTIONS\\
20 LD_PRELOAD=$LD_PRELOAD
5a4327d1
DDM
21EOF
22
1ad84c9a
DDM
23 # ASAN logs to stderr by default. However, journald's stderr is connected to /dev/null, so we lose
24 # all the ASAN logs. To rectify that, let's connect journald's stdout to the console so that any
25 # sanitizer failures appear directly on the user's console.
26 mkdir -p /etc/systemd/system/systemd-journald.service.d
27 cat >/etc/systemd/system/systemd-journald.service.d/10-stdout-tty.conf <<EOF
01a07564
DDM
28[Service]
29StandardOutput=tty
30EOF
31
1ad84c9a
DDM
32 # Both systemd and util-linux's login call vhangup() on /dev/console which disconnects all users.
33 # This means systemd-journald can't log to /dev/console even if we configure `StandardOutput=tty`. As
34 # a workaround, we modify console-getty.service to disable systemd's vhangup() and disallow login
35 # from calling vhangup() so that journald's ASAN logs correctly end up in the console.
01a07564 36
1ad84c9a
DDM
37 mkdir -p /etc/systemd/system/console-getty.service.d
38 cat >/etc/systemd/system/console-getty.service.d/10-no-vhangup.conf <<EOF
01a07564
DDM
39[Service]
40TTYVHangup=no
41CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
42EOF
1ad84c9a
DDM
43 # ASAN and syscall filters aren't compatible with each other.
44 find / -name '*.service' -type f -exec sed -i 's/^\(MemoryDeny\|SystemCall\)/# \1/' {} +
69d638e6 45
1ad84c9a
DDM
46 # `systemd-hwdb update` takes > 50s when built with sanitizers so let's not run it by default.
47 systemctl mask systemd-hwdb-update.service
48fi
37d35150 49
1ad84c9a
DDM
50if [ -n "$IMAGE_ID" ] ; then
51 sed -n \
52 -i \
53 -e '/^IMAGE_ID=/!p' \
54 -e "\$aIMAGE_ID=$IMAGE_ID" \
55 /usr/lib/os-release
56fi
01a07564 57
1ad84c9a
DDM
58if [ -n "$IMAGE_VERSION" ] ; then
59 sed -n \
60 -i \
61 -e '/^IMAGE_VERSION=/!p' \
62 -e "\$aIMAGE_VERSION=$IMAGE_VERSION" \
63 /usr/lib/os-release
1b6f9b98 64fi
6b7e774b 65
fe424384
DDM
66if command -v authselect >/dev/null; then
67 authselect select minimal
68
69 if authselect list-features minimal | grep -q "with-homed"; then
70 authselect enable-feature with-homed
71 fi
72fi
7cd64af5
LB
73
74# Let tmpfiles.d/systemd-resolve.conf handle the symlink
75rm -f /etc/resolv.conf