Try not to create the keyfile if not necessary

This commit is contained in:
Chrysostomus 2020-11-06 21:31:28 +02:00
parent 73b5c62ab8
commit 3731dfb146

View File

@ -129,6 +129,30 @@ setupLuks( const LuksDevice& d )
return true; 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 Calamares::JobResult
LuksBootKeyFileJob::exec() LuksBootKeyFileJob::exec()
{ {
@ -174,6 +198,13 @@ LuksBootKeyFileJob::exec()
return Calamares::JobResult::ok(); 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() ) if ( s.devices.first().passphrase.isEmpty() )
{ {
cDebug() << Logger::SubEntry << "No root passphrase."; cDebug() << Logger::SubEntry << "No root passphrase.";