]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut.sh): handle /etc/machine-id empty or uninitialized
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Tue, 7 Mar 2023 15:17:16 +0000 (16:17 +0100)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Wed, 26 Apr 2023 12:18:44 +0000 (12:18 +0000)
Handle the case where the user tries to generate the initrd after explicitly
resetting the /etc/machine-id file.

Fixes issue #2267

dracut.sh

index 1f6f0aee80c9904bbf8e74c1e62fbecc482f31af..7178ac5e3946b410dd05808c3e17777556028aa1 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1087,8 +1087,9 @@ if ! [[ $outfile ]]; then
             || [[ -d "$dracutsysrootdir"/boot/Default ]] \
             || [[ -d "$dracutsysrootdir"/boot/efi/Default ]]; then
             MACHINE_ID="Default"
-        elif [[ -f "$dracutsysrootdir"/etc/machine-id ]]; then
+        elif [[ -s "$dracutsysrootdir"/etc/machine-id ]]; then
             read -r MACHINE_ID < "$dracutsysrootdir"/etc/machine-id
+            [[ $MACHINE_ID == "uninitialized" ]] && MACHINE_ID="Default"
         else
             MACHINE_ID="Default"
         fi