From 70a59d6cd1a77cbf16ddb7862c28b1f7fcb2b620 Mon Sep 17 00:00:00 2001 From: Penvern Vincent Date: Sat, 13 Apr 2024 02:09:09 +0200 Subject: [PATCH 1/4] add possibility to pre check encryption checkox --- src/modules/partition/PartitionViewStep.cpp | 2 ++ src/modules/partition/gui/ChoicePage.cpp | 7 +++++++ src/modules/partition/gui/ChoicePage.h | 1 + src/modules/partition/gui/EncryptWidget.cpp | 5 +++++ src/modules/partition/gui/EncryptWidget.h | 1 + src/modules/partition/partition.conf | 5 +++++ src/modules/partition/partition.schema.yaml | 1 + 7 files changed, 22 insertions(+) diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 119bf1baa..4b170a8ab 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -698,6 +698,8 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) Calamares::getBool( configurationMap, "alwaysShowPartitionLabels", true ) ); gs->insert( "enableLuksAutomatedPartitioning", Calamares::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) ); + gs->insert( "preCheckEncryption", + Calamares::getBool( configurationMap, "preCheckEncryption", false ) ); QString partitionTableName = Calamares::getString( configurationMap, "defaultPartitionTableType" ); if ( partitionTableName.isEmpty() ) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 8a1313237..823525fd3 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -83,12 +83,14 @@ ChoicePage::ChoicePage( Config* config, QWidget* parent ) , m_beforePartitionLabelsView( nullptr ) , m_bootloaderComboBox( nullptr ) , m_enableEncryptionWidget( true ) + , m_preCheckEncryption( false ) { setupUi( this ); auto gs = Calamares::JobQueue::instance()->globalStorage(); m_enableEncryptionWidget = gs->value( "enableLuksAutomatedPartitioning" ).toBool(); + m_preCheckEncryption = gs->value( "preCheckEncryption" ).toBool(); // Set up drives combo m_mainLayout->setDirection( QBoxLayout::TopToBottom ); @@ -468,6 +470,11 @@ ChoicePage::onActionChanged() { m_encryptWidget->setFilesystem( FileSystem::typeForName( m_replaceFsTypesChoiceComboBox->currentText() ) ); } + + if ( m_preCheckEncryption ) + { + m_encryptWidget->setEncryptionCheckbox( m_preCheckEncryption ); + } } Device* currd = selectedDevice(); diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 7deb4dec6..0508cb9cd 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -170,6 +170,7 @@ private: int m_lastSelectedDeviceIndex = -1; bool m_enableEncryptionWidget = false; + bool m_preCheckEncryption = false; QMutex m_coreMutex; }; diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index 176a7c610..3d5f122f2 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -70,6 +70,11 @@ EncryptWidget::EncryptWidget( QWidget* parent ) CALAMARES_RETRANSLATE_SLOT( &EncryptWidget::retranslate ); } +void EncryptWidget::setEncryptionCheckbox( bool preCheckEncrypt) +{ + m_ui->m_encryptCheckBox->setChecked( preCheckEncrypt ); +} + void EncryptWidget::reset( bool checkVisible ) { diff --git a/src/modules/partition/gui/EncryptWidget.h b/src/modules/partition/gui/EncryptWidget.h index 9669b4d21..8833f61ad 100644 --- a/src/modules/partition/gui/EncryptWidget.h +++ b/src/modules/partition/gui/EncryptWidget.h @@ -36,6 +36,7 @@ public: explicit EncryptWidget( QWidget* parent = nullptr ); + void setEncryptionCheckbox( bool preCheckEncrypt = false); void reset( bool checkVisible = true ); Encryption state() const; diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index 0975179de..3d335432f 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -240,6 +240,11 @@ defaultFileSystemType: "ext4" # If nothing is specified, LUKS is enabled in automated modes. #enableLuksAutomatedPartitioning: true +# When enableLuksAutomatedPartitioning is true, this option will pre-check +# encryption checkbox. This option is only usefull to help people to not forget +# to cypher their disk when installing in enterprise (for exemple). +#preCheckEncryption: false + # Partition layout. # # This optional setting specifies a custom partition layout. diff --git a/src/modules/partition/partition.schema.yaml b/src/modules/partition/partition.schema.yaml index 769c1abae..65bc723f5 100644 --- a/src/modules/partition/partition.schema.yaml +++ b/src/modules/partition/partition.schema.yaml @@ -34,6 +34,7 @@ properties: luksGeneration: { type: string, enum: [luks1, luks2] } # Also allows "luks" as alias of "luks1" enableLuksAutomatedPartitioning: { type: boolean, default: false } + preCheckEncryption: { type: boolean, default: false } allowManualPartitioning: { type: boolean, default: true } showNotEncryptedBootMessage: { type: boolean, default: true } From cc835cee6f6272ef8692e88f3008f36fffe01800 Mon Sep 17 00:00:00 2001 From: Penvern Vincent Date: Mon, 15 Apr 2024 16:34:35 +0200 Subject: [PATCH 2/4] do not use Global Storage for variable PreCheckEncryption, other modules don't have to know if this variable is set to true or false --- src/modules/partition/Config.cpp | 1 + src/modules/partition/Config.h | 10 +++++++++- src/modules/partition/PartitionViewStep.cpp | 2 -- src/modules/partition/gui/ChoicePage.cpp | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index 2010fecdd..f4e404c28 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -444,6 +444,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) m_allowZfsEncryption = Calamares::getBool( configurationMap, "allowZfsEncryption", true ); m_allowManualPartitioning = Calamares::getBool( configurationMap, "allowManualPartitioning", true ); + m_preCheckEncryption = Calamares::getBool( configurationMap, "preCheckEncryption", false ); m_showNotEncryptedBootMessage = Calamares::getBool( configurationMap, "showNotEncryptedBootMessage", true ); m_requiredPartitionTableType = Calamares::getStringList( configurationMap, "requiredPartitionTableType" ); diff --git a/src/modules/partition/Config.h b/src/modules/partition/Config.h index d8d68c6d2..199ddaf88 100644 --- a/src/modules/partition/Config.h +++ b/src/modules/partition/Config.h @@ -35,7 +35,7 @@ class Config : public QObject replaceModeFilesystemChanged ) Q_PROPERTY( bool allowManualPartitioning READ allowManualPartitioning CONSTANT FINAL ) - + Q_PROPERTY( bool preCheckEncryption READ preCheckEncryption CONSTANT FINAL ) Q_PROPERTY( bool showNotEncryptedBootMessage READ showNotEncryptedBootMessage CONSTANT FINAL ) public: @@ -148,6 +148,13 @@ public: /// @brief Is manual partitioning allowed (not explicitly disabled in the config file)? bool allowManualPartitioning() const { return m_allowManualPartitioning; } + /** @brief pre check encryption checkbox. + * + * parameter is used if enableLuksAutomatedPartitioning is true. + * Default value is false + */ + bool preCheckEncryption() const { return m_preCheckEncryption; } + /// @brief Show "Boot partition not encrypted" warning (not explicitly disabled in the config file)? bool showNotEncryptedBootMessage() const { return m_showNotEncryptedBootMessage; } @@ -199,6 +206,7 @@ private: QStringList m_requiredPartitionTableType; bool m_allowZfsEncryption = true; bool m_allowManualPartitioning = true; + bool m_preCheckEncryption = false; bool m_showNotEncryptedBootMessage = true; }; diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 4b170a8ab..119bf1baa 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -698,8 +698,6 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) Calamares::getBool( configurationMap, "alwaysShowPartitionLabels", true ) ); gs->insert( "enableLuksAutomatedPartitioning", Calamares::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) ); - gs->insert( "preCheckEncryption", - Calamares::getBool( configurationMap, "preCheckEncryption", false ) ); QString partitionTableName = Calamares::getString( configurationMap, "defaultPartitionTableType" ); if ( partitionTableName.isEmpty() ) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 823525fd3..ccb59e5cb 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -90,7 +90,7 @@ ChoicePage::ChoicePage( Config* config, QWidget* parent ) auto gs = Calamares::JobQueue::instance()->globalStorage(); m_enableEncryptionWidget = gs->value( "enableLuksAutomatedPartitioning" ).toBool(); - m_preCheckEncryption = gs->value( "preCheckEncryption" ).toBool(); + m_preCheckEncryption = m_config->preCheckEncryption(); // Set up drives combo m_mainLayout->setDirection( QBoxLayout::TopToBottom ); From 5ac23cd3d60f956fd5525b66c738e0178e07d491 Mon Sep 17 00:00:00 2001 From: Penvern Vincent Date: Mon, 15 Apr 2024 22:44:42 +0200 Subject: [PATCH 3/4] Remove m_preCheckEncryption variable from ChoicePage --- src/modules/partition/gui/ChoicePage.cpp | 6 ++---- src/modules/partition/gui/ChoicePage.h | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index ccb59e5cb..b2396ebc0 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -83,14 +83,12 @@ ChoicePage::ChoicePage( Config* config, QWidget* parent ) , m_beforePartitionLabelsView( nullptr ) , m_bootloaderComboBox( nullptr ) , m_enableEncryptionWidget( true ) - , m_preCheckEncryption( false ) { setupUi( this ); auto gs = Calamares::JobQueue::instance()->globalStorage(); m_enableEncryptionWidget = gs->value( "enableLuksAutomatedPartitioning" ).toBool(); - m_preCheckEncryption = m_config->preCheckEncryption(); // Set up drives combo m_mainLayout->setDirection( QBoxLayout::TopToBottom ); @@ -471,9 +469,9 @@ ChoicePage::onActionChanged() m_encryptWidget->setFilesystem( FileSystem::typeForName( m_replaceFsTypesChoiceComboBox->currentText() ) ); } - if ( m_preCheckEncryption ) + if ( m_config->preCheckEncryption() ) { - m_encryptWidget->setEncryptionCheckbox( m_preCheckEncryption ); + m_encryptWidget->setEncryptionCheckbox( m_config->preCheckEncryption() ); } } diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 0508cb9cd..7deb4dec6 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -170,7 +170,6 @@ private: int m_lastSelectedDeviceIndex = -1; bool m_enableEncryptionWidget = false; - bool m_preCheckEncryption = false; QMutex m_coreMutex; }; From 8469fbd2e82c8008ed333007658f16cd2e4e3271 Mon Sep 17 00:00:00 2001 From: Penvern Vincent Date: Tue, 16 Apr 2024 18:08:11 +0200 Subject: [PATCH 4/4] Fix Next button behviour for all combinations of enableLuksAutomatedPartitioning and preCheckEncryption configure file variables --- src/modules/partition/gui/ChoicePage.cpp | 12 +++++------- src/modules/partition/gui/EncryptWidget.cpp | 16 ++++++++-------- src/modules/partition/gui/EncryptWidget.h | 1 + 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index b2396ebc0..3824f4c54 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -185,7 +185,6 @@ ChoicePage::init( PartitionCoreModule* core ) setModelToComboBox( m_drivesCombo, core->deviceModel() ); connect( m_drivesCombo, qOverload< int >( &QComboBox::currentIndexChanged ), this, &ChoicePage::applyDeviceChoice ); - connect( m_encryptWidget, &EncryptWidget::stateChanged, this, &ChoicePage::onEncryptWidgetStateChanged ); connect( m_reuseHomeCheckBox, &QCheckBox::stateChanged, this, &ChoicePage::onHomeCheckBoxStateChanged ); @@ -468,11 +467,8 @@ ChoicePage::onActionChanged() { m_encryptWidget->setFilesystem( FileSystem::typeForName( m_replaceFsTypesChoiceComboBox->currentText() ) ); } - - if ( m_config->preCheckEncryption() ) - { - m_encryptWidget->setEncryptionCheckbox( m_config->preCheckEncryption() ); - } + + m_encryptWidget->setEncryptionCheckbox( m_config->preCheckEncryption() ); } Device* currd = selectedDevice(); @@ -1580,7 +1576,9 @@ ChoicePage::calculateNextEnabled() const } } - if ( m_config->installChoice() != InstallChoice::Manual && m_encryptWidget->isVisible() ) + if ( m_config->installChoice() != InstallChoice::Manual + && (m_encryptWidget->isVisible() || + m_encryptWidget->isEncryptionCheckboxChecked())) { switch ( m_encryptWidget->state() ) { diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index 3d5f122f2..562166a6b 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -70,6 +70,11 @@ EncryptWidget::EncryptWidget( QWidget* parent ) CALAMARES_RETRANSLATE_SLOT( &EncryptWidget::retranslate ); } +bool EncryptWidget::isEncryptionCheckboxChecked() +{ + return m_ui->m_encryptCheckBox->isChecked(); +} + void EncryptWidget::setEncryptionCheckbox( bool preCheckEncrypt) { m_ui->m_encryptCheckBox->setChecked( preCheckEncrypt ); @@ -174,15 +179,10 @@ EncryptWidget::updateState( const bool notify ) } } - Encryption newState = state(); - - if ( newState != m_state ) + m_state = state(); + if ( notify ) { - m_state = newState; - if ( notify ) - { - Q_EMIT stateChanged( m_state ); - } + Q_EMIT stateChanged( m_state ); } } diff --git a/src/modules/partition/gui/EncryptWidget.h b/src/modules/partition/gui/EncryptWidget.h index 8833f61ad..c7cc23daa 100644 --- a/src/modules/partition/gui/EncryptWidget.h +++ b/src/modules/partition/gui/EncryptWidget.h @@ -39,6 +39,7 @@ public: void setEncryptionCheckbox( bool preCheckEncrypt = false); void reset( bool checkVisible = true ); + bool isEncryptionCheckboxChecked(); Encryption state() const; void setText( const QString& text );