[users] Move setRootPassword to Config
- this really controls whether a root password is written during installtion, so rename to writeRootPassword in the code.
This commit is contained in:
parent
45b71c24e7
commit
6a03bcb25e
@ -337,4 +337,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
setSudoersGroup( CalamaresUtils::getString( configurationMap, "sudoersGroup" ) );
|
setSudoersGroup( CalamaresUtils::getString( configurationMap, "sudoersGroup" ) );
|
||||||
|
|
||||||
m_doAutoLogin = CalamaresUtils::getBool( configurationMap, "doAutologin", false );
|
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?
|
/// Should the user be automatically logged-in?
|
||||||
bool doAutoLogin() const { return m_doAutoLogin; }
|
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& forbiddenLoginNames();
|
||||||
static const QStringList& forbiddenHostNames();
|
static const QStringList& forbiddenHostNames();
|
||||||
@ -124,6 +126,7 @@ private:
|
|||||||
QString m_loginName;
|
QString m_loginName;
|
||||||
QString m_hostName;
|
QString m_hostName;
|
||||||
bool m_doAutoLogin = false;
|
bool m_doAutoLogin = false;
|
||||||
|
bool m_writeRootPassword = true;
|
||||||
|
|
||||||
bool m_customLoginName = false;
|
bool m_customLoginName = false;
|
||||||
bool m_customHostName = false;
|
bool m_customHostName = false;
|
||||||
|
@ -105,7 +105,6 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
|||||||
, m_readyHostname( false )
|
, m_readyHostname( false )
|
||||||
, m_readyPassword( false )
|
, m_readyPassword( false )
|
||||||
, m_readyRootPassword( false )
|
, m_readyRootPassword( false )
|
||||||
, m_writeRootPassword( true )
|
|
||||||
{
|
{
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
|
||||||
@ -119,22 +118,19 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
|||||||
onRootPasswordTextChanged( ui->textBoxRootPassword->text() );
|
onRootPasswordTextChanged( ui->textBoxRootPassword->text() );
|
||||||
checkReady( isReady() );
|
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
|
/* 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
|
||||||
* the checkbox -- so when writeRoot is false, checked needs
|
* the checkbox -- so when writeRoot is false, checked needs
|
||||||
* to be true, to hide them all.
|
* to be true, to hide them all.
|
||||||
*/
|
*/
|
||||||
if ( !m_writeRootPassword )
|
const bool visible = m_config->writeRootPassword() ? !checked : false;
|
||||||
{
|
ui->labelChooseRootPassword->setVisible( visible );
|
||||||
checked = true;
|
ui->labelRootPassword->setVisible( visible );
|
||||||
}
|
ui->labelRootPasswordError->setVisible( visible );
|
||||||
ui->labelChooseRootPassword->setVisible( !checked );
|
ui->textBoxRootPassword->setVisible( visible );
|
||||||
ui->labelRootPassword->setVisible( !checked );
|
ui->textBoxVerifiedRootPassword->setVisible( visible );
|
||||||
ui->labelRootPasswordError->setVisible( !checked );
|
|
||||||
ui->textBoxRootPassword->setVisible( !checked );
|
|
||||||
ui->textBoxVerifiedRootPassword->setVisible( !checked );
|
|
||||||
checkReady( isReady() );
|
checkReady( isReady() );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -154,7 +150,7 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
|||||||
} );
|
} );
|
||||||
connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked );
|
connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked );
|
||||||
|
|
||||||
setWriteRootPassword( true );
|
ui->checkBoxReusePassword->setVisible( m_config->writeRootPassword() );
|
||||||
ui->checkBoxReusePassword->setChecked( true );
|
ui->checkBoxReusePassword->setChecked( true );
|
||||||
ui->checkBoxValidatePassword->setChecked( true );
|
ui->checkBoxValidatePassword->setChecked( true );
|
||||||
|
|
||||||
@ -196,18 +192,16 @@ bool
|
|||||||
UsersPage::isReady()
|
UsersPage::isReady()
|
||||||
{
|
{
|
||||||
bool readyFields = m_readyFullName && m_readyHostname && m_readyPassword && m_readyUsername;
|
bool readyFields = m_readyFullName && m_readyHostname && m_readyPassword && m_readyUsername;
|
||||||
if ( !m_writeRootPassword || ui->checkBoxReusePassword->isChecked() )
|
// If we're going to write a root password, we need a valid one (or reuse the user's password)
|
||||||
{
|
readyFields
|
||||||
return readyFields;
|
&= m_config->writeRootPassword() ? ( m_readyRootPassword || ui->checkBoxReusePassword->isChecked() ) : true;
|
||||||
}
|
return readyFields;
|
||||||
|
|
||||||
return readyFields && m_readyRootPassword;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
UsersPage::getRootPassword() const
|
UsersPage::getRootPassword() const
|
||||||
{
|
{
|
||||||
if ( m_writeRootPassword )
|
if ( m_config->writeRootPassword() )
|
||||||
{
|
{
|
||||||
if ( ui->checkBoxReusePassword->isChecked() )
|
if ( ui->checkBoxReusePassword->isChecked() )
|
||||||
{
|
{
|
||||||
@ -248,7 +242,7 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
|
|||||||
defaultGroupsList );
|
defaultGroupsList );
|
||||||
list.append( Calamares::job_ptr( j ) );
|
list.append( Calamares::job_ptr( j ) );
|
||||||
|
|
||||||
if ( m_writeRootPassword )
|
if ( m_config->writeRootPassword() )
|
||||||
{
|
{
|
||||||
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
|
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
|
void
|
||||||
UsersPage::onFullNameTextEdited( const QString& fullName )
|
UsersPage::onFullNameTextEdited( const QString& fullName )
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,6 @@ public:
|
|||||||
|
|
||||||
void onActivate();
|
void onActivate();
|
||||||
|
|
||||||
void setWriteRootPassword( bool show );
|
|
||||||
void setPasswordCheckboxVisible( bool visible );
|
void setPasswordCheckboxVisible( bool visible );
|
||||||
void setValidatePasswordDefault( bool checked );
|
void setValidatePasswordDefault( bool checked );
|
||||||
void setReusePasswordDefault( bool checked );
|
void setReusePasswordDefault( bool checked );
|
||||||
@ -101,8 +100,6 @@ private:
|
|||||||
bool m_readyHostname;
|
bool m_readyHostname;
|
||||||
bool m_readyPassword;
|
bool m_readyPassword;
|
||||||
bool m_readyRootPassword;
|
bool m_readyRootPassword;
|
||||||
|
|
||||||
bool m_writeRootPassword;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // USERSPAGE_H
|
#endif // USERSPAGE_H
|
||||||
|
@ -176,10 +176,6 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
m_defaultGroups = QStringList { "lp", "video", "network", "storage", "wheel", "audio" };
|
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 ) );
|
m_widget->setReusePasswordDefault( getBool( configurationMap, "doReusePassword", false ) );
|
||||||
|
|
||||||
if ( configurationMap.contains( "passwordRequirements" )
|
if ( configurationMap.contains( "passwordRequirements" )
|
||||||
|
Loading…
Reference in New Issue
Block a user