[users] Move setRootPassword to Config

- this really controls whether a root password is written during installtion,
  so rename to writeRootPassword in the code.
main
Adriaan de Groot 5 years ago
parent 45b71c24e7
commit 6a03bcb25e

@ -337,4 +337,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
setSudoersGroup( CalamaresUtils::getString( configurationMap, "sudoersGroup" ) );
m_doAutoLogin = CalamaresUtils::getBool( configurationMap, "doAutologin", false );
m_writeRootPassword = CalamaresUtils::getBool( configurationMap, "setRootPassword", true );
Calamares::JobQueue::instance()->globalStorage()->insert( "setRootPassword", m_writeRootPassword );
}

@ -74,6 +74,8 @@ public:
/// Should the user be automatically logged-in?
bool doAutoLogin() const { return m_doAutoLogin; }
/// Should the root password be written (if false, no password is set and the root account is disabled for login)
bool writeRootPassword() const { return m_writeRootPassword; }
static const QStringList& forbiddenLoginNames();
static const QStringList& forbiddenHostNames();
@ -124,6 +126,7 @@ private:
QString m_loginName;
QString m_hostName;
bool m_doAutoLogin = false;
bool m_writeRootPassword = true;
bool m_customLoginName = false;
bool m_customHostName = false;

@ -105,7 +105,6 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
, m_readyHostname( false )
, m_readyPassword( false )
, m_readyRootPassword( false )
, m_writeRootPassword( true )
{
ui->setupUi( this );
@ -119,22 +118,19 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
onRootPasswordTextChanged( ui->textBoxRootPassword->text() );
checkReady( isReady() );
} );
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, [this]( int checked ) {
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, [this]( const int checked ) {
/* 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
* the checkbox -- so when writeRoot is false, checked needs
* to be true, to hide them all.
*/
if ( !m_writeRootPassword )
{
checked = true;
}
ui->labelChooseRootPassword->setVisible( !checked );
ui->labelRootPassword->setVisible( !checked );
ui->labelRootPasswordError->setVisible( !checked );
ui->textBoxRootPassword->setVisible( !checked );
ui->textBoxVerifiedRootPassword->setVisible( !checked );
const bool visible = m_config->writeRootPassword() ? !checked : false;
ui->labelChooseRootPassword->setVisible( visible );
ui->labelRootPassword->setVisible( visible );
ui->labelRootPasswordError->setVisible( visible );
ui->textBoxRootPassword->setVisible( visible );
ui->textBoxVerifiedRootPassword->setVisible( visible );
checkReady( isReady() );
} );
@ -154,7 +150,7 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
} );
connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked );
setWriteRootPassword( true );
ui->checkBoxReusePassword->setVisible( m_config->writeRootPassword() );
ui->checkBoxReusePassword->setChecked( true );
ui->checkBoxValidatePassword->setChecked( true );
@ -196,18 +192,16 @@ bool
UsersPage::isReady()
{
bool readyFields = m_readyFullName && m_readyHostname && m_readyPassword && m_readyUsername;
if ( !m_writeRootPassword || ui->checkBoxReusePassword->isChecked() )
{
return readyFields;
}
return readyFields && m_readyRootPassword;
// If we're going to write a root password, we need a valid one (or reuse the user's password)
readyFields
&= m_config->writeRootPassword() ? ( m_readyRootPassword || ui->checkBoxReusePassword->isChecked() ) : true;
return readyFields;
}
QString
UsersPage::getRootPassword() const
{
if ( m_writeRootPassword )
if ( m_config->writeRootPassword() )
{
if ( ui->checkBoxReusePassword->isChecked() )
{
@ -248,7 +242,7 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
defaultGroupsList );
list.append( Calamares::job_ptr( j ) );
if ( m_writeRootPassword )
if ( m_config->writeRootPassword() )
{
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
}
@ -274,14 +268,6 @@ UsersPage::onActivate()
}
void
UsersPage::setWriteRootPassword( bool write )
{
m_writeRootPassword = write;
ui->checkBoxReusePassword->setVisible( write );
}
void
UsersPage::onFullNameTextEdited( const QString& fullName )
{

@ -51,7 +51,6 @@ public:
void onActivate();
void setWriteRootPassword( bool show );
void setPasswordCheckboxVisible( bool visible );
void setValidatePasswordDefault( bool checked );
void setReusePasswordDefault( bool checked );
@ -101,8 +100,6 @@ private:
bool m_readyHostname;
bool m_readyPassword;
bool m_readyRootPassword;
bool m_writeRootPassword;
};
#endif // USERSPAGE_H

@ -176,10 +176,6 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
m_defaultGroups = QStringList { "lp", "video", "network", "storage", "wheel", "audio" };
}
bool setRootPassword = getBool( configurationMap, "setRootPassword", true );
Calamares::JobQueue::instance()->globalStorage()->insert( "setRootPassword", setRootPassword );
m_widget->setWriteRootPassword( setRootPassword );
m_widget->setReusePasswordDefault( getBool( configurationMap, "doReusePassword", false ) );
if ( configurationMap.contains( "passwordRequirements" )

Loading…
Cancel
Save