Merge pull request #1952 from abalfoort/#1935
#1935 - Reuse luks partitions
This commit is contained in:
commit
9d6bb2ee2a
@ -162,14 +162,19 @@ class FstabGenerator(object):
|
|||||||
crypttab_options = self.crypttab_options
|
crypttab_options = self.crypttab_options
|
||||||
|
|
||||||
# Set crypttab password for partition to none and remove crypttab options
|
# Set crypttab password for partition to none and remove crypttab options
|
||||||
|
# if crypto_keyfile.bin was not generated
|
||||||
|
if not os.path.exists(os.path.join(self.root_mount_point, "crypto_keyfile.bin")):
|
||||||
|
password = "none"
|
||||||
|
crypttab_options = ""
|
||||||
# on root partition when /boot is unencrypted
|
# on root partition when /boot is unencrypted
|
||||||
if partition["mountPoint"] == "/":
|
elif partition["mountPoint"] == "/":
|
||||||
if any([p["mountPoint"] == "/boot"
|
if any([p["mountPoint"] == "/boot"
|
||||||
and "luksMapperName" not in p
|
and "luksMapperName" not in p
|
||||||
for p in self.partitions]):
|
for p in self.partitions]):
|
||||||
password = "none"
|
password = "none"
|
||||||
crypttab_options = ""
|
crypttab_options = ""
|
||||||
|
|
||||||
|
|
||||||
return dict(
|
return dict(
|
||||||
name=mapper_name,
|
name=mapper_name,
|
||||||
device="UUID=" + luks_uuid,
|
device="UUID=" + luks_uuid,
|
||||||
|
@ -251,7 +251,9 @@ fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configu
|
|||||||
gs->insert( "efiSystemPartitionSize", sizeString );
|
gs->insert( "efiSystemPartitionSize", sizeString );
|
||||||
gs->insert( "efiSystemPartitionSize_i", part_size.toBytes() );
|
gs->insert( "efiSystemPartitionSize_i", part_size.toBytes() );
|
||||||
|
|
||||||
if ( part_size.toBytes() != PartUtils::efiFilesystemMinimumSize() )
|
// Assign long long int to long unsigned int to prevent compilation warning
|
||||||
|
size_t unsigned_part_size = part_size.toBytes();
|
||||||
|
if ( unsigned_part_size != PartUtils::efiFilesystemMinimumSize() )
|
||||||
{
|
{
|
||||||
cWarning() << "EFI partition size" << sizeString << "has been adjusted to"
|
cWarning() << "EFI partition size" << sizeString << "has been adjusted to"
|
||||||
<< PartUtils::efiFilesystemMinimumSize() << "bytes";
|
<< PartUtils::efiFilesystemMinimumSize() << "bytes";
|
||||||
|
@ -22,15 +22,17 @@
|
|||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystemfactory.h>
|
#include <kpmcore/fs/filesystemfactory.h>
|
||||||
#include <kpmcore/fs/luks.h>
|
#include <kpmcore/fs/luks.h>
|
||||||
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
#include <kpmcore/util/externalcommand.h>
|
||||||
|
|
||||||
using CalamaresUtils::Partition::PartitionIterator;
|
using CalamaresUtils::Partition::PartitionIterator;
|
||||||
|
|
||||||
namespace KPMHelpers
|
namespace KPMHelpers
|
||||||
{
|
{
|
||||||
|
|
||||||
Partition*
|
Partition*
|
||||||
findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint )
|
findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint )
|
||||||
{
|
{
|
||||||
for ( auto device : devices )
|
for ( auto device : devices )
|
||||||
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
||||||
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
|
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
|
||||||
@ -38,11 +40,11 @@ findPartitionByMountPoint( const QList< Device* >& devices, const QString& mount
|
|||||||
return *it;
|
return *it;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Partition*
|
Partition*
|
||||||
createNewPartition( PartitionNode* parent,
|
createNewPartition( PartitionNode* parent,
|
||||||
const Device& device,
|
const Device& device,
|
||||||
const PartitionRole& role,
|
const PartitionRole& role,
|
||||||
FileSystem::Type fsType,
|
FileSystem::Type fsType,
|
||||||
@ -50,7 +52,7 @@ createNewPartition( PartitionNode* parent,
|
|||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
PartitionTable::Flags flags )
|
PartitionTable::Flags flags )
|
||||||
{
|
{
|
||||||
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() );
|
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() );
|
||||||
fs->setLabel( fsLabel );
|
fs->setLabel( fsLabel );
|
||||||
return new Partition( parent,
|
return new Partition( parent,
|
||||||
@ -65,11 +67,11 @@ createNewPartition( PartitionNode* parent,
|
|||||||
false /* mounted */,
|
false /* mounted */,
|
||||||
flags /* activeFlags */,
|
flags /* activeFlags */,
|
||||||
KPM_PARTITION_STATE( New ) );
|
KPM_PARTITION_STATE( New ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Partition*
|
Partition*
|
||||||
createNewEncryptedPartition( PartitionNode* parent,
|
createNewEncryptedPartition( PartitionNode* parent,
|
||||||
const Device& device,
|
const Device& device,
|
||||||
const PartitionRole& role,
|
const PartitionRole& role,
|
||||||
FileSystem::Type fsType,
|
FileSystem::Type fsType,
|
||||||
@ -78,7 +80,7 @@ createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
const QString& passphrase,
|
const QString& passphrase,
|
||||||
PartitionTable::Flags flags )
|
PartitionTable::Flags flags )
|
||||||
{
|
{
|
||||||
PartitionRole::Roles newRoles = role.roles();
|
PartitionRole::Roles newRoles = role.roles();
|
||||||
if ( !role.has( PartitionRole::Luks ) )
|
if ( !role.has( PartitionRole::Luks ) )
|
||||||
{
|
{
|
||||||
@ -109,12 +111,12 @@ createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
flags /* activeFlags */,
|
flags /* activeFlags */,
|
||||||
KPM_PARTITION_STATE( New ) );
|
KPM_PARTITION_STATE( New ) );
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Partition*
|
Partition*
|
||||||
clonePartition( Device* device, Partition* partition )
|
clonePartition( Device* device, Partition* partition )
|
||||||
{
|
{
|
||||||
FileSystem* fs = FileSystemFactory::create(
|
FileSystem* fs = FileSystemFactory::create(
|
||||||
partition->fileSystem().type(), partition->firstSector(), partition->lastSector(), device->logicalSize() );
|
partition->fileSystem().type(), partition->firstSector(), partition->lastSector(), device->logicalSize() );
|
||||||
return new Partition( partition->parent(),
|
return new Partition( partition->parent(),
|
||||||
@ -125,11 +127,91 @@ clonePartition( Device* device, Partition* partition )
|
|||||||
fs->lastSector(),
|
fs->lastSector(),
|
||||||
partition->partitionPath(),
|
partition->partitionPath(),
|
||||||
partition->activeFlags() );
|
partition->activeFlags() );
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobResult
|
// Adapted from luks cryptOpen which always opens a dialog to ask for a passphrase
|
||||||
execute( Operation& operation, const QString& failureMessage )
|
int
|
||||||
{
|
updateLuksDevice( Partition* partition, const QString& passphrase )
|
||||||
|
{
|
||||||
|
const QString deviceNode = partition->partitionPath();
|
||||||
|
|
||||||
|
cDebug() << "Update Luks device: " << deviceNode;
|
||||||
|
|
||||||
|
if ( passphrase.isEmpty() )
|
||||||
|
{
|
||||||
|
cWarning() << Logger::SubEntry << "#1: Passphrase is empty";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( partition->fileSystem().type() != FileSystem::Luks )
|
||||||
|
{
|
||||||
|
cWarning() << Logger::SubEntry << "#2: Not a luks encrypted device";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cast partition fs to luks fs
|
||||||
|
FS::luks* luksFs = dynamic_cast< FS::luks* >( &partition->fileSystem() );
|
||||||
|
|
||||||
|
// Test the given passphrase
|
||||||
|
if ( !luksFs->testPassphrase( deviceNode, passphrase ) )
|
||||||
|
{
|
||||||
|
cWarning() << Logger::SubEntry << "#3: Passphrase incorrect";
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( luksFs->isCryptOpen() )
|
||||||
|
{
|
||||||
|
if ( !luksFs->mapperName().isEmpty())
|
||||||
|
{
|
||||||
|
cWarning() << Logger::SubEntry << "#4: Device already decrypted";
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "No mapper node found";
|
||||||
|
luksFs->setCryptOpen( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExternalCommand openCmd( QStringLiteral( "cryptsetup" ),
|
||||||
|
{ QStringLiteral( "open" ),
|
||||||
|
deviceNode,
|
||||||
|
luksFs->suggestedMapperName( deviceNode ) } );
|
||||||
|
|
||||||
|
if ( !( openCmd.write( passphrase.toLocal8Bit() + '\n' ) &&
|
||||||
|
openCmd.start( -1 ) &&
|
||||||
|
openCmd.exitCode() == 0 ) )
|
||||||
|
{
|
||||||
|
cWarning() << Logger::SubEntry << openCmd.exitCode() << ": cryptsetup command failed";
|
||||||
|
return openCmd.exitCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the existing passphrase
|
||||||
|
luksFs->setPassphrase( passphrase );
|
||||||
|
|
||||||
|
luksFs->scan( deviceNode );
|
||||||
|
|
||||||
|
if ( luksFs->mapperName().isEmpty() )
|
||||||
|
{
|
||||||
|
cWarning() << Logger::SubEntry << "#5: No mapper node found";
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
luksFs->loadInnerFileSystem( luksFs->mapperName() );
|
||||||
|
luksFs->setCryptOpen( luksFs->innerFS() != nullptr );
|
||||||
|
|
||||||
|
if ( !luksFs->isCryptOpen() )
|
||||||
|
{
|
||||||
|
cWarning() << Logger::SubEntry << "#6: Device could not be decrypted";
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Calamares::JobResult
|
||||||
|
execute( Operation& operation, const QString& failureMessage )
|
||||||
|
{
|
||||||
operation.setStatus( Operation::StatusRunning );
|
operation.setStatus( Operation::StatusRunning );
|
||||||
|
|
||||||
Report report( nullptr );
|
Report report( nullptr );
|
||||||
@ -143,7 +225,7 @@ execute( Operation& operation, const QString& failureMessage )
|
|||||||
std::for_each( l.begin(), l.end(), []( QString& s ) { CalamaresUtils::removeLeading( s, '=' ); } );
|
std::for_each( l.begin(), l.end(), []( QString& s ) { CalamaresUtils::removeLeading( s, '=' ); } );
|
||||||
|
|
||||||
return Calamares::JobResult::error( failureMessage, l.join( '\n' ) );
|
return Calamares::JobResult::error( failureMessage, l.join( '\n' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace KPMHelpers
|
} // namespace KPMHelpers
|
||||||
|
@ -43,17 +43,17 @@ class PartitionRole;
|
|||||||
namespace KPMHelpers
|
namespace KPMHelpers
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates on all devices and return the first partition which is associated
|
* Iterates on all devices and return the first partition which is associated
|
||||||
* with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint()
|
* with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint()
|
||||||
*/
|
*/
|
||||||
Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint );
|
Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to create a new Partition object (does not create anything
|
* Helper function to create a new Partition object (does not create anything
|
||||||
* on the disk) associated with a FileSystem.
|
* on the disk) associated with a FileSystem.
|
||||||
*/
|
*/
|
||||||
Partition* createNewPartition( PartitionNode* parent,
|
Partition* createNewPartition( PartitionNode* parent,
|
||||||
const Device& device,
|
const Device& device,
|
||||||
const PartitionRole& role,
|
const PartitionRole& role,
|
||||||
FileSystem::Type fsType,
|
FileSystem::Type fsType,
|
||||||
@ -62,7 +62,7 @@ Partition* createNewPartition( PartitionNode* parent,
|
|||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
PartitionTable::Flags flags );
|
PartitionTable::Flags flags );
|
||||||
|
|
||||||
Partition* createNewEncryptedPartition( PartitionNode* parent,
|
Partition* createNewEncryptedPartition( PartitionNode* parent,
|
||||||
const Device& device,
|
const Device& device,
|
||||||
const PartitionRole& role,
|
const PartitionRole& role,
|
||||||
FileSystem::Type fsType,
|
FileSystem::Type fsType,
|
||||||
@ -72,25 +72,27 @@ Partition* createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
const QString& passphrase,
|
const QString& passphrase,
|
||||||
PartitionTable::Flags flags );
|
PartitionTable::Flags flags );
|
||||||
|
|
||||||
Partition* clonePartition( Device* device, Partition* partition );
|
Partition* clonePartition( Device* device, Partition* partition );
|
||||||
|
|
||||||
/** @brief Return a result for an @p operation
|
int updateLuksDevice( Partition* partition, const QString& passphrase );
|
||||||
|
|
||||||
|
/** @brief Return a result for an @p operation
|
||||||
*
|
*
|
||||||
* Executes the operation, and if successful, returns a success result.
|
* Executes the operation, and if successful, returns a success result.
|
||||||
* Otherwise returns an error using @p failureMessage as the primary part
|
* Otherwise returns an error using @p failureMessage as the primary part
|
||||||
* of the error, and details obtained from the operation.
|
* of the error, and details obtained from the operation.
|
||||||
*/
|
*/
|
||||||
Calamares::JobResult execute( Operation& operation, const QString& failureMessage );
|
Calamares::JobResult execute( Operation& operation, const QString& failureMessage );
|
||||||
/** @brief Return a result for an @p operation
|
/** @brief Return a result for an @p operation
|
||||||
*
|
*
|
||||||
* It's acceptable to use an rvalue: the operation-running is the effect
|
* It's acceptable to use an rvalue: the operation-running is the effect
|
||||||
* you're interested in, rather than keeping the temporary around.
|
* you're interested in, rather than keeping the temporary around.
|
||||||
*/
|
*/
|
||||||
static inline Calamares::JobResult
|
static inline Calamares::JobResult
|
||||||
execute( Operation&& operation, const QString& failureMessage )
|
execute( Operation&& operation, const QString& failureMessage )
|
||||||
{
|
{
|
||||||
return execute( operation, failureMessage );
|
return execute( operation, failureMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace KPMHelpers
|
} // namespace KPMHelpers
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "core/PartUtils.h"
|
#include "core/PartUtils.h"
|
||||||
#include "core/PartitionCoreModule.h"
|
#include "core/PartitionCoreModule.h"
|
||||||
#include "core/PartitionInfo.h"
|
#include "core/PartitionInfo.h"
|
||||||
|
#include "core/KPMHelpers.h"
|
||||||
#include "gui/PartitionDialogHelpers.h"
|
#include "gui/PartitionDialogHelpers.h"
|
||||||
#include "gui/PartitionSizeController.h"
|
#include "gui/PartitionSizeController.h"
|
||||||
|
|
||||||
@ -28,14 +29,18 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "partition/FileSystem.h"
|
#include "partition/FileSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "widgets/TranslationFix.h"
|
||||||
|
|
||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystemfactory.h>
|
#include <kpmcore/fs/filesystemfactory.h>
|
||||||
|
#include <kpmcore/fs/luks.h>
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
using CalamaresUtils::Partition::untranslatedFS;
|
using CalamaresUtils::Partition::untranslatedFS;
|
||||||
using CalamaresUtils::Partition::userVisibleFS;
|
using CalamaresUtils::Partition::userVisibleFS;
|
||||||
@ -52,6 +57,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
|
|||||||
, m_usedMountPoints( usedMountPoints )
|
, m_usedMountPoints( usedMountPoints )
|
||||||
{
|
{
|
||||||
m_ui->setupUi( this );
|
m_ui->setupUi( this );
|
||||||
|
m_ui->encryptWidget->hide();
|
||||||
standardMountPoints( *( m_ui->mountPointComboBox ), PartitionInfo::mountPoint( partition ) );
|
standardMountPoints( *( m_ui->mountPointComboBox ), PartitionInfo::mountPoint( partition ) );
|
||||||
|
|
||||||
QColor color = ColorUtils::colorForPartition( m_partition );
|
QColor color = ColorUtils::colorForPartition( m_partition );
|
||||||
@ -132,10 +138,8 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
|
|||||||
setFlagList( *( m_ui->m_listFlags ), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) );
|
setFlagList( *( m_ui->m_listFlags ), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EditExistingPartitionDialog::~EditExistingPartitionDialog() {}
|
EditExistingPartitionDialog::~EditExistingPartitionDialog() {}
|
||||||
|
|
||||||
|
|
||||||
PartitionTable::Flags
|
PartitionTable::Flags
|
||||||
EditExistingPartitionDialog::newFlags() const
|
EditExistingPartitionDialog::newFlags() const
|
||||||
{
|
{
|
||||||
@ -242,8 +246,31 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
|||||||
{
|
{
|
||||||
core->setFilesystemLabel( m_device, m_partition, fsLabel );
|
core->setFilesystemLabel( m_device, m_partition, fsLabel );
|
||||||
}
|
}
|
||||||
|
|
||||||
core->refreshPartition( m_device, m_partition );
|
core->refreshPartition( m_device, m_partition );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the existing luks partition
|
||||||
|
const QString passphrase = m_ui->encryptWidget->passphrase();
|
||||||
|
if ( !passphrase.isEmpty() )
|
||||||
|
{
|
||||||
|
int retCode = KPMHelpers::updateLuksDevice( m_partition, passphrase );
|
||||||
|
if ( retCode != 0 )
|
||||||
|
{
|
||||||
|
QString message = tr( "Passphrase for existing partition" );
|
||||||
|
QString description = tr( "Partition %1 could not be decrypted "
|
||||||
|
"with the given passphrase."
|
||||||
|
"<br/><br/>"
|
||||||
|
"Edit the partition again and give the correct passphrase"
|
||||||
|
"or delete and create a new encrypted partition." )
|
||||||
|
.arg( m_partition->partitionPath() );
|
||||||
|
|
||||||
|
QMessageBox mb( QMessageBox::Information, message, description,
|
||||||
|
QMessageBox::Ok, this->parentWidget() );
|
||||||
|
Calamares::fixButtonLabels( &mb );
|
||||||
|
mb.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +293,6 @@ EditExistingPartitionDialog::replacePartResizerWidget()
|
|||||||
m_partitionSizeController->setPartResizerWidget( widget, m_ui->formatRadioButton->isChecked() );
|
m_partitionSizeController->setPartResizerWidget( widget, m_ui->formatRadioButton->isChecked() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EditExistingPartitionDialog::updateMountPointPicker()
|
EditExistingPartitionDialog::updateMountPointPicker()
|
||||||
{
|
{
|
||||||
@ -293,13 +319,50 @@ EditExistingPartitionDialog::updateMountPointPicker()
|
|||||||
{
|
{
|
||||||
setSelectedMountPoint( m_ui->mountPointComboBox, QString() );
|
setSelectedMountPoint( m_ui->mountPointComboBox, QString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleEncryptWidget();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EditExistingPartitionDialog::checkMountPointSelection()
|
EditExistingPartitionDialog::checkMountPointSelection()
|
||||||
{
|
{
|
||||||
validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ),
|
if ( validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ),
|
||||||
m_usedMountPoints,
|
m_usedMountPoints,
|
||||||
m_ui->mountPointExplanation,
|
m_ui->mountPointExplanation,
|
||||||
m_ui->buttonBox->button( QDialogButtonBox::Ok ) );
|
m_ui->buttonBox->button( QDialogButtonBox::Ok ) ) )
|
||||||
|
{
|
||||||
|
toggleEncryptWidget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EditExistingPartitionDialog::toggleEncryptWidget()
|
||||||
|
{
|
||||||
|
// Show/hide encryptWidget:
|
||||||
|
// check if partition is a previously luks formatted partition
|
||||||
|
// and not currently formatted
|
||||||
|
// and its mount point not a standard mount point except when it's /home
|
||||||
|
QString mp = selectedMountPoint( m_ui->mountPointComboBox );
|
||||||
|
if ( !mp.isEmpty()
|
||||||
|
&& m_partition->fileSystem().type() == FileSystem::Luks
|
||||||
|
&& !m_ui->formatRadioButton->isChecked()
|
||||||
|
&& ( !standardMountPoints().contains(mp) || mp == "/home" ) )
|
||||||
|
{
|
||||||
|
m_ui->encryptWidget->show();
|
||||||
|
m_ui->encryptWidget->reset( false );
|
||||||
|
}
|
||||||
|
// TODO: When formatting a partition user must be able to encrypt that partition
|
||||||
|
// Probably need to delete this partition and create a new one
|
||||||
|
// else if ( m_ui->formatRadioButton->isChecked()
|
||||||
|
// && !mp.isEmpty())
|
||||||
|
// {
|
||||||
|
// m_ui->encryptWidget->show();
|
||||||
|
// m_ui->encryptWidget->reset();
|
||||||
|
// }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ui->encryptWidget->reset();
|
||||||
|
m_ui->encryptWidget->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,11 @@ class EditExistingPartitionDialog : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
struct FreeSpace
|
||||||
|
{
|
||||||
|
Partition* p;
|
||||||
|
};
|
||||||
|
|
||||||
EditExistingPartitionDialog( Device* device,
|
EditExistingPartitionDialog( Device* device,
|
||||||
Partition* partition,
|
Partition* partition,
|
||||||
const QStringList& usedMountPoints,
|
const QStringList& usedMountPoints,
|
||||||
@ -53,6 +58,7 @@ private:
|
|||||||
PartitionTable::Flags newFlags() const;
|
PartitionTable::Flags newFlags() const;
|
||||||
void replacePartResizerWidget();
|
void replacePartResizerWidget();
|
||||||
void updateMountPointPicker();
|
void updateMountPointPicker();
|
||||||
|
void toggleEncryptWidget();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* EDITEXISTINGPARTITIONDIALOG_H */
|
#endif /* EDITEXISTINGPARTITIONDIALOG_H */
|
||||||
|
@ -10,8 +10,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>450</width>
|
<width>570</width>
|
||||||
<height>615</height>
|
<height>689</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -97,7 +97,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="8" column="0">
|
||||||
<widget class="QLabel" name="mountPointLabel">
|
<widget class="QLabel" name="mountPointLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Mount Point:</string>
|
<string>&Mount Point:</string>
|
||||||
@ -107,7 +107,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="8" column="1">
|
||||||
<widget class="QComboBox" name="mountPointComboBox">
|
<widget class="QComboBox" name="mountPointComboBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
@ -153,14 +153,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QComboBox" name="fileSystemComboBox"/>
|
<widget class="QComboBox" name="fileSystemComboBox"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0">
|
<item row="15" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Flags:</string>
|
<string>Flags:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="1">
|
<item row="15" column="1">
|
||||||
<widget class="QListWidget" name="m_listFlags">
|
<widget class="QListWidget" name="m_listFlags">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -173,7 +173,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="13" column="1">
|
||||||
<widget class="QLineEdit" name="fileSystemLabelEdit">
|
<widget class="QLineEdit" name="fileSystemLabelEdit">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Label for the filesystem</string>
|
<string>Label for the filesystem</string>
|
||||||
@ -183,20 +183,39 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="13" column="0">
|
||||||
<widget class="QLabel" name="fileSystemLabelLabel">
|
<widget class="QLabel" name="fileSystemLabelLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>FS Label:</string>
|
<string>FS Label:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="QLabel" name="mountPointExplanation">
|
<widget class="QLabel" name="mountPointExplanation">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="11" column="1">
|
||||||
|
<widget class="EncryptWidget" name="encryptWidget" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="1">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>13</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -218,6 +237,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<header location="global">kpmcore/gui/partresizerwidget.h</header>
|
<header location="global">kpmcore/gui/partresizerwidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>EncryptWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>gui/EncryptWidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>sizeSpinBox</tabstop>
|
<tabstop>sizeSpinBox</tabstop>
|
||||||
|
@ -70,14 +70,17 @@ EncryptWidget::EncryptWidget( QWidget* parent )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EncryptWidget::reset()
|
EncryptWidget::reset( bool checkVisible )
|
||||||
{
|
{
|
||||||
m_ui->m_passphraseLineEdit->clear();
|
m_ui->m_passphraseLineEdit->clear();
|
||||||
m_ui->m_confirmLineEdit->clear();
|
m_ui->m_confirmLineEdit->clear();
|
||||||
|
|
||||||
m_ui->m_encryptCheckBox->setChecked( false );
|
m_ui->m_encryptCheckBox->setChecked( false );
|
||||||
}
|
|
||||||
|
|
||||||
|
m_ui->m_encryptCheckBox->setVisible( checkVisible );
|
||||||
|
m_ui->m_passphraseLineEdit->setVisible( !checkVisible );
|
||||||
|
m_ui->m_confirmLineEdit->setVisible( !checkVisible );
|
||||||
|
}
|
||||||
|
|
||||||
EncryptWidget::Encryption
|
EncryptWidget::Encryption
|
||||||
EncryptWidget::state() const
|
EncryptWidget::state() const
|
||||||
@ -146,7 +149,7 @@ EncryptWidget::updateState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Encryption newState;
|
Encryption newState;
|
||||||
if ( m_ui->m_encryptCheckBox->isChecked() )
|
if ( m_ui->m_encryptCheckBox->isChecked() || !m_ui->m_encryptCheckBox->isVisible())
|
||||||
{
|
{
|
||||||
if ( !m_ui->m_passphraseLineEdit->text().isEmpty()
|
if ( !m_ui->m_passphraseLineEdit->text().isEmpty()
|
||||||
&& m_ui->m_passphraseLineEdit->text() == m_ui->m_confirmLineEdit->text() )
|
&& m_ui->m_passphraseLineEdit->text() == m_ui->m_confirmLineEdit->text() )
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
|
|
||||||
explicit EncryptWidget( QWidget* parent = nullptr );
|
explicit EncryptWidget( QWidget* parent = nullptr );
|
||||||
|
|
||||||
void reset();
|
void reset( bool checkVisible = true );
|
||||||
|
|
||||||
Encryption state() const;
|
Encryption state() const;
|
||||||
void setText( const QString& text );
|
void setText( const QString& text );
|
||||||
|
Loading…
Reference in New Issue
Block a user