Merge branch 'issue-1498' into calamares

FIXES #1498
This commit is contained in:
Adriaan de Groot 2020-08-28 23:50:23 +02:00
commit 4726f04b16
4 changed files with 48 additions and 41 deletions

View File

@ -35,6 +35,8 @@ on functionality, but do touch each and every source file:
## Modules ## ## Modules ##
- *keyboardq* and *localeq* improvements. (Thanks to Anke) - *keyboardq* and *localeq* improvements. (Thanks to Anke)
- *users* module did not set up autologin properly. This is yet another
regression left over from 3.2.28. (Reported by Phil and pcrepix, #1498)
# 3.2.29 (2020-08-20) # # 3.2.29 (2020-08-20) #

View File

@ -30,6 +30,30 @@ static const QRegExp HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" );
static constexpr const int HOSTNAME_MIN_LENGTH = 2; static constexpr const int HOSTNAME_MIN_LENGTH = 2;
static constexpr const int HOSTNAME_MAX_LENGTH = 63; static constexpr const int HOSTNAME_MAX_LENGTH = 63;
static void
updateGSAutoLogin( bool doAutoLogin, const QString& login )
{
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
if ( doAutoLogin && !login.isEmpty() )
{
gs->insert( "autologinUser", login );
}
else
{
gs->remove( "autologinUser" );
}
if ( login.isEmpty() )
{
gs->remove( "username" );
}
else
{
gs->insert( "username", login );
}
}
const NamedEnumTable< HostNameAction >& const NamedEnumTable< HostNameAction >&
hostNameActionNames() hostNameActionNames()
{ {
@ -110,15 +134,7 @@ Config::setLoginName( const QString& login )
{ {
if ( login != m_loginName ) if ( login != m_loginName )
{ {
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); updateGSAutoLogin( doAutoLogin(), login );
if ( login.isEmpty() )
{
gs->remove( "username" );
}
else
{
gs->insert( "username", login );
}
m_customLoginName = !login.isEmpty(); m_customLoginName = !login.isEmpty();
m_loginName = login; m_loginName = login;
@ -330,9 +346,9 @@ Config::setFullName( const QString& name )
QString login = makeLoginNameSuggestion( cleanParts ); QString login = makeLoginNameSuggestion( cleanParts );
if ( !login.isEmpty() && login != m_loginName ) if ( !login.isEmpty() && login != m_loginName )
{ {
m_loginName = login; setLoginName( login );
emit loginNameChanged( login ); // It's **still** not custom, though setLoginName() sets that
emit loginNameStatusChanged( loginNameStatus() ); m_customLoginName = false;
} }
} }
if ( !m_customHostName ) if ( !m_customHostName )
@ -340,9 +356,9 @@ Config::setFullName( const QString& name )
QString hostname = makeHostnameSuggestion( cleanParts ); QString hostname = makeHostnameSuggestion( cleanParts );
if ( !hostname.isEmpty() && hostname != m_hostName ) if ( !hostname.isEmpty() && hostname != m_hostName )
{ {
m_hostName = hostname; setHostName( hostname );
emit hostNameChanged( hostname ); // Still not custom
emit hostNameStatusChanged( hostNameStatus() ); m_customHostName = false;
} }
} }
} }
@ -353,15 +369,7 @@ Config::setAutoLogin( bool b )
{ {
if ( b != m_doAutoLogin ) if ( b != m_doAutoLogin )
{ {
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); updateGSAutoLogin( b, loginName() );
if ( b )
{
gs->insert( "autologinUser", loginName() );
}
else
{
gs->remove( "autologinUser" );
}
m_doAutoLogin = b; m_doAutoLogin = b;
emit autoLoginChanged( b ); emit autoLoginChanged( b );
} }
@ -700,14 +708,16 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
} }
std::sort( m_passwordChecks.begin(), m_passwordChecks.end() ); std::sort( m_passwordChecks.begin(), m_passwordChecks.end() );
updateGSAutoLogin( doAutoLogin(), loginName() );
checkReady(); checkReady();
} }
void void
Config::finalizeGlobalStorage() const Config::finalizeGlobalStorage() const
{ {
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); updateGSAutoLogin( doAutoLogin(), loginName() );
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
if ( writeRootPassword() ) if ( writeRootPassword() )
{ {
gs->insert( "reuseRootPassword", reuseUserPasswordForRoot() ); gs->insert( "reuseRootPassword", reuseUserPasswordForRoot() );

View File

@ -84,12 +84,6 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
{ {
ui->setupUi( this ); ui->setupUi( this );
ui->checkBoxReusePassword->setVisible( m_config->writeRootPassword() );
ui->checkBoxReusePassword->setChecked( m_config->reuseUserPasswordForRoot() );
ui->checkBoxValidatePassword->setVisible( m_config->permitWeakPasswords() );
ui->checkBoxValidatePassword->setChecked( m_config->requireStrongPasswords() );
// Connect signals and slots // Connect signals and slots
ui->textBoxUserPassword->setText( config->userPassword() ); ui->textBoxUserPassword->setText( config->userPassword() );
connect( ui->textBoxUserPassword, &QLineEdit::textChanged, config, &Config::setUserPassword ); connect( ui->textBoxUserPassword, &QLineEdit::textChanged, config, &Config::setUserPassword );
@ -107,10 +101,6 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
connect( config, &Config::rootPasswordSecondaryChanged, ui->textBoxVerifiedRootPassword, &QLineEdit::setText ); connect( config, &Config::rootPasswordSecondaryChanged, ui->textBoxVerifiedRootPassword, &QLineEdit::setText );
connect( config, &Config::rootPasswordStatusChanged, this, &UsersPage::reportRootPasswordStatus ); connect( config, &Config::rootPasswordStatusChanged, this, &UsersPage::reportRootPasswordStatus );
connect( ui->checkBoxValidatePassword, &QCheckBox::stateChanged, this, [this]( int checked ) {
m_config->setRequireStrongPasswords( checked != Qt::Unchecked );
} );
connect( ui->textBoxFullName, &QLineEdit::textEdited, config, &Config::setFullName ); connect( ui->textBoxFullName, &QLineEdit::textEdited, config, &Config::setFullName );
connect( config, &Config::fullNameChanged, this, &UsersPage::onFullNameTextEdited ); connect( config, &Config::fullNameChanged, this, &UsersPage::onFullNameTextEdited );
@ -122,26 +112,29 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
connect( config, &Config::loginNameChanged, ui->textBoxLoginName, &QLineEdit::setText ); connect( config, &Config::loginNameChanged, ui->textBoxLoginName, &QLineEdit::setText );
connect( config, &Config::loginNameStatusChanged, this, &UsersPage::reportLoginNameStatus ); connect( config, &Config::loginNameStatusChanged, this, &UsersPage::reportLoginNameStatus );
ui->checkBoxDoAutoLogin->setChecked( m_config->doAutoLogin() );
connect( ui->checkBoxDoAutoLogin, &QCheckBox::stateChanged, this, [this]( int checked ) { connect( ui->checkBoxDoAutoLogin, &QCheckBox::stateChanged, this, [this]( int checked ) {
m_config->setAutoLogin( checked != Qt::Unchecked ); m_config->setAutoLogin( checked != Qt::Unchecked );
} ); } );
connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked ); connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked );
ui->checkBoxReusePassword->setVisible( m_config->writeRootPassword() );
ui->checkBoxReusePassword->setChecked( m_config->reuseUserPasswordForRoot() );
if ( m_config->writeRootPassword() ) if ( m_config->writeRootPassword() )
{ {
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, [this]( int checked ) {
m_config->setReuseUserPasswordForRoot( checked != Qt::Unchecked );
} );
connect( config, &Config::reuseUserPasswordForRootChanged, ui->checkBoxReusePassword, &QCheckBox::setChecked ); connect( config, &Config::reuseUserPasswordForRootChanged, ui->checkBoxReusePassword, &QCheckBox::setChecked );
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, &UsersPage::onReuseUserPasswordChanged ); connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, &UsersPage::onReuseUserPasswordChanged );
} }
ui->checkBoxRequireStrongPassword->setVisible( m_config->permitWeakPasswords() );
ui->checkBoxRequireStrongPassword->setChecked( m_config->requireStrongPasswords() );
if ( m_config->permitWeakPasswords() ) if ( m_config->permitWeakPasswords() )
{ {
connect( ui->checkBoxValidatePassword, &QCheckBox::stateChanged, this, [this]( int checked ) { connect( ui->checkBoxRequireStrongPassword, &QCheckBox::stateChanged, this, [this]( int checked ) {
m_config->setRequireStrongPasswords( checked != Qt::Unchecked ); m_config->setRequireStrongPasswords( checked != Qt::Unchecked );
} ); } );
connect( config, &Config::requireStrongPasswordsChanged, ui->checkBoxValidatePassword, &QCheckBox::setChecked ); connect(
config, &Config::requireStrongPasswordsChanged, ui->checkBoxRequireStrongPassword, &QCheckBox::setChecked );
} }
CALAMARES_RETRANSLATE_SLOT( &UsersPage::retranslate ) CALAMARES_RETRANSLATE_SLOT( &UsersPage::retranslate )
@ -241,6 +234,8 @@ UsersPage::reportUserPasswordStatus( int validity, const QString& message )
void void
UsersPage::onReuseUserPasswordChanged( const int checked ) UsersPage::onReuseUserPasswordChanged( const int checked )
{ {
// Pass the change on to config
m_config->setReuseUserPasswordForRoot( checked != Qt::Unchecked );
/* When "reuse" is checked, hide the fields for explicitly /* When "reuse" is checked, hide the fields for explicitly
* entering the root password. However, if we're going to * entering the root password. However, if we're going to
* disable the root password anyway, hide them all regardless of * disable the root password anyway, hide them all regardless of

View File

@ -450,7 +450,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxValidatePassword"> <widget class="QCheckBox" name="checkBoxRequireStrongPassword">
<property name="toolTip"> <property name="toolTip">
<string>When this box is checked, password-strength checking is done and you will not be able to use a weak password.</string> <string>When this box is checked, password-strength checking is done and you will not be able to use a weak password.</string>
</property> </property>