[users] implement upstream fixes

This commit is contained in:
Philip 2016-12-06 21:56:40 +01:00
parent 846a4a19ae
commit ec44f2e4f4
7 changed files with 85 additions and 78 deletions

View File

@ -8,7 +8,7 @@ The following settings are available in **users.conf**:
- ```defaultGroups```: list of groups every user will be added to. - ```defaultGroups```: list of groups every user will be added to.
- ```autologinGroup```: group to add the user with autologin to, if any. - ```autologinGroup```: group to add the user with autologin to, if any.
- ```doAutologin```: allow for users with autologin (at most one per system). Defaults to false. - ```doAutologin```: if autologin is allowed, set it to "yes" by default. Defaults to false.
- ```sudoersGroup```: group for sudoers usage. - ```sudoersGroup```: group for sudoers usage.
- ```setRootPassword```: allow to set the root password in the installed system. Defaults to false. - ```setRootPassword```: allow to set the root password in the installed system. Defaults to false.
- ```availableShells```: comma-separated list of available shells for new users. If not present, new users will not have any explicit shell in /etc/passwd, therefore the system default (usually, /bin/bash) will be used. - ```availableShells```: comma-separated list of available shells for new users. If not present, new users will not have any explicit shell in /etc/passwd, therefore the system default (usually, /bin/bash) will be used.

View File

