Compare commits

..

4 Commits

Author SHA1 Message Date
Adriaan de Groot
5241e25ae8 Changes: pre-release housekeeping 2021-04-14 13:05:11 +02:00
Adriaan de Groot
3f1d12ccd8 [users] One more capitalization fix for autologin
FIXES #1672
2021-04-13 16:12:22 +02:00
Adriaan de Groot
2b8309eb04 [users] Add tests for autologin settings
- four possibilities for old and new keys
- 6e is the check for not-actually-set, to track defaults
2021-04-13 16:11:57 +02:00
Adriaan de Groot
adb9f37cca [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
2021-04-13 14:03:31 +02:00
11 changed files with 130 additions and 17 deletions

View File

@@ -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 ..

View File

@@ -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
)

View File

@@ -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

View File

@@ -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

View File

@@ -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 );

View File

@@ -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 )

View File

@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
autologinGroup: derp
doAutologin: true

View File

@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
autologinGroup: derp
doAutoLogin: true

View File

@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
autoLoginGroup: derp
doAutologin: true

View File

@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
autoLoginGroup: derp
doAutoLogin: true

View File

@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
doautologin: true
autologingroup: wheel