Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 14, 2014
@beanpole135 beanpole135 Small update to PCDM:
1) Clean up session management/restarts (in case login fails during all the PAM or user/group changes)
2) Update the location of the lastlogin file (/var/db/pcdm/lastlogin), and make sure it is getting saved/loaded properly.
fdf420c
@beanpole135 beanpole135 Merge branch 'master' of github.com:pcbsd/pcbsd bf6b163
View
15 src-qt4/PCDM/src/main.cpp
@@ -144,11 +144,8 @@ int runSingleSession(int argc, char *argv[]){
w.setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
w.setWindowState(Qt::WindowMaximized); //Qt::WindowFullScreen);
- //Setup the signals/slots to startup the desktop session
- //if(USECLIBS){ QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString)), &desktop,SLOT(setupDesktop(QString,QString,QString))); }
- //else{
- QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString,QString)), &desktop,SLOT(loginToXSession(QString,QString,QString,QString)) );
- //}
+ //Setup the signals/slots to startup the desktop session
+ QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString,QString)), &desktop,SLOT(loginToXSession(QString,QString,QString,QString)) );
//Setup the signals/slots for return information for the GUI
QObject::connect( &desktop, SIGNAL(InvalidLogin()), &w, SLOT(slotLoginFailure()) );
QObject::connect( &desktop, SIGNAL(started()), &w, SLOT(slotLoginSuccess()) );
@@ -159,10 +156,7 @@ int runSingleSession(int argc, char *argv[]){
retCode = a.exec();
} // end of PCDM GUI running
//Wait for the desktop session to finish before exiting
- //if(USECLIBS){ desktop.startDesktop(); }
- //else{
desktop.waitForSessionClosed();
- //}
splash.show(); //show the splash screen again
//Now wait a couple seconds for things to settle
QTime wTime = QTime::currentTime().addSecs(2);
@@ -179,8 +173,6 @@ int runSingleSession(int argc, char *argv[]){
//Keep processing events during the wait (for splashscreen)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
- //set the return code for a shutdown
- retCode = -1; //make sure it does not start a new session
}
//Clean up Code
@@ -213,7 +205,8 @@ int main(int argc, char *argv[])
int retCode = runSingleSession(argc,argv);
qDebug() << "-- PCDM Session Ended --";
//check for special exit code
- if(retCode != 0){ neverquit=FALSE; }
+ if(retCode == -1){ neverquit=true; } //make sure we go around again at least once
+ else if(retCode != 0){ neverquit=FALSE; }
//Now kill the shild process (whole session)
qDebug() << "Exiting child process";
exit(3);
View
29 src-qt4/PCDM/src/pcdm-backend.cpp
@@ -91,7 +91,11 @@ QString Backend::getUsernameFromDisplayname(QString dspname){
QString Backend::getDisplayNameFromUsername(QString username){
int i = usernameList.indexOf(username);
- return displaynameList[i];
+ if(i==-1){ i = displaynameList.indexOf(username); } //make sure it was not a display name passed in
+ if(i==-1){ return ""; }
+ else{
+ return displaynameList[i];
+ }
}
QString Backend::getUserHomeDir(QString username){
@@ -249,8 +253,8 @@ void Backend::checkLocalDirs(){
//Check for sample files
if(!mainDir.exists("pcdm.conf.sample")){ QFile::copy(":samples/pcdm.conf",base+"/pcdm.conf.sample"); }
//Check for the PCDM runtime directory
- mainDir.cd("/var/db/pcdm");
- if(!mainDir.exists()){ mainDir.mkdir("/var/db/pcdm"); }
+ mainDir.cd(DBDIR);
+ if(!mainDir.exists()){ mainDir.mkpath(DBDIR); }
}
QString Backend::getLastUser(){
@@ -259,7 +263,8 @@ QString Backend::getLastUser(){
readSystemLastLogin();
}
//return the value
- return lastUser;
+ QString user = getDisplayNameFromUsername(lastUser);
+ return user;
}
QString Backend::getLastDE(QString user){
@@ -273,7 +278,7 @@ QString Backend::getLastDE(QString user){
}
void Backend::saveLoginInfo(QString user, QString desktop){
- writeSystemLastLogin(user,desktop); //save the system file (/usr/local/share/PCDM/.lastlogin)
+ writeSystemLastLogin(user,desktop); //save the system file (DBDIR/lastlogin)
writeUserLastDesktop(user,desktop); //save the user file (~/.lastlogin)
}
@@ -284,7 +289,7 @@ void Backend::readDefaultSysEnvironment(QString &lang, QString &keymodel, QStrin
keylayout = "us";
keyvariant = "";
//Read the current inputs file and overwrite default values
- QFile file("/var/db/pcdm/defaultInputs");
+ QFile file(DBDIR+"defaultInputs");
bool goodFile=false;
if(file.exists()){
if(file.open(QIODevice::ReadOnly | QIODevice::Text) ){
@@ -308,11 +313,11 @@ void Backend::readDefaultSysEnvironment(QString &lang, QString &keymodel, QStrin
}
void Backend::saveDefaultSysEnvironment(QString lang, QString keymodel, QString keylayout, QString keyvariant){
- QFile file("/var/db/pcdm/defaultInputs");
+ QFile file(DBDIR+"defaultInputs");
//Make sure the containing directory exists
- if(!QFile::exists("/var/db/pcdm")){
+ if(!QFile::exists(DBDIR)){
QDir dir;
- dir.mkpath("/var/db/pcdm");
+ dir.mkpath(DBDIR);
}
//Now save the file
if(file.open(QIODevice::WriteOnly | QIODevice::Text) ){
@@ -540,12 +545,12 @@ void Backend::readSystemUsers(){
}
void Backend::readSystemLastLogin(){
- if(!QFile::exists("/usr/local/share/PCDM/.lastlogin")){
+ if(!QFile::exists(DBDIR+"lastlogin")){
lastUser.clear();
Backend::log("PCDM: No previous login data found");
}else{
//Load the previous login data
- QFile file("/usr/local/share/PCDM/.lastlogin");
+ QFile file(DBDIR+"lastlogin");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
Backend::log("PCDM: Unable to open previous login data file");
}else{
@@ -558,7 +563,7 @@ void Backend::readSystemLastLogin(){
}
void Backend::writeSystemLastLogin(QString user, QString desktop){
- QFile file1("/usr/local/share/PCDM/.lastlogin");
+ QFile file1(DBDIR+"lastlogin");
if(!file1.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)){
Backend::log("PCDM: Unable to save last login data to system directory");
}else{
View
1  src-qt4/PCDM/src/pcdm-backend.h
@@ -19,6 +19,7 @@
#include "pcbsd-utils.h"
#define PCSYSINSTALL QString("/usr/sbin/pc-sysinstall")
+#define DBDIR QString("/var/db/pcdm/")
class Process : public QProcess {
public:
View
18 src-qt4/PCDM/src/pcdm-xprocess.cpp
@@ -48,7 +48,10 @@ void XProcess::loginToXSession(QString username, QString password, QString deskt
xde = desktop;
xlang = lang;
//Now start the login process
- startXSession();
+ if( !startXSession() ){
+ //Could not continue after session changed significantly - close down the session to restart
+ QCoreApplication::exit(-1); //special code to make sure we are just restarting the PCDM session (not the full X session)
+ }
}
bool XProcess::isRunning(){
@@ -68,20 +71,21 @@ void XProcess::waitForSessionClosed(){
*/
bool XProcess::startXSession(){
- //disconnect(SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotCleanup()) );
+ //Returns TRUE if the session can continue, or FALSE if it needs to be closed down
+
//Check that the necessary info to start the session is available
if( xuser.isEmpty() || xcmd.isEmpty() || xhome.isEmpty() || xde.isEmpty() ){
emit InvalidLogin(); //Make sure the GUI knows that it was a failure
- return FALSE;
+ return true;
}
//Backend::log("Starting up Desktop environment ("+xcmd+") as user ("+xuser+")");
//Check for PAM username/password validity
- if( !pam_checkPW() ){ emit InvalidLogin(); pam_shutdown(); return FALSE; }
+ if( !pam_checkPW() ){ emit InvalidLogin(); pam_shutdown(); return true; }
//Save the current user/desktop as the last login
- Backend::saveLoginInfo(Backend::getDisplayNameFromUsername(xuser),xde);
+ Backend::saveLoginInfo(xuser,xde);
// Get the users uid/gid information
struct passwd *pw;
@@ -91,7 +95,6 @@ bool XProcess::startXSession(){
if (!(pw = getpwnam(xuser.toLatin1()))) {
uid = strtol(xuser.toLatin1(), &ok, 10);
if (!(pw = getpwuid(uid))) {
- emit InvalidLogin(); //Make sure the GUI knows that it was a failure
return FALSE;
}
}
@@ -109,14 +112,12 @@ bool XProcess::startXSession(){
//QWidget *wid = new QWidget();
if (setgid(pw->pw_gid) < 0) {
qDebug() << "setgid() failed!";
- emit InvalidLogin(); //Make sure the GUI knows that it was a failure
return FALSE;
}
// Setup our other groups
if (initgroups(xuser.toLatin1(), pw->pw_gid) < 0) {
qDebug() << "initgroups() failed!";
- emit InvalidLogin(); //Make sure the GUI knows that it was a failure
setgid(0);
return FALSE;
}
@@ -124,7 +125,6 @@ bool XProcess::startXSession(){
// Lets drop to user privs
if (setuid(pw->pw_uid) < 0) {
qDebug() << "setuid() failed!";
- emit InvalidLogin(); //Make sure the GUI knows that it was a failure
return FALSE;
}
//Startup the PAM session

No commit comments for this range

Something went wrong with that request. Please try again.