diff --git a/src/modules/luksbootkeyfile/LuksBootKeyFileJob.cpp b/src/modules/luksbootkeyfile/LuksBootKeyFileJob.cpp index 9bd2f66da..940d75be6 100644 --- a/src/modules/luksbootkeyfile/LuksBootKeyFileJob.cpp +++ b/src/modules/luksbootkeyfile/LuksBootKeyFileJob.cpp @@ -129,6 +129,30 @@ setupLuks( const LuksDevice& d ) return true; } +// static +QVariantList +LuksBootKeyFileJob::partitions() +{ + Calamares::GlobalStorage* globalStorage = Calamares::JobQueue::instance()->globalStorage(); + return globalStorage->value( QStringLiteral( "partitions" ) ).toList(); +} + +static bool +LuksBootKeyFileJob::hasUnencryptedSeparateBoot() +{ + const QVariantList partitions = LuksBootKeyFileJob::partitions(); + for ( const QVariant& partition : partitions ) + { + QVariantMap partitionMap = partition.toMap(); + QString mountPoint = partitionMap.value( QStringLiteral( "mountPoint" ) ).toString(); + if ( mountPoint == QStringLiteral( "/boot" ) ) + { + return !partitionMap.contains( QStringLiteral( "luksMapperName" ) ); + } + } + return false; +} + Calamares::JobResult LuksBootKeyFileJob::exec() { @@ -174,6 +198,13 @@ LuksBootKeyFileJob::exec() return Calamares::JobResult::ok(); } + // /boot partition is not encrypted, keyfile must not be used + if ( hasUnencryptedSeparateBoot() ) + { + cDebug() << Logger::SubEntry << "/boot partition is not encryptepted, skipping keyfile creation."; + return Calamares::JobResult::ok(); + } + if ( s.devices.first().passphrase.isEmpty() ) { cDebug() << Logger::SubEntry << "No root passphrase.";