public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v3] fix on-first-boot for systemd >= 247
@ 2022-08-02 10:39 Felix Moessbauer
  2022-08-09 19:01 ` Schmidl, Tobias
  2022-08-10 11:33 ` Anton Mikanovich
  0 siblings, 2 replies; 4+ messages in thread
From: Felix Moessbauer @ 2022-08-02 10:39 UTC (permalink / raw)
  To: isar-users
  Cc: tobiasschmidl, henning.schild, jan.kiszka, amikan, Felix Moessbauer

This patch fixes the bug that /etc/machine-id is never
generated when running from within an initrd with an ro rootfs.

In this case, the magic value "uninitialized" has to be used
instead of deleting the file.

For older systemd versions, we set it to the empty string
which is non-documented, but works as identified
in various tests on debian buster (systemd version 241).

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes/image-postproc-extension.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/meta/classes/image-postproc-extension.bbclass b/meta/classes/image-postproc-extension.bbclass
index 0c412c0d..4a901cbf 100644
--- a/meta/classes/image-postproc-extension.bbclass
+++ b/meta/classes/image-postproc-extension.bbclass
@@ -56,8 +56,15 @@ image_postprocess_mark() {
 ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_machine_id"
 image_postprocess_machine_id() {
     # systemd(1) takes care of recreating the machine-id on first boot
+    # for systemd < v247, set to empty string, else set to uninitialized
+    # (required if initramfs with ro root is used)
+    SYSTEMD_VERSION=$( sudo chroot ${IMAGE_ROOTFS} dpkg-query --showformat='${source:Upstream-Version}' --show systemd || echo "0" )
+    MACHINE_ID="uninitialized"
+    if dpkg --compare-versions "$SYSTEMD_VERSION" "lt" "247"; then
+        MACHINE_ID=""
+    fi
+    echo "$MACHINE_ID" | sudo tee '${IMAGE_ROOTFS}/etc/machine-id'
     sudo rm -f '${IMAGE_ROOTFS}/var/lib/dbus/machine-id'
-    sudo rm -f '${IMAGE_ROOTFS}/etc/machine-id'
 }
 
 ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_sshd_key_regen"
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] fix on-first-boot for systemd >= 247
  2022-08-02 10:39 [PATCH v3] fix on-first-boot for systemd >= 247 Felix Moessbauer
@ 2022-08-09 19:01 ` Schmidl, Tobias
  2022-08-10  7:10   ` Anton Mikanovich
  2022-08-10 11:33 ` Anton Mikanovich
  1 sibling, 1 reply; 4+ messages in thread
From: Schmidl, Tobias @ 2022-08-09 19:01 UTC (permalink / raw)
  To: isar-users; +Cc: amikan, jan.kiszka, Moessbauer, Felix, Schild, Henning

Hi all,

Am Dienstag, dem 02.08.2022 um 12:39 +0200 schrieb Felix Moessbauer:
> This patch fixes the bug that /etc/machine-id is never
> generated when running from within an initrd with an ro rootfs.
> 
> In this case, the magic value "uninitialized" has to be used
> instead of deleting the file.
> 
> For older systemd versions, we set it to the empty string
> which is non-documented, but works as identified
> in various tests on debian buster (systemd version 241).
> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---

What is the status of this patch? Are there any impediments?

Kinds regards,

Tobias


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] fix on-first-boot for systemd >= 247
  2022-08-09 19:01 ` Schmidl, Tobias
@ 2022-08-10  7:10   ` Anton Mikanovich
  0 siblings, 0 replies; 4+ messages in thread
From: Anton Mikanovich @ 2022-08-10  7:10 UTC (permalink / raw)
  To: Schmidl, Tobias, isar-users
  Cc: jan.kiszka, Moessbauer, Felix, Schild, Henning

09.08.2022 22:01, Schmidl, Tobias wrote:
> Hi all,
>
> Am Dienstag, dem 02.08.2022 um 12:39 +0200 schrieb Felix Moessbauer:
>> This patch fixes the bug that /etc/machine-id is never
>> generated when running from within an initrd with an ro rootfs.
>>
>> In this case, the magic value "uninitialized" has to be used
>> instead of deleting the file.
>>
>> For older systemd versions, we set it to the empty string
>> which is non-documented, but works as identified
>> in various tests on debian buster (systemd version 241).
>>
>> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
>> ---
> What is the status of this patch? Are there any impediments?
>
> Kinds regards,
>
> Tobias
>
Hello Tobias,

This patch was tested and looks ok.
A week past from the patch receiving, so we are ready to apply it.
Didn't managed to merge it yesterday, will do it today.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] fix on-first-boot for systemd >= 247
  2022-08-02 10:39 [PATCH v3] fix on-first-boot for systemd >= 247 Felix Moessbauer
  2022-08-09 19:01 ` Schmidl, Tobias
@ 2022-08-10 11:33 ` Anton Mikanovich
  1 sibling, 0 replies; 4+ messages in thread
From: Anton Mikanovich @ 2022-08-10 11:33 UTC (permalink / raw)
  To: Felix Moessbauer, isar-users; +Cc: tobiasschmidl, henning.schild, jan.kiszka

02.08.2022 13:39, Felix Moessbauer wrote:
> This patch fixes the bug that /etc/machine-id is never
> generated when running from within an initrd with an ro rootfs.
>
> In this case, the magic value "uninitialized" has to be used
> instead of deleting the file.
>
> For older systemd versions, we set it to the empty string
> which is non-documented, but works as identified
> in various tests on debian buster (systemd version 241).
>
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>

Applied to next, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-10 11:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 10:39 [PATCH v3] fix on-first-boot for systemd >= 247 Felix Moessbauer
2022-08-09 19:01 ` Schmidl, Tobias
2022-08-10  7:10   ` Anton Mikanovich
2022-08-10 11:33 ` Anton Mikanovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox