From adb9f37ccac51be7896724b75f148e33ec04f73d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 12 Apr 2021 17:21:33 +0200 Subject: [PATCH 1/4] [locale] Set *locale* GS key when needed The code path for setting the locale / language automatically emits currentLanguageStatusChanged(), but the code that updates GS connects to currentLanguageCodeChaged(). This was altered in the 3.2.28 release cycle. Since then, automcatic locale selection wasn't setting *locale* in GS, so that a click-through kind of locale selection would not set it; then the packages module has no *locale* setting for localization packages. The combination of status and code signals (machine- and human- readable) is ok. Introduce a setter to the language that does the necessary signalling, so that setting the language automatically also DTRT. FIXES #1671 --- src/modules/locale/Config.cpp | 18 +++++++++++++----- src/modules/locale/Config.h | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 1417e5b89..854d65eef 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -259,8 +259,7 @@ Config::setCurrentLocation( const CalamaresUtils::Locale::TimeZoneData* location auto newLocale = automaticLocaleConfiguration(); if ( !m_selectedLocaleConfiguration.explicit_lang ) { - m_selectedLocaleConfiguration.setLanguage( newLocale.language() ); - emit currentLanguageStatusChanged( currentLanguageStatus() ); + setLanguage( newLocale.language() ); } if ( !m_selectedLocaleConfiguration.explicit_lc ) { @@ -302,11 +301,20 @@ Config::localeConfiguration() const void Config::setLanguageExplicitly( const QString& language ) { - m_selectedLocaleConfiguration.setLanguage( language ); m_selectedLocaleConfiguration.explicit_lang = true; + setLanguage( language ); +} - emit currentLanguageStatusChanged( currentLanguageStatus() ); - emit currentLanguageCodeChanged( currentLanguageCode() ); +void +Config::setLanguage( const QString& language ) +{ + if ( language != m_selectedLocaleConfiguration.language() ) + { + m_selectedLocaleConfiguration.setLanguage( language ); + + emit currentLanguageStatusChanged( currentLanguageStatus() ); + emit currentLanguageCodeChanged( currentLanguageCode() ); + } } void diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h index 4383f6bb0..bcdaf0bbf 100644 --- a/src/modules/locale/Config.h +++ b/src/modules/locale/Config.h @@ -95,6 +95,8 @@ private: } public Q_SLOTS: + /// Set the language, but do not mark it as user-choice + void setLanguage( const QString& language ); /// Set a language by user-choice, overriding future location changes void setLanguageExplicitly( const QString& language ); /// Set LC (formats) by user-choice, overriding future location changes From 2b8309eb04f62d9064a10bec78c542ce596b06b4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Apr 2021 16:01:07 +0200 Subject: [PATCH 2/4] [users] Add tests for autologin settings - four possibilities for old and new keys - 6e is the check for not-actually-set, to track defaults --- src/modules/users/Tests.cpp | 40 ++++++++++++++++++++++ src/modules/users/tests/6a-issue-1672.conf | 7 ++++ src/modules/users/tests/6b-issue-1672.conf | 7 ++++ src/modules/users/tests/6c-issue-1672.conf | 7 ++++ src/modules/users/tests/6d-issue-1672.conf | 7 ++++ src/modules/users/tests/6e-issue-1672.conf | 7 ++++ 6 files changed, 75 insertions(+) create mode 100644 src/modules/users/tests/6a-issue-1672.conf create mode 100644 src/modules/users/tests/6b-issue-1672.conf create mode 100644 src/modules/users/tests/6c-issue-1672.conf create mode 100644 src/modules/users/tests/6d-issue-1672.conf create mode 100644 src/modules/users/tests/6e-issue-1672.conf diff --git a/src/modules/users/Tests.cpp b/src/modules/users/Tests.cpp index 4106cd785..acb0c9d6d 100644 --- a/src/modules/users/Tests.cpp +++ b/src/modules/users/Tests.cpp @@ -44,6 +44,9 @@ private Q_SLOTS: void testHostActions(); void testPasswordChecks(); void testUserPassword(); + + void testAutoLogin_data(); + void testAutoLogin(); }; UserTests::UserTests() {} @@ -339,6 +342,43 @@ UserTests::testUserPassword() } } +void +UserTests::testAutoLogin_data() +{ + QTest::addColumn< QString >( "filename" ); + QTest::addColumn< bool >( "autoLoginIsSet" ); + QTest::addColumn< QString >( "autoLoginGroupName" ); + + QTest::newRow( "old, old" ) << "tests/6a-issue-1672.conf" << true << "derp"; + QTest::newRow( "old, new" ) << "tests/6b-issue-1672.conf" << true << "derp"; + QTest::newRow( "new, old" ) << "tests/6c-issue-1672.conf" << true << "derp"; + QTest::newRow( "new, new" ) << "tests/6d-issue-1672.conf" << true << "derp"; + QTest::newRow( "default" ) << "tests/6e-issue-1672.conf" << false << QString(); +} + +void +UserTests::testAutoLogin() +{ + QFETCH( QString, filename ); + QFETCH( bool, autoLoginIsSet ); + QFETCH( QString, autoLoginGroupName ); + + // BUILD_AS_TEST is the source-directory path + QFile fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) ); + QVERIFY( fi.exists() ); + + bool ok = false; + const auto map = CalamaresUtils::loadYaml( fi, &ok ); + QVERIFY( ok ); + QVERIFY( map.count() > 0 ); + + Config c; + c.setConfigurationMap( map ); + + QCOMPARE( c.doAutoLogin(), autoLoginIsSet ); + QCOMPARE( c.autoLoginGroup(), autoLoginGroupName ); +} + QTEST_GUILESS_MAIN( UserTests ) diff --git a/src/modules/users/tests/6a-issue-1672.conf b/src/modules/users/tests/6a-issue-1672.conf new file mode 100644 index 000000000..b8ba24266 --- /dev/null +++ b/src/modules/users/tests/6a-issue-1672.conf @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +--- +autologinGroup: derp +doAutologin: true + diff --git a/src/modules/users/tests/6b-issue-1672.conf b/src/modules/users/tests/6b-issue-1672.conf new file mode 100644 index 000000000..a54e71e01 --- /dev/null +++ b/src/modules/users/tests/6b-issue-1672.conf @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +--- +autologinGroup: derp +doAutoLogin: true + diff --git a/src/modules/users/tests/6c-issue-1672.conf b/src/modules/users/tests/6c-issue-1672.conf new file mode 100644 index 000000000..5d12bd71e --- /dev/null +++ b/src/modules/users/tests/6c-issue-1672.conf @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +--- +autoLoginGroup: derp +doAutologin: true + diff --git a/src/modules/users/tests/6d-issue-1672.conf b/src/modules/users/tests/6d-issue-1672.conf new file mode 100644 index 000000000..80976bf64 --- /dev/null +++ b/src/modules/users/tests/6d-issue-1672.conf @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +--- +autoLoginGroup: derp +doAutoLogin: true + diff --git a/src/modules/users/tests/6e-issue-1672.conf b/src/modules/users/tests/6e-issue-1672.conf new file mode 100644 index 000000000..df299b480 --- /dev/null +++ b/src/modules/users/tests/6e-issue-1672.conf @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +--- +doautologin: true +autologingroup: wheel + From 3f1d12ccd85c3df6734f05a6220dc871040c6836 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Apr 2021 15:08:13 +0200 Subject: [PATCH 3/4] [users] One more capitalization fix for autologin FIXES #1672 --- src/modules/users/Config.cpp | 41 ++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 2954b0381..6560d06ac 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -803,6 +803,29 @@ addPasswordCheck( const QString& key, const QVariant& value, PasswordCheckList& return true; } +/** @brief Returns a value of either key from the map + * + * Takes a function (e.g. getBool, or getString) and two keys, + * returning the value in the map of the one that is there (or @p defaultArg) + */ +template < typename T, typename U > +T +either( T ( *f )( const QVariantMap&, const QString&, U ), + const QVariantMap& configurationMap, + const QString& oldKey, + const QString& newKey, + U defaultArg ) +{ + if ( configurationMap.contains( oldKey ) ) + { + return f( configurationMap, oldKey, defaultArg ); + } + else + { + return f( configurationMap, newKey, defaultArg ); + } +} + void Config::setConfigurationMap( const QVariantMap& configurationMap ) { @@ -814,7 +837,8 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) // Now it might be explicitly set to empty, which is ok setUserShell( shell ); - setAutoLoginGroup( CalamaresUtils::getString( configurationMap, "autoLoginGroup" ) ); + setAutoLoginGroup( either< QString, const QString& >( + CalamaresUtils::getString, configurationMap, "autologinGroup", "autoLoginGroup", QString() ) ); setSudoersGroup( CalamaresUtils::getString( configurationMap, "sudoersGroup" ) ); m_hostNameActions = getHostNameActions( configurationMap ); @@ -823,16 +847,11 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) // Renaming of Autologin -> AutoLogin in 4ffa79d4cf also affected // configuration keys, which was not intended. Accept both. - const auto oldKey = QStringLiteral( "doAutologin" ); - const auto newKey = QStringLiteral( "doAutoLogin" ); - if ( configurationMap.contains( oldKey ) ) - { - m_doAutoLogin = CalamaresUtils::getBool( configurationMap, oldKey, false ); - } - else - { - m_doAutoLogin = CalamaresUtils::getBool( configurationMap, newKey, false ); - } + m_doAutoLogin = either( CalamaresUtils::getBool, + configurationMap, + QStringLiteral( "doAutologin" ), + QStringLiteral( "doAutoLogin" ), + false ); m_writeRootPassword = CalamaresUtils::getBool( configurationMap, "setRootPassword", true ); Calamares::JobQueue::instance()->globalStorage()->insert( "setRootPassword", m_writeRootPassword ); From 5241e25ae8acb57541ba4f92e91fda2ba22efad5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Apr 2021 16:20:46 +0200 Subject: [PATCH 4/4] Changes: pre-release housekeeping --- CHANGES | 9 +++++++++ CMakeLists.txt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index fb9f13d6b..eafa05dc6 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,15 @@ contributors are listed. Note that Calamares does not have a historical changelog -- this log starts with version 3.2.0. The release notes on the website will have to do for older versions. +# 3.2.39.3 (2021-04-14) # + +A minor bugfix tweak release. Since this contains yet **another** +autologin-related fix, and there is nothing large enough to justify +a 3.2.40 release yet, add it to the growing tail of 3.2.39. (Reported +by Joe Kamprad, #1672). Also fixes a regression from 3.2.28 in +localized packages (e.g. *package-LOCALE* did not work). + + # 3.2.39.2 (2021-04-02) # This is **another** hotfix release for issues around autologin .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 92ea86845..db775389c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ # TODO:3.3: Require CMake 3.12 cmake_minimum_required( VERSION 3.3 FATAL_ERROR ) project( CALAMARES - VERSION 3.2.39.2 + VERSION 3.2.39.3 LANGUAGES C CXX )