[PC-BSD Commits] r5142 - pcbsd/trunk/SysInstaller
svn at pcbsd.org
svn at pcbsd.org
Wed Nov 25 08:13:48 PST 2009
Author: kris
Date: 2009-11-25 08:13:48 -0800 (Wed, 25 Nov 2009)
New Revision: 5142
Modified:
pcbsd/trunk/SysInstaller/sys-userwidget.cpp
pcbsd/trunk/SysInstaller/sysinstaller.cpp
pcbsd/trunk/SysInstaller/sysinstaller.h
pcbsd/trunk/SysInstaller/sysinstaller.ui
Log:
Finished up the user management section of SysInstaller, we can add, remove, and modify users, plus set root
password again
Modified: pcbsd/trunk/SysInstaller/sys-userwidget.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sys-userwidget.cpp 2009-11-25 14:31:26 UTC (rev 5141)
+++ pcbsd/trunk/SysInstaller/sys-userwidget.cpp 2009-11-25 16:13:48 UTC (rev 5142)
@@ -9,49 +9,242 @@
connect( linePassword2, SIGNAL(lostFocus()), this, SLOT(slotRootPasswordLineEditLostFocus()));
// Connect the username fields to the enable / disable function for the pushbuttons
- connect( lineUserName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotCheckUserLinesChanged(const QString & ) ) );
- connect( lineFullName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotCheckUserLinesChanged(const QString & ) ) );
- connect( lineUserPassword, SIGNAL( textChanged(const QString &) ), this, SLOT(slotCheckUserLinesChanged(const QString & ) ) );
- connect( lineUserPassword2, SIGNAL( textChanged(const QString &) ), this, SLOT(slotCheckUserLinesChanged(const QString & ) ) );
+ connect( lineUserName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotCheckUserLinesChanged() ) );
+ connect( lineFullName, SIGNAL( textChanged(const QString &) ), this, SLOT(slotCheckUserLinesChanged() ) );
+ connect( lineUserPassword, SIGNAL( textChanged(const QString &) ), this, SLOT(slotCheckUserLinesChanged() ) );
+ connect( lineUserPassword2, SIGNAL( textChanged(const QString &) ), this, SLOT(slotCheckUserLinesChanged() ) );
connect( lineUserPassword2, SIGNAL(lostFocus()), this, SLOT(slotUserPasswordLineEditLostFocus()));
- //connect( listWidgetUsers, SIGNAL( selectionChanged () ), this, SLOT(slotListWidgetUsersChanged() ) );
+ connect( listWidgetUsers, SIGNAL( clicked(const QModelIndex &) ), this, SLOT(slotListWidgetUsersChanged() ) );
// Connect the buttons for user management
connect( pushAddUser, SIGNAL( clicked() ), this, SLOT( slotAddUserButton() ) );
connect( pushRemoveUser, SIGNAL( clicked() ), this, SLOT( slotRemoveUserButton() ) );
connect( pushApplyUser, SIGNAL( clicked() ), this, SLOT( slotApplyUserButton() ) );
+ // Populate our shell selection
+ comboShell->clear();
+ comboShell->addItem("/bin/csh");
+ comboShell->addItem("/bin/tcsh");
+ comboShell->addItem("/bin/sh");
+ comboShell->addItem("/usr/local/bin/bash");
+
+ //Setup any regular expressions we will need
+ passwordRegExp.setPattern("([a-z]*[A-Z]*[0-9]*[!\"\xef\xbf\xbd$%^&*()_+=\xef\xbf\xbd#'`@~:?<>|{}\\-.]*)+");
}
void SysInstaller::slotPasswordTextChanged()
{
+ slotCheckUserLinesChanged();
}
void SysInstaller::slotRootPasswordLineEditLostFocus()
{
+ slotCheckUserLinesChanged();
}
-void SysInstaller::slotCheckUserLinesChanged(const QString & )
+void SysInstaller::slotCheckUserLinesChanged()
{
+ bool ok = TRUE;
+ textAcctNotify->setText("");
+
+ // Check if we are missing some values
+ if ( lineUserName->text().isEmpty() ) {
+ textAcctNotify->setText("");
+ ok = FALSE;
+ }
+ if ( lineFullName->text().isEmpty() ) {
+ textAcctNotify->setText("");
+ ok = FALSE;
+ }
+ if ( lineUserPassword->text().isEmpty() ) {
+ textAcctNotify->setText("");
+ ok = FALSE;
+ }
+
+ //Check if passwords match
+ if (linePassword->text() != linePassword2->text() \
+ && ! linePassword->text().isEmpty() && ! linePassword2->text().isEmpty() )
+ textAcctNotify->setText(tr("Root passwords do not match!"));
+
+
+ //Check if passwords match
+ if (lineUserPassword->text() != lineUserPassword2->text() \
+ && ! lineUserPassword->text().isEmpty() && ! lineUserPassword2->text().isEmpty() )
+ textAcctNotify->setText(tr("Error: User passwords do not match!"));
+
+ //Check username contains only letters and numbers
+ if ((! passwordRegExp.exactMatch(lineUserName->text())) && (lineUserName->text() != "")) {
+ textAcctNotify->setText(tr("Username may contain only letters and numbers!"));
+ ok = FALSE;
+ }
+
+ if ( (lineUserPassword->text() != lineUserPassword2->text()) || lineUserPassword->text().isEmpty())
+ ok = FALSE;
+
+ QString Username = lineUserName->text();
+
+ if ( Username == "root" \
+ || Username == "toor" \
+ || Username == "daemon" \
+ || Username == "operator" \
+ || Username == "bin" \
+ || Username == "tty" \
+ || Username == "kmenu" \
+ || Username == "games" \
+ || Username == "news" \
+ || Username == "man" \
+ || Username == "sshd" \
+ || Username == "smmsp" \
+ || Username == "mailnull" \
+ || Username == "bind" \
+ || Username == "proxy" \
+ || Username == "_pflog" \
+ || Username == "_dhcp" \
+ || Username == "pop" \
+ || Username == "www" \
+ || Username == "nobody" \
+ || Username == "cyrus" \
+ || Username == "cups")
+ {
+ ok = FALSE;
+ textAcctNotify->setText( tr("Error: The username") + " " + Username + " " + tr("is reserved."));
+ }
+
+
+ bool ok2;
+ ok2 = true;
+ for ( int i = 0; i < listUsers.count(); ++i)
+ {
+ if(listUsers.at(i).at(0) == lineUserName->text() ) {
+ ok2 = FALSE;
+ break;
+ }
+ }
+
+ if ( ok) {
+ if (ok2)
+ {
+ pushAddUser->setEnabled(TRUE);
+ pushApplyUser->setEnabled(FALSE);
+ } else {
+ pushAddUser->setEnabled(FALSE);
+ pushApplyUser->setEnabled(TRUE);
+ }
+ } else {
+ pushApplyUser->setEnabled(FALSE);
+ pushAddUser->setEnabled(FALSE);
+ }
+
}
void SysInstaller::slotUserPasswordLineEditLostFocus()
{
+ slotCheckUserLinesChanged();
}
void SysInstaller::slotListWidgetUsersChanged()
{
+ int i;
+
+ if ( ! listWidgetUsers->currentRow() == -1)
+ return;
+
+ i = listWidgetUsers->currentRow();
+
+ lineUserName->setText(listUsers.at(i).at(0));
+ lineFullName->setText(listUsers.at(i).at(1));
+ lineUserPassword->setText(listUsers.at(i).at(2));
+ lineUserPassword2->setText(listUsers.at(i).at(2));
+
+ if ( listUsers.at(i).at(3) == "/bin/csh")
+ comboShell->setCurrentIndex(0);
+ else if(listUsers.at(i).at(3) == "/bin/tcsh")
+ comboShell->setCurrentIndex(1);
+ else if(listUsers.at(i).at(3) == "/bin/sh")
+ comboShell->setCurrentIndex(2);
+ else if(listUsers.at(i).at(3) == "/usr/local/bin/bash")
+ comboShell->setCurrentIndex(3);
}
+void SysInstaller::refreshUsers()
+{
+ listWidgetUsers->clear();
+ for ( int i = 0; i < listUsers.count(); ++i)
+ listWidgetUsers->addItem(listUsers.at(i).at(0) + " (" + listUsers.at(i).at(1) + ")" );
+
+}
+
void SysInstaller::slotAddUserButton()
{
+ QStringList newUserList;
+ newUserList << lineUserName->text() \
+ << lineFullName->text() \
+ << lineUserPassword->text() \
+ << comboShell->currentText();
+
+ listUsers << newUserList;
+
+ refreshUsers();
+
+ lineUserName->setText("");
+ lineFullName->setText("");
+ lineUserPassword->setText("");
+ lineUserPassword2->setText("");
+
+ slotCheckUserLinesChanged();
}
void SysInstaller::slotRemoveUserButton()
{
+
+ if ( listWidgetUsers->currentRow() == -1)
+ return;
+
+ listUsers.removeAt(listWidgetUsers->currentRow());
+
+ refreshUsers();
+ slotCheckUserLinesChanged();
}
void SysInstaller::slotApplyUserButton()
{
+ QString Shell;
+ int i;
+
+ if ( listWidgetUsers->currentRow() == -1)
+ return;
+
+ i = listWidgetUsers->currentRow();
+ listUsers[i][0] = lineUserName->text();
+ listUsers[i][1] = lineFullName->text();
+ listUsers[i][2] = lineUserPassword->text();
+ listUsers[i][3] = comboShell->currentText();
+
+ refreshUsers();
+ slotCheckUserLinesChanged();
}
+bool SysInstaller::checkUserAccountInfo()
+{
+ bool ok;
+ ok = true;
+
+ // Check if we hav e a username setup.
+ if ( listUsers.empty() )
+ {
+ textAcctNotify->setText(tr("You must setup at least one username to continue. "));
+ ok = false;
+ }
+
+ if ((linePassword->text() != linePassword2->text()) || linePassword->text().isEmpty())
+ {
+ textAcctNotify->setText(tr("Error: Root password must be set to continue. "));
+ ok = false;
+ }
+
+ if(ok)
+ textAcctNotify->setText("");
+
+ return ok;
+}
+
Modified: pcbsd/trunk/SysInstaller/sysinstaller.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.cpp 2009-11-25 14:31:26 UTC (rev 5141)
+++ pcbsd/trunk/SysInstaller/sysinstaller.cpp 2009-11-25 16:13:48 UTC (rev 5142)
@@ -212,6 +212,9 @@
}
}
+ // If the chosen disk is too small or partition is invalid, don't continue
+ if ( stackWidget->currentIndex() == 4 && ! checkUserAccountInfo() )
+ return;
proceed(true);
}
Modified: pcbsd/trunk/SysInstaller/sysinstaller.h
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.h 2009-11-25 14:31:26 UTC (rev 5141)
+++ pcbsd/trunk/SysInstaller/sysinstaller.h 2009-11-25 16:13:48 UTC (rev 5142)
@@ -84,7 +84,7 @@
// User Management Slots
void slotPasswordTextChanged();
void slotRootPasswordLineEditLostFocus();
- void slotCheckUserLinesChanged(const QString & );
+ void slotCheckUserLinesChanged();
void slotUserPasswordLineEditLostFocus();
void slotListWidgetUsersChanged();
void slotAddUserButton();
@@ -106,7 +106,11 @@
void connectDiskSlots(); // Function to connect disk-related slots
void connectUserSlots(); // Function to connect user slots
+ void refreshUsers();
+ bool checkUserAccountInfo();
+ QRegExp passwordRegExp;
+
void proceed(bool);
bool isInstalled();
bool checkDiskRequirements();
@@ -121,6 +125,7 @@
QList<QStringList> sysFinalDiskLayout; // Our lists which contains the final disk layout
int systemMemory; // Ammount of system RAM we have in MB
QStringList savedKeyVariants; // Temp variable to keep key variants in memory
+ QList<QStringList> listUsers; // QStringList which keeps our users
};
Modified: pcbsd/trunk/SysInstaller/sysinstaller.ui
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.ui 2009-11-25 14:31:26 UTC (rev 5141)
+++ pcbsd/trunk/SysInstaller/sysinstaller.ui 2009-11-25 16:13:48 UTC (rev 5142)
@@ -300,7 +300,7 @@
<item>
<widget class="QStackedWidget" name="anteInstallStack">
<property name="currentIndex">
- <number>5</number>
+ <number>4</number>
</property>
<widget class="QWidget" name="aiStep0">
<layout class="QGridLayout" name="gridLayout_10">
@@ -1714,7 +1714,7 @@
</property>
</spacer>
</item>
- <item row="0" column="2" rowspan="8">
+ <item row="0" column="2" rowspan="9">
<spacer name="horizontalSpacer_22">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -1769,7 +1769,7 @@
</property>
</widget>
</item>
- <item row="7" column="1">
+ <item row="8" column="1">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -1923,28 +1923,7 @@
</widget>
</item>
<item row="2" column="1">
- <widget class="QComboBox" name="comboShell">
- <item>
- <property name="text">
- <string>/bin/csh</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>/bin/tcsh</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>/bin/sh</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>/usr/local/bin/bash</string>
- </property>
- </item>
- </widget>
+ <widget class="QComboBox" name="comboShell"/>
</item>
<item row="2" column="3" colspan="2">
<widget class="QPushButton" name="pushApplyUser">
@@ -2015,6 +1994,19 @@
</layout>
</widget>
</item>
+ <item row="7" column="1">
+ <widget class="QLabel" name="textAcctNotify">
+ <property name="styleSheet">
+ <string>color: rgb(167, 0, 0);</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="QWidget" name="aiStep5">
More information about the Commits
mailing list