Try not to create the keyfile if not necessary

main
Chrysostomus 4 years ago
parent 73b5c62ab8
commit 3731dfb146

@ -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.";

Loading…
Cancel
Save