From 46e90ccda21f392728d03f3eb635151d24795040 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 11 Jun 2015 04:02:06 +0200 Subject: [PATCH] Add setRootPassword option to the Users module. If set to true, the user must set a root password. Otherwise, the user won't be asked and a root password will not be set. --- src/modules/users/UsersPage.cpp | 26 +++++++++++++++++++++++--- src/modules/users/UsersPage.h | 3 +++ src/modules/users/UsersViewStep.cpp | 8 ++++++++ src/modules/users/page_usersetup.ui | 8 ++++---- src/modules/users/users.conf | 7 ++++--- 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index 784c37458..cb013748c 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -47,6 +47,7 @@ UsersPage::UsersPage( QWidget* parent ) , m_readyHostname( false ) , m_readyPassword( false ) , m_readyRootPassword( false ) + , m_showRootPassword( true ) { ui->setupUi( this ); @@ -69,6 +70,8 @@ UsersPage::UsersPage( QWidget* parent ) m_customUsername = false; m_customHostname = false; + setShowRootPassword( true ); + CALAMARES_RETRANSLATE( ui->retranslateUi( this ); ) } @@ -109,9 +112,12 @@ UsersPage::createJobs( const QString& defaultUserGroup, const QStringList& defau ui->textBoxUserPassword->text() ); list.append( Calamares::job_ptr( j ) ); - j = new SetPasswordJob( "root", - ui->textBoxRootPassword->text() ); - list.append( Calamares::job_ptr( j ) ); + if ( m_showRootPassword ) + { + j = new SetPasswordJob( "root", + ui->textBoxRootPassword->text() ); + list.append( Calamares::job_ptr( j ) ); + } j = new SetHostNameJob( ui->textBoxHostname->text() ); list.append( Calamares::job_ptr( j ) ); @@ -134,6 +140,20 @@ UsersPage::onActivate() } +void +UsersPage::setShowRootPassword( bool show ) +{ + ui->labelChooseRootPassword->setVisible( show ); + ui->labelExtraRootPassword->setVisible( show ); + ui->labelRootPassword->setVisible( show ); + ui->labelRootPasswordError->setVisible( show ); + ui->textBoxRootPassword->setVisible( show ); + ui->textBoxVerifiedRootPassword->setVisible( show ); + + m_showRootPassword = show; +} + + void UsersPage::onFullNameTextEdited( const QString& textRef ) { diff --git a/src/modules/users/UsersPage.h b/src/modules/users/UsersPage.h index 92781e0b8..b339d5026 100644 --- a/src/modules/users/UsersPage.h +++ b/src/modules/users/UsersPage.h @@ -45,6 +45,8 @@ public: void onActivate(); + void setShowRootPassword( bool show ); + protected slots: void onFullNameTextEdited( const QString& ); void fillSuggestions(); @@ -75,6 +77,7 @@ private: bool m_readyPassword; bool m_readyRootPassword; + bool m_showRootPassword; }; #endif // USERSPAGE_H diff --git a/src/modules/users/UsersViewStep.cpp b/src/modules/users/UsersViewStep.cpp index 0f99e02dc..87362b906 100644 --- a/src/modules/users/UsersViewStep.cpp +++ b/src/modules/users/UsersViewStep.cpp @@ -151,5 +151,13 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap ) Calamares::JobQueue::instance()->globalStorage()->insert( "sudoersGroup", configurationMap.value( "sudoersGroup" ).toString() ); } + + if ( configurationMap.contains( "setRootPassword" ) && + configurationMap.value( "setRootPassword" ).type() == QVariant::Bool ) + { + Calamares::JobQueue::instance()->globalStorage()->insert( "setRootPassword", + configurationMap.value( "setRootPassword" ).toBool() ); + m_widget->setShowRootPassword( configurationMap.value( "setRootPassword" ).toBool() ); + } } diff --git a/src/modules/users/page_usersetup.ui b/src/modules/users/page_usersetup.ui index a506256e5..4771e022c 100644 --- a/src/modules/users/page_usersetup.ui +++ b/src/modules/users/page_usersetup.ui @@ -446,7 +446,7 @@ - + Choose a password for the administrator account. @@ -548,7 +548,7 @@ - + font-weight: normal @@ -593,7 +593,7 @@ - Log in automatically + &Log in automatically false @@ -603,7 +603,7 @@ - Require my password to log in + Require &my password to log in true diff --git a/src/modules/users/users.conf b/src/modules/users/users.conf index aab7a4065..ac82211ae 100644 --- a/src/modules/users/users.conf +++ b/src/modules/users/users.conf @@ -1,5 +1,5 @@ --- -userGroup: users +userGroup: users defaultGroups: - lp - video @@ -7,5 +7,6 @@ defaultGroups: - storage - wheel - audio -autologinGroup: autologin -sudoersGroup: wheel +autologinGroup: autologin +sudoersGroup: wheel +setRootPassword: true