Skip to content

Commit 61aaa19

Browse files
authored
add lvm-on-luks partition to crypttab (#398)
Before this change, this code didn't detect that an ext4 partition on LVM-on-LUKS needed a crypttab entry.
1 parent d1e1a50 commit 61aaa19

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/Core/Main.vala

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,11 +3012,19 @@ public class Main : GLib.Object{
30123012
// check and add entries for mapped devices which are encrypted
30133013

30143014
foreach(var mnt in mount_list){
3015-
if ((mnt.device != null) && (mnt.device.parent != null) && (mnt.device.is_on_encrypted_partition())){
3016-
3015+
if ((mnt.device != null) && (mnt.device.parent != null)
3016+
&& ((mnt.device.is_on_encrypted_partition())
3017+
|| ((mnt.device.parent.parent != null) &&
3018+
(mnt.device.parent.is_on_encrypted_partition())))){
3019+
3020+
// We could be either directly on LUKS or on LVM-on-LUKS,
3021+
// so be sure to get the top-level LUKS UUID.
3022+
var crypt_parent = (mnt.device.is_on_encrypted_partition()) ?
3023+
mnt.device.parent.uuid : mnt.device.parent.parent.uuid;
3024+
30173025
// find existing
30183026
var entry = CryptTabEntry.find_entry_by_uuid(
3019-
crypttab_list, mnt.device.parent.uuid);
3027+
crypttab_list, crypt_parent);
30203028

30213029
// add if missing
30223030
if (entry == null){
@@ -3025,8 +3033,8 @@ public class Main : GLib.Object{
30253033
}
30263034

30273035
// set custom values
3028-
entry.device_uuid = mnt.device.parent.uuid;
3029-
entry.mapped_name = "luks-%s".printf(mnt.device.parent.uuid);
3036+
entry.device_uuid = crypt_parent;
3037+
entry.mapped_name = "luks-%s".printf(crypt_parent);
30303038
entry.keyfile = "none";
30313039
entry.options = "luks,nofail";
30323040
}

0 commit comments

Comments
 (0)