Magellan Linux

Contents of /trunk/dracut/patches/dracut-059-systemd-253.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3785 - (show annotations) (download)
Fri Oct 13 11:22:40 2023 UTC (7 months, 2 weeks ago) by niro
File size: 9415 byte(s)
-systemd-253 support
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Antonio Alvarez Feijoo <antonio.feijoo@suse.com>
3 Date: Mon, 9 Jan 2023 11:47:06 +0100
4 Subject: [PATCH 1/4] fix(dracut-systemd): remove unused argument
5
6 The `generator_wait_for_dev` function of the dracut rootfs systemd generator
7 only uses the first argument. Moreover, RDRETRY is unset at this point.
8
9 (cherry picked from commit eb75861c2a1c05eb142616da1891a7fa5a2a34e1)
10 ---
11 modules.d/98dracut-systemd/rootfs-generator.sh | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14 diff --git a/modules.d/98dracut-systemd/rootfs-generator.sh b/modules.d/98dracut-systemd/rootfs-generator.sh
15 index e1d365df..3238b495 100755
16 --- a/modules.d/98dracut-systemd/rootfs-generator.sh
17 +++ b/modules.d/98dracut-systemd/rootfs-generator.sh
18 @@ -104,7 +104,7 @@ esac
19 GENERATOR_DIR="$1"
20
21 if [ "$rootok" = "1" ]; then
22 - generator_wait_for_dev "${root#block:}" "$RDRETRY"
23 + generator_wait_for_dev "${root#block:}"
24 generator_fsck_after_pre_mount "${root#block:}"
25 strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
26 fi
27
28 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
29 From: Antonio Alvarez Feijoo <antonio.feijoo@suse.com>
30 Date: Wed, 1 Mar 2023 11:21:16 +0100
31 Subject: [PATCH 2/4] fix(dracut-systemd): do not hardcode the systemd
32 generator directory
33
34 The normal directory is the first argument passed to the systemd generator,
35 so use it instead of hardcoding /run/systemd/generator.
36
37 (cherry picked from commit a2b32ed976898188bc98d9b6c7eec3dc45f4abf0)
38 ---
39 modules.d/98dracut-systemd/rootfs-generator.sh | 8 ++++----
40 1 file changed, 4 insertions(+), 4 deletions(-)
41
42 diff --git a/modules.d/98dracut-systemd/rootfs-generator.sh b/modules.d/98dracut-systemd/rootfs-generator.sh
43 index 3238b495..5b85d8c5 100755
44 --- a/modules.d/98dracut-systemd/rootfs-generator.sh
45 +++ b/modules.d/98dracut-systemd/rootfs-generator.sh
46 @@ -17,7 +17,7 @@ generator_wait_for_dev() {
47 # after remote-fs-pre.target since the initqueue is ordered before it so
48 # it will never actually show up (think Tang-pinned rootfs).
49 cat > "$hookdir/initqueue/finished/devexists-${_name}.sh" << EOF
50 -if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetup@*.service 2>/dev/null; then
51 +if ! grep -q After=remote-fs-pre.target "$GENERATOR_DIR"/systemd-cryptsetup@*.service 2>/dev/null; then
52 [ -e "$1" ]
53 fi
54 EOF
55 @@ -77,12 +77,12 @@ generator_fsck_after_pre_mount() {
56 [ -z "$1" ] && return 0
57
58 _name=$(dev_unit_name "$1")
59 - [ -d /run/systemd/generator/systemd-fsck@"${_name}".service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@"${_name}".service.d
60 - if ! [ -f /run/systemd/generator/systemd-fsck@"${_name}".service.d/after-pre-mount.conf ]; then
61 + [ -d "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d ] || mkdir -p "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d
62 + if ! [ -f "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d/after-pre-mount.conf ]; then
63 {
64 echo "[Unit]"
65 echo "After=dracut-pre-mount.service"
66 - } > /run/systemd/generator/systemd-fsck@"${_name}".service.d/after-pre-mount.conf
67 + } > "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d/after-pre-mount.conf
68 fi
69
70 }
71
72 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
73 From: Antonio Alvarez Feijoo <antonio.feijoo@suse.com>
74 Date: Wed, 1 Mar 2023 12:07:29 +0100
75 Subject: [PATCH 3/4] fix(dracut-systemd): check and create generator dir
76 outside of inner function
77
78 (cherry picked from commit e21f8f7d5abaae37ada8c7a6dc91c2d878e0b501)
79 ---
80 modules.d/98dracut-systemd/rootfs-generator.sh | 7 ++++---
81 1 file changed, 4 insertions(+), 3 deletions(-)
82
83 diff --git a/modules.d/98dracut-systemd/rootfs-generator.sh b/modules.d/98dracut-systemd/rootfs-generator.sh
84 index 5b85d8c5..c3f60ad4 100755
85 --- a/modules.d/98dracut-systemd/rootfs-generator.sh
86 +++ b/modules.d/98dracut-systemd/rootfs-generator.sh
87 @@ -51,7 +51,6 @@ generator_mount_rootfs() {
88 [ -z "$1" ] && return 0
89
90 _name=$(dev_unit_name "$1")
91 - [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
92 if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then
93 {
94 echo "[Unit]"
95 @@ -101,9 +100,11 @@ case "${root#block:}" in
96 ;;
97 esac
98
99 -GENERATOR_DIR="$1"
100 -
101 if [ "$rootok" = "1" ]; then
102 + GENERATOR_DIR="$1"
103 + [ -z "$GENERATOR_DIR" ] && exit 1
104 + [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
105 +
106 generator_wait_for_dev "${root#block:}"
107 generator_fsck_after_pre_mount "${root#block:}"
108 strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
109
110 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
111 From: Antonio Alvarez Feijoo <antonio.feijoo@suse.com>
112 Date: Fri, 3 Mar 2023 16:06:30 +0100
113 Subject: [PATCH 4/4] fix(dracut-systemd): rootfs-generator cannot write
114 outside of generator dir
115
116 Altough it was already documented in systemd.generator(7) that generators must
117 not write to locations other than those passed as arguments, since
118 https://github.com/systemd/systemd/commit/ca6ce62d systemd executes generators
119 in a mount namespace "sandbox", so now the hooks created by the rootfs-generator
120 are lost.
121
122 These hooks are created using the root= cmdline argument, so this patch moves
123 the creation of these hooks to a cmdline hook.
124
125 Fixes issue #2211
126 Fixes issue #2225
127
128 (cherry picked from commit 4bde75fabe31a5c048fd75e533b94e91c3faa83b)
129 ---
130 modules.d/98dracut-systemd/module-setup.sh | 2 +
131 .../98dracut-systemd/parse-root.sh (new +x) | 38 +++++++++++++++++++
132 .../98dracut-systemd/rootfs-generator.sh | 20 +---------
133 3 files changed, 41 insertions(+), 19 deletions(-)
134
135 diff --git a/modules.d/98dracut-systemd/module-setup.sh b/modules.d/98dracut-systemd/module-setup.sh
136 index b7da86db..e66fc956 100755
137 --- a/modules.d/98dracut-systemd/module-setup.sh
138 +++ b/modules.d/98dracut-systemd/module-setup.sh
139 @@ -37,6 +37,8 @@ install() {
140
141 inst_script "$moddir/rootfs-generator.sh" "$systemdutildir"/system-generators/dracut-rootfs-generator
142
143 + inst_hook cmdline 10 "$moddir/parse-root.sh"
144 +
145 for i in \
146 dracut-cmdline.service \
147 dracut-cmdline-ask.service \
148 diff --git a/modules.d/98dracut-systemd/parse-root.sh b/modules.d/98dracut-systemd/parse-root.sh
149 new file mode 100755
150 index 00000000..deeeff3f
151 --- /dev/null
152 +++ b/modules.d/98dracut-systemd/parse-root.sh
153 @@ -0,0 +1,38 @@
154 +#!/bin/sh
155 +
156 +type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
157 +
158 +root=$(getarg root=)
159 +case "${root#block:}" in
160 + LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*)
161 + root="block:$(label_uuid_to_dev "$root")"
162 + rootok=1
163 + ;;
164 + /dev/nfs) # ignore legacy /dev/nfs
165 + ;;
166 + /dev/*)
167 + root="block:${root}"
168 + rootok=1
169 + ;;
170 +esac
171 +
172 +if [ "$rootok" = "1" ]; then
173 + root_dev="${root#block:}"
174 + root_name="$(str_replace "$root_dev" '/' '\x2f')"
175 + if ! [ -e "$hookdir/initqueue/finished/devexists-${root_name}.sh" ]; then
176 +
177 + # If a LUKS device needs unlocking via systemd in the initrd, assume
178 + # it's for the root device. In that case, don't block on it if it's
179 + # after remote-fs-pre.target since the initqueue is ordered before it so
180 + # it will never actually show up (think Tang-pinned rootfs).
181 + cat > "$hookdir/initqueue/finished/devexists-${root_name}.sh" << EOF
182 +if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetup@*.service 2>/dev/null; then
183 + [ -e "$root_dev" ]
184 +fi
185 +EOF
186 + {
187 + printf '[ -e "%s" ] || ' "$root_dev"
188 + printf 'warn "\"%s\" does not exist"\n' "$root_dev"
189 + } >> "$hookdir/emergency/80-${root_name}.sh"
190 + fi
191 +fi
192 diff --git a/modules.d/98dracut-systemd/rootfs-generator.sh b/modules.d/98dracut-systemd/rootfs-generator.sh
193 index c3f60ad4..bcfd2b89 100755
194 --- a/modules.d/98dracut-systemd/rootfs-generator.sh
195 +++ b/modules.d/98dracut-systemd/rootfs-generator.sh
196 @@ -6,28 +6,10 @@ generator_wait_for_dev() {
197 local _name
198 local _timeout
199
200 - _name="$(str_replace "$1" '/' '\x2f')"
201 + _name=$(dev_unit_name "$1")
202 _timeout=$(getarg rd.timeout)
203 _timeout=${_timeout:-0}
204
205 - if ! [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ]; then
206 -
207 - # If a LUKS device needs unlocking via systemd in the initrd, assume
208 - # it's for the root device. In that case, don't block on it if it's
209 - # after remote-fs-pre.target since the initqueue is ordered before it so
210 - # it will never actually show up (think Tang-pinned rootfs).
211 - cat > "$hookdir/initqueue/finished/devexists-${_name}.sh" << EOF
212 -if ! grep -q After=remote-fs-pre.target "$GENERATOR_DIR"/systemd-cryptsetup@*.service 2>/dev/null; then
213 - [ -e "$1" ]
214 -fi
215 -EOF
216 - {
217 - printf '[ -e "%s" ] || ' "$1"
218 - printf 'warn "\"%s\" does not exist"\n' "$1"
219 - } >> "$hookdir/emergency/80-${_name}.sh"
220 - fi
221 -
222 - _name=$(dev_unit_name "$1")
223 if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/"${_name}".device ]; then
224 [ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants
225 ln -s ../"${_name}".device "$GENERATOR_DIR"/initrd.target.wants/"${_name}".device