|
|
|
@ -24,8 +24,8 @@
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
|
|
|
|
|
#include "CalamaresVersion.h"
|
|
|
|
|
#include "JobQueue.h"
|
|
|
|
|
#include "GlobalStorage.h"
|
|
|
|
|
#include "JobQueue.h"
|
|
|
|
|
|
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
|
|
|
|
@ -33,24 +33,24 @@
|
|
|
|
|
const QLatin1String DracutLuksCfgJob::CONFIG_FILE( "/etc/dracut.conf.d/calamares-luks.conf" );
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
const char *DracutLuksCfgJob::CONFIG_FILE_HEADER =
|
|
|
|
|
"# Configuration file automatically written by the Calamares system installer\n"
|
|
|
|
|
const char* DracutLuksCfgJob::CONFIG_FILE_HEADER
|
|
|
|
|
= "# Configuration file automatically written by the Calamares system installer\n"
|
|
|
|
|
"# (This file is written once at install time and should be safe to edit.)\n"
|
|
|
|
|
"# Enables support for LUKS full disk encryption with single sign on from GRUB.\n"
|
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
const char *DracutLuksCfgJob::CONFIG_FILE_CRYPTTAB_KEYFILE_LINE =
|
|
|
|
|
"# force installing /etc/crypttab even if hostonly=\"no\", install the keyfile\n"
|
|
|
|
|
const char* DracutLuksCfgJob::CONFIG_FILE_CRYPTTAB_KEYFILE_LINE
|
|
|
|
|
= "# force installing /etc/crypttab even if hostonly=\"no\", install the keyfile\n"
|
|
|
|
|
"install_items+=\" /etc/crypttab /crypto_keyfile.bin \"\n";
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
const char *DracutLuksCfgJob::CONFIG_FILE_CRYPTTAB_LINE =
|
|
|
|
|
"# force installing /etc/crypttab even if hostonly=\"no\"\n"
|
|
|
|
|
const char* DracutLuksCfgJob::CONFIG_FILE_CRYPTTAB_LINE = "# force installing /etc/crypttab even if hostonly=\"no\"\n"
|
|
|
|
|
"install_items+=\" /etc/crypttab \"\n";
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
const QLatin1String DracutLuksCfgJob::CONFIG_FILE_SWAPLINE( "# enable automatic resume from swap\nadd_device+=\" /dev/disk/by-uuid/%1 \"\n" );
|
|
|
|
|
const QLatin1String DracutLuksCfgJob::CONFIG_FILE_SWAPLINE(
|
|
|
|
|
"# enable automatic resume from swap\nadd_device+=\" /dev/disk/by-uuid/%1 \"\n" );
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
QString
|
|
|
|
@ -78,8 +78,10 @@ DracutLuksCfgJob::isRootEncrypted()
|
|
|
|
|
QVariantMap partitionMap = partition.toMap();
|
|
|
|
|
QString mountPoint = partitionMap.value( QStringLiteral( "mountPoint" ) ).toString();
|
|
|
|
|
if ( mountPoint == QStringLiteral( "/" ) )
|
|
|
|
|
{
|
|
|
|
|
return partitionMap.contains( QStringLiteral( "luksMapperName" ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -93,8 +95,10 @@ DracutLuksCfgJob::hasUnencryptedSeparateBoot()
|
|
|
|
|
QVariantMap partitionMap = partition.toMap();
|
|
|
|
|
QString mountPoint = partitionMap.value( QStringLiteral( "mountPoint" ) ).toString();
|
|
|
|
|
if ( mountPoint == QStringLiteral( "/boot" ) )
|
|
|
|
|
{
|
|
|
|
|
return !partitionMap.contains( QStringLiteral( "luksMapperName" ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -108,8 +112,10 @@ DracutLuksCfgJob::swapOuterUuid()
|
|
|
|
|
QVariantMap partitionMap = partition.toMap();
|
|
|
|
|
QString fsType = partitionMap.value( QStringLiteral( "fs" ) ).toString();
|
|
|
|
|
if ( fsType == QStringLiteral( "linuxswap" ) && partitionMap.contains( QStringLiteral( "luksMapperName" ) ) )
|
|
|
|
|
{
|
|
|
|
|
return partitionMap.value( QStringLiteral( "luksUuid" ) ).toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -119,19 +125,21 @@ DracutLuksCfgJob::DracutLuksCfgJob( QObject* parent )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DracutLuksCfgJob::~DracutLuksCfgJob()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
DracutLuksCfgJob::~DracutLuksCfgJob() {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
|
DracutLuksCfgJob::prettyName() const
|
|
|
|
|
{
|
|
|
|
|
if ( isRootEncrypted() )
|
|
|
|
|
{
|
|
|
|
|
return tr( "Write LUKS configuration for Dracut to %1" ).arg( CONFIG_FILE );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return tr( "Skip writing LUKS configuration for Dracut: \"/\" partition is not encrypted" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calamares::JobResult
|
|
|
|
@ -150,8 +158,7 @@ DracutLuksCfgJob::exec()
|
|
|
|
|
}
|
|
|
|
|
QTextStream outStream( &configFile );
|
|
|
|
|
outStream << CONFIG_FILE_HEADER
|
|
|
|
|
<< ( hasUnencryptedSeparateBoot() ? CONFIG_FILE_CRYPTTAB_LINE
|
|
|
|
|
: CONFIG_FILE_CRYPTTAB_KEYFILE_LINE );
|
|
|
|
|
<< ( hasUnencryptedSeparateBoot() ? CONFIG_FILE_CRYPTTAB_LINE : CONFIG_FILE_CRYPTTAB_KEYFILE_LINE );
|
|
|
|
|
const QString swapOuterUuid = DracutLuksCfgJob::swapOuterUuid();
|
|
|
|
|
if ( !swapOuterUuid.isEmpty() )
|
|
|
|
|
{
|
|
|
|
@ -159,8 +166,11 @@ DracutLuksCfgJob::exec()
|
|
|
|
|
outStream << QString( CONFIG_FILE_SWAPLINE ).arg( swapOuterUuid ).toLatin1();
|
|
|
|
|
}
|
|
|
|
|
cDebug() << "[DRACUTLUKSCFG]: Wrote config to" << realConfigFilePath;
|
|
|
|
|
} else
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cDebug() << "[DRACUTLUKSCFG]: / not encrypted, skipping";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Calamares::JobResult::ok();
|
|
|
|
|
}
|
|
|
|
|