diff --git a/CHANGES b/CHANGES index 5476b42a4..0f6dd7de1 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,8 @@ on functionality, but do touch each and every source file: ## Modules ## - *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) # diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 5ce8c8ed1..d0f573286 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -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_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 >& hostNameActionNames() { @@ -110,15 +134,7 @@ Config::setLoginName( const QString& login ) { if ( login != m_loginName ) { - Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - if ( login.isEmpty() ) - { - gs->remove( "username" ); - } - else - { - gs->insert( "username", login ); - } + updateGSAutoLogin( doAutoLogin(), login ); m_customLoginName = !login.isEmpty(); m_loginName = login; @@ -330,9 +346,9 @@ Config::setFullName( const QString& name ) QString login = makeLoginNameSuggestion( cleanParts ); if ( !login.isEmpty() && login != m_loginName ) { - m_loginName = login; - emit loginNameChanged( login ); - emit loginNameStatusChanged( loginNameStatus() ); + setLoginName( login ); + // It's **still** not custom, though setLoginName() sets that + m_customLoginName = false; } } if ( !m_customHostName ) @@ -340,9 +356,9 @@ Config::setFullName( const QString& name ) QString hostname = makeHostnameSuggestion( cleanParts ); if ( !hostname.isEmpty() && hostname != m_hostName ) { - m_hostName = hostname; - emit hostNameChanged( hostname ); - emit hostNameStatusChanged( hostNameStatus() ); + setHostName( hostname ); + // Still not custom + m_customHostName = false; } } } @@ -353,15 +369,7 @@ Config::setAutoLogin( bool b ) { if ( b != m_doAutoLogin ) { - Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - if ( b ) - { - gs->insert( "autologinUser", loginName() ); - } - else - { - gs->remove( "autologinUser" ); - } + updateGSAutoLogin( b, loginName() ); m_doAutoLogin = b; emit autoLoginChanged( b ); } @@ -700,14 +708,16 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) } std::sort( m_passwordChecks.begin(), m_passwordChecks.end() ); + updateGSAutoLogin( doAutoLogin(), loginName() ); checkReady(); } void Config::finalizeGlobalStorage() const { - Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); + updateGSAutoLogin( doAutoLogin(), loginName() ); + Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); if ( writeRootPassword() ) { gs->insert( "reuseRootPassword", reuseUserPasswordForRoot() ); diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index 8059b02e1..6ea03f8ef 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -84,12 +84,6 @@ UsersPage::UsersPage( Config* config, QWidget* parent ) { 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 ui->textBoxUserPassword->setText( config->userPassword() ); 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::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( 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::loginNameStatusChanged, this, &UsersPage::reportLoginNameStatus ); + ui->checkBoxDoAutoLogin->setChecked( m_config->doAutoLogin() ); connect( ui->checkBoxDoAutoLogin, &QCheckBox::stateChanged, this, [this]( int checked ) { m_config->setAutoLogin( checked != Qt::Unchecked ); } ); connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked ); + ui->checkBoxReusePassword->setVisible( m_config->writeRootPassword() ); + ui->checkBoxReusePassword->setChecked( m_config->reuseUserPasswordForRoot() ); 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( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, &UsersPage::onReuseUserPasswordChanged ); } + ui->checkBoxRequireStrongPassword->setVisible( m_config->permitWeakPasswords() ); + ui->checkBoxRequireStrongPassword->setChecked( m_config->requireStrongPasswords() ); 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 ); } ); - connect( config, &Config::requireStrongPasswordsChanged, ui->checkBoxValidatePassword, &QCheckBox::setChecked ); + connect( + config, &Config::requireStrongPasswordsChanged, ui->checkBoxRequireStrongPassword, &QCheckBox::setChecked ); } CALAMARES_RETRANSLATE_SLOT( &UsersPage::retranslate ) @@ -241,6 +234,8 @@ UsersPage::reportUserPasswordStatus( int validity, const QString& message ) void 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 * entering the root password. However, if we're going to * disable the root password anyway, hide them all regardless of diff --git a/src/modules/users/page_usersetup.ui b/src/modules/users/page_usersetup.ui index e03526a11..ba1c0bc7d 100644 --- a/src/modules/users/page_usersetup.ui +++ b/src/modules/users/page_usersetup.ui @@ -450,7 +450,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - + When this box is checked, password-strength checking is done and you will not be able to use a weak password.