From 745b4b169322724dca15d408f0ce391940064520 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 4 Jul 2019 13:17:34 +0200 Subject: [PATCH] [luksbootkeyfile] Extract partitioning keyphrases from GS --- .../luksbootkeyfile/LuksBootKeyFileJob.cpp | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/modules/luksbootkeyfile/LuksBootKeyFileJob.cpp b/src/modules/luksbootkeyfile/LuksBootKeyFileJob.cpp index fb659cfab..c05cb970d 100644 --- a/src/modules/luksbootkeyfile/LuksBootKeyFileJob.cpp +++ b/src/modules/luksbootkeyfile/LuksBootKeyFileJob.cpp @@ -49,7 +49,37 @@ struct GlobalSettings GlobalSettings( const QVariant& partitions ) : valid( false ) { - cDebug() << partitions; + if ( partitions.canConvert() ) + { + filesystems = getPartitionInfo( partitions.toList() ); + valid = true; + } + } + + /** @brief Extract the luks passphrases setup. + * + * Given a list of partitions (as set up by the partitioning module, + * so there's maps with keys inside), returns just the list of + * luks passphrases for each device. + */ + static QList< LuksPassphrase > getPartitionInfo( const QVariantList& list ) + { + int count = 0; + for( const auto& p : list ) + { + if ( p.canConvert< QVariantMap>() ) + { + auto pinfo = p.toMap(); + QString device = pinfo["device"].toString(); + QString fs = pinfo["fs"].toString(); + QString mountPoint = pinfo["mountPoint"].toString(); + QString uuid = pinfo["uuid"].toString(); + + cDebug() << count << "D=" << device << mountPoint << '(' << fs << ')'; + } + count++; + } + return QList< LuksPassphrase >(); } QList< LuksPassphrase > filesystems; @@ -69,7 +99,7 @@ LuksBootKeyFileJob::exec() { return Calamares::JobResult::internalError( "LukeBootKeyFile", - tr( "No partitions are defined for
%1
to use." ).arg( "luksbootkeyfile" ), + tr( "No partitions are defined for LUKS to use." ).arg( "luksbootkeyfile" ), Calamares::JobResult::InvalidConfiguration ); }