From 24ade72f7faff9613c2842548abcae204c6316a8 Mon Sep 17 00:00:00 2001 From: Bryan Fink Date: Sat, 15 Mar 2025 10:42:13 -0500 Subject: [PATCH] add lvm-on-luks partition to crypttab Before this change, this code didn't detect that an ext4 partition on LVM-on-LUKS needed a crypttab entry. --- src/Core/Main.vala | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Core/Main.vala b/src/Core/Main.vala index a47a3aed..806c4735 100644 --- a/src/Core/Main.vala +++ b/src/Core/Main.vala @@ -2879,11 +2879,19 @@ public class Main : GLib.Object{ // check and add entries for mapped devices which are encrypted foreach(var mnt in mount_list){ - if ((mnt.device != null) && (mnt.device.parent != null) && (mnt.device.is_on_encrypted_partition())){ - + if ((mnt.device != null) && (mnt.device.parent != null) + && ((mnt.device.is_on_encrypted_partition()) + || ((mnt.device.parent.parent != null) && + (mnt.device.parent.is_on_encrypted_partition())))){ + + // We could be either directly on LUKS or on LVM-on-LUKS, + // so be sure to get the top-level LUKS UUID. + var crypt_parent = (mnt.device.is_on_encrypted_partition()) ? + mnt.device.parent.uuid : mnt.device.parent.parent.uuid; + // find existing var entry = CryptTabEntry.find_entry_by_uuid( - crypttab_list, mnt.device.parent.uuid); + crypttab_list, crypt_parent); // add if missing if (entry == null){ @@ -2892,8 +2900,8 @@ public class Main : GLib.Object{ } // set custom values - entry.device_uuid = mnt.device.parent.uuid; - entry.mapped_name = "luks-%s".printf(mnt.device.parent.uuid); + entry.device_uuid = crypt_parent; + entry.mapped_name = "luks-%s".printf(crypt_parent); entry.keyfile = "none"; entry.options = "luks,nofail"; }