@ -31,7 +31,7 @@
#include "AddUserDialog.h" #include "AddUserDialog.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
AddUserDialog::AddUserDialog(const QStringList& existingUsers, bool avatar, bool autologin, const QStringList& shells, bool haveRootPassword, QWidget* parent) AddUserDialog::AddUserDialog(const QStringList& existingUsers, bool avatar, bool allowAutologin, bool checkAutologin, const QStringList& shells, bool haveRootPassword, QWidget* parent)
: QDialog(parent), : QDialog(parent),
m_existingUsers(existingUsers) m_existingUsers(existingUsers)
{ {
@ -80,8 +80,10 @@ AddUserDialog::AddUserDialog(const QStringList& existingUsers, bool avatar, bool
ui.rootUsesUserPwCheckBox->setEnabled(false); ui.rootUsesUserPwCheckBox->setEnabled(false);
} }
if (!autologin) { if (!allowAutologin) {
ui.autoLoginCheckBox->setEnabled(false); ui.autoLoginCheckBox->setEnabled(false);
} else {
ui.autoLoginCheckBox->setChecked(checkAutologin);
} }
if (!avatar) { if (!avatar) {
@ -106,7 +108,7 @@ void AddUserDialog::accept() {
shell = ui.loginShellSelection->currentText(); shell = ui.loginShellSelection->currentText();
fullName = ui.nameLine->text(); fullName = ui.nameLine->text();
autoLogin = ui.autoLoginCheckBox->isEnabled(); autoLogin = ui.autoLoginCheckBox->isChecked();
useUserPw = ui.rootUsesUserPwCheckBox->isChecked(); useUserPw = ui.rootUsesUserPwCheckBox->isChecked();
QDialog::accept(); QDialog::accept();

View File

@ -38,10 +38,11 @@ public:
* - existingUsers: username of the users that were already created. * - existingUsers: username of the users that were already created.
* This avoids us creating a second one with the same name. * This avoids us creating a second one with the same name.
* - avatar: whether we should allow to choose an avatar. * - avatar: whether we should allow to choose an avatar.
* - autologin: whether we should allow the autologin option. * - allowAutologin: whether we should allow the autologin option.
* - checkAutologin: if allowAutologin is true, will it be checked by default or not? Ignored if false.
* - shells: the available login shells for users. * - shells: the available login shells for users.
*/ */
AddUserDialog(const QStringList &existingUsers, bool avatar, bool autologin, const QStringList &shells, bool haveRootPassword, QWidget *parent = 0); AddUserDialog(const QStringList &existingUsers, bool avatar, bool allowAutologin, bool checkAutologin, const QStringList &shells, bool haveRootPassword, QWidget *parent = 0);
virtual ~AddUserDialog(); virtual ~AddUserDialog();
QString login; QString login;

View File

@ -141,6 +141,7 @@ UsersPage::UsersPage( QWidget* parent )
, ui( new Ui::UserCreation ) , ui( new Ui::UserCreation )
, m_readyHostname( false ) , m_readyHostname( false )
, m_readyRootPassword( false ) , m_readyRootPassword( false )
, m_autologin( false )
, m_haveRootPassword( true ) , m_haveRootPassword( true )
{ {
ui->setupUi( this ); ui->setupUi( this );
@ -179,12 +180,11 @@ UsersPage::addUserClicked() {
} }
} }
// Only allow autologin if the module configuration allows it, // Only allow autologin if there exists no other users with autologin enabled.
// and there exists no other users with autologin enabled. bool allowAutologin = !userHasAutologin;
bool allowAutologin = m_autologin && !userHasAutologin;
QPointer<AddUserDialog> dlg = new AddUserDialog( QPointer<AddUserDialog> dlg = new AddUserDialog(
existingUsers, !m_avatarFilePath.isEmpty(), allowAutologin, m_availableShells, m_haveRootPassword, this ); existingUsers, !m_avatarFilePath.isEmpty(), allowAutologin, m_autologin, m_availableShells, m_haveRootPassword, this );
if ( dlg->exec() == QDialog::Accepted ) { if ( dlg->exec() == QDialog::Accepted ) {
addUser(dlg->login, dlg->fullName, dlg->password, dlg->shell, dlg->avatarFile, dlg->autoLogin); addUser(dlg->login, dlg->fullName, dlg->password, dlg->shell, dlg->avatarFile, dlg->autoLogin);

View File

@ -130,9 +130,13 @@ private:
bool m_readyHostname; bool m_readyHostname;
bool m_readyRootPassword; bool m_readyRootPassword;
// Check autologin by default (if no other user is already in autologin mode)?
bool m_autologin; bool m_autologin;
// Allow to set a root password?
bool m_haveRootPassword; bool m_haveRootPassword;
// Path to copy the avatar file to, if the user selects one.
QString m_avatarFilePath; QString m_avatarFilePath;
// List of available shells for new users.
QStringList m_availableShells; QStringList m_availableShells;
}; };

View File

@ -68,6 +68,45 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="4" colspan="2">
<widget class="QLineEdit" name="confirmPassLine">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Confirm Password:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="6" rowspan="4" colspan="2">
<widget class="QLabel" name="confirmPwCheck">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="3" rowspan="4"> <item row="0" column="3" rowspan="4">
<spacer name="horizontalSpacer_7"> <spacer name="horizontalSpacer_7">
<property name="orientation"> <property name="orientation">
@ -84,16 +123,32 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="2"> <item row="0" column="4" rowspan="3" colspan="2">
<widget class="QLabel" name="label_3"> <widget class="QLineEdit" name="passLine">
<property name="text"> <property name="minimumSize">
<string>Confirm Password:</string> <size>
</property> <width>150</width>
<property name="alignment"> <height>0</height>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </size>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" rowspan="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" rowspan="4"> <item row="1" column="0" rowspan="4">
<layout class="QVBoxLayout" name="userNameLayout"> <layout class="QVBoxLayout" name="userNameLayout">
<item> <item>
@ -154,7 +209,7 @@
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>40</width> <width>30</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
@ -174,61 +229,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="4" colspan="2">
<widget class="QLineEdit" name="confirmPassLine">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="4" rowspan="3" colspan="2">
<widget class="QLineEdit" name="passLine">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="6" rowspan="4" colspan="2">
<widget class="QLabel" name="confirmPwCheck">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>694</width> <width>694</width>
<height>474</height> <height>475</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -109,7 +109,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>678</width> <width>678</width>
<height>248</height> <height>249</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -233,13 +233,13 @@
<widget class="QLabel" name="labelHostname"> <widget class="QLabel" name="labelHostname">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>50</width> <width>40</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>50</width> <width>40</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
@ -252,7 +252,7 @@
<widget class="QLabel" name="labelRootPwIcon"> <widget class="QLabel" name="labelRootPwIcon">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>50</width> <width>30</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>