From 8bdfcac0fbae62623c2cedc92439d0472ea72865 Mon Sep 17 00:00:00 2001 From: dalto Date: Sat, 13 Nov 2021 09:31:23 -0600 Subject: [PATCH] [partition] Add support for zfs encryption when erase disk is selected --- src/modules/mount/main.py | 1 - .../partition/core/PartitionLayout.cpp | 22 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py index 20815969a..f58b90e9f 100644 --- a/src/modules/mount/main.py +++ b/src/modules/mount/main.py @@ -118,7 +118,6 @@ def mount_partition(root_mount_point, partition, partitions): raise Exception("Internal error mounting zfs datasets") for zfs_pool in zfs_pool_list: - libcalamares.utils.warning("Poolname: " + zfs_pool["poolName"] + " mountpoint: " + zfs_pool["mountpoint"]) if zfs_pool["mountpoint"] == partition["mountPoint"]: pool_name = zfs_pool["poolName"] ds_name = zfs_pool["dsName"]; diff --git a/src/modules/partition/core/PartitionLayout.cpp b/src/modules/partition/core/PartitionLayout.cpp index 8ae904e92..f60952643 100644 --- a/src/modules/partition/core/PartitionLayout.cpp +++ b/src/modules/partition/core/PartitionLayout.cpp @@ -296,7 +296,9 @@ PartitionLayout::createPartitions( Device* dev, } Partition* part = nullptr; - if ( luksPassphrase.isEmpty() ) + + // Encryption for zfs is handled in the zfs module + if ( luksPassphrase.isEmpty() || correctFS( entry.partFileSystem ) == FileSystem::Zfs ) { part = KPMHelpers::createNewPartition( parent, *dev, @@ -319,6 +321,24 @@ PartitionLayout::createPartitions( Device* dev, luksPassphrase, KPM_PARTITION_FLAG( None ) ); } + + // For zfs, we need to make the passphrase available to later modules + if ( correctFS( entry.partFileSystem ) == FileSystem::Zfs ) + { + Calamares::GlobalStorage* storage = Calamares::JobQueue::instance()->globalStorage(); + QList< QVariant > zfsInfoList; + QVariantMap zfsInfo; + + // Save the information subsequent modules will need + zfsInfo[ "encrypted" ] = !luksPassphrase.isEmpty(); + zfsInfo[ "passphrase" ] = luksPassphrase; + zfsInfo[ "mountpoint" ] = entry.partMountPoint; + + // Add it to the list and insert it into global storage + zfsInfoList.append( zfsInfo ); + storage->insert( "zfsInfo", zfsInfoList ); + } + PartitionInfo::setFormat( part, true ); PartitionInfo::setMountPoint( part, entry.partMountPoint ); if ( !entry.partLabel.isEmpty() )