Changeset fdf420c


Ignore:
Timestamp:
03/14/14 10:23:18 (7 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.2, releng/10.0.3
Children:
bf6b163
Parents:
370de21
Message:

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.

Location:
src-qt4/PCDM/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/PCDM/src/main.cpp

    r28c79ad rfdf420c  
    145145    w.setWindowState(Qt::WindowMaximized); //Qt::WindowFullScreen); 
    146146 
    147     //Setup the signals/slots to startup the desktop session 
    148     //if(USECLIBS){ QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString)), &desktop,SLOT(setupDesktop(QString,QString,QString))); } 
    149     //else{  
    150             QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString,QString)), &desktop,SLOT(loginToXSession(QString,QString,QString,QString)) );  
    151     //} 
     147    //Setup the signals/slots to startup the desktop session  
     148    QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString,QString)), &desktop,SLOT(loginToXSession(QString,QString,QString,QString)) );  
    152149    //Setup the signals/slots for return information for the GUI 
    153150    QObject::connect( &desktop, SIGNAL(InvalidLogin()), &w, SLOT(slotLoginFailure()) ); 
     
    160157  }  // end of PCDM GUI running 
    161158  //Wait for the desktop session to finish before exiting 
    162   //if(USECLIBS){ desktop.startDesktop(); } 
    163   //else{  
    164159    desktop.waitForSessionClosed();  
    165   //} 
    166160  splash.show(); //show the splash screen again 
    167161  //Now wait a couple seconds for things to settle 
     
    180174      QCoreApplication::processEvents(QEventLoop::AllEvents, 100);  
    181175    } 
    182     //set the return code for a shutdown 
    183     retCode = -1; //make sure it does not start a new session 
    184176  } 
    185177   
     
    214206    qDebug() << "-- PCDM Session Ended --"; 
    215207    //check for special exit code 
    216     if(retCode != 0){ neverquit=FALSE; } 
     208    if(retCode == -1){ neverquit=true; } //make sure we go around again at least once 
     209    else if(retCode != 0){ neverquit=FALSE; } 
    217210    //Now kill the shild process (whole session) 
    218211    qDebug() << "Exiting child process"; 
  • src-qt4/PCDM/src/pcdm-backend.cpp

    rae41693 rfdf420c  
    9292QString Backend::getDisplayNameFromUsername(QString username){ 
    9393  int i = usernameList.indexOf(username); 
    94   return displaynameList[i];   
     94  if(i==-1){ i = displaynameList.indexOf(username); } //make sure it was not a display name passed in 
     95  if(i==-1){ return ""; } 
     96  else{ 
     97    return displaynameList[i];   
     98  } 
    9599} 
    96100 
     
    250254  if(!mainDir.exists("pcdm.conf.sample")){ QFile::copy(":samples/pcdm.conf",base+"/pcdm.conf.sample"); }  
    251255  //Check for the PCDM runtime directory 
    252   mainDir.cd("/var/db/pcdm"); 
    253   if(!mainDir.exists()){ mainDir.mkdir("/var/db/pcdm"); } 
     256  mainDir.cd(DBDIR); 
     257  if(!mainDir.exists()){ mainDir.mkpath(DBDIR); } 
    254258} 
    255259 
     
    260264  } 
    261265  //return the value 
    262   return lastUser; 
     266  QString user = getDisplayNameFromUsername(lastUser); 
     267  return user; 
    263268} 
    264269 
     
    274279 
    275280void Backend::saveLoginInfo(QString user, QString desktop){ 
    276   writeSystemLastLogin(user,desktop); //save the system file (/usr/local/share/PCDM/.lastlogin) 
     281  writeSystemLastLogin(user,desktop); //save the system file (DBDIR/lastlogin) 
    277282  writeUserLastDesktop(user,desktop); //save the user file (~/.lastlogin) 
    278283} 
     
    285290    keyvariant = ""; 
    286291  //Read the current inputs file and overwrite default values 
    287   QFile file("/var/db/pcdm/defaultInputs"); 
     292  QFile file(DBDIR+"defaultInputs"); 
    288293  bool goodFile=false; 
    289294  if(file.exists()){ 
     
    309314 
    310315void Backend::saveDefaultSysEnvironment(QString lang, QString keymodel, QString keylayout, QString keyvariant){ 
    311   QFile file("/var/db/pcdm/defaultInputs"); 
     316  QFile file(DBDIR+"defaultInputs"); 
    312317  //Make sure the containing directory exists 
    313   if(!QFile::exists("/var/db/pcdm")){ 
     318  if(!QFile::exists(DBDIR)){ 
    314319    QDir dir; 
    315     dir.mkpath("/var/db/pcdm"); 
     320    dir.mkpath(DBDIR); 
    316321  } 
    317322  //Now save the file 
     
    541546 
    542547void Backend::readSystemLastLogin(){ 
    543     if(!QFile::exists("/usr/local/share/PCDM/.lastlogin")){ 
     548    if(!QFile::exists(DBDIR+"lastlogin")){ 
    544549      lastUser.clear(); 
    545550      Backend::log("PCDM: No previous login data found"); 
    546551    }else{ 
    547552      //Load the previous login data 
    548       QFile file("/usr/local/share/PCDM/.lastlogin"); 
     553      QFile file(DBDIR+"lastlogin"); 
    549554      if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ 
    550555        Backend::log("PCDM: Unable to open previous login data file");     
     
    559564 
    560565void Backend::writeSystemLastLogin(QString user, QString desktop){ 
    561   QFile file1("/usr/local/share/PCDM/.lastlogin"); 
     566  QFile file1(DBDIR+"lastlogin"); 
    562567  if(!file1.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)){ 
    563568    Backend::log("PCDM: Unable to save last login data to system directory");      
  • src-qt4/PCDM/src/pcdm-backend.h

    r3b71e5d rfdf420c  
    2020 
    2121#define PCSYSINSTALL    QString("/usr/sbin/pc-sysinstall") 
     22#define DBDIR QString("/var/db/pcdm/") 
    2223 
    2324class Process : public QProcess { 
  • src-qt4/PCDM/src/pcdm-xprocess.cpp

    ra51a897 rfdf420c  
    4949  xlang = lang; 
    5050  //Now start the login process 
    51   startXSession(); 
     51  if( !startXSession() ){ 
     52    //Could not continue after session changed significantly - close down the session to restart 
     53    QCoreApplication::exit(-1); //special code to make sure we are just restarting the PCDM session (not the full X session) 
     54  } 
    5255} 
    5356 
     
    6972 
    7073bool XProcess::startXSession(){ 
    71   //disconnect(SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotCleanup()) ); 
     74  //Returns TRUE if the session can continue, or FALSE if it needs to be closed down 
     75 
    7276  //Check that the necessary info to start the session is available 
    7377  if( xuser.isEmpty() || xcmd.isEmpty() || xhome.isEmpty() || xde.isEmpty() ){ 
    7478    emit InvalidLogin();  //Make sure the GUI knows that it was a failure 
    75     return FALSE; 
     79    return true; 
    7680  } 
    7781  //Backend::log("Starting up Desktop environment ("+xcmd+") as user ("+xuser+")"); 
    7882   
    7983  //Check for PAM username/password validity 
    80   if( !pam_checkPW() ){ emit InvalidLogin(); pam_shutdown(); return FALSE; } 
     84  if( !pam_checkPW() ){ emit InvalidLogin(); pam_shutdown(); return true; } 
    8185 
    8286 
    8387  //Save the current user/desktop as the last login 
    84   Backend::saveLoginInfo(Backend::getDisplayNameFromUsername(xuser),xde); 
     88  Backend::saveLoginInfo(xuser,xde); 
    8589 
    8690  // Get the users uid/gid information 
     
    9296      uid = strtol(xuser.toLatin1(), &ok, 10); 
    9397      if (!(pw = getpwuid(uid))) { 
    94           emit InvalidLogin();  //Make sure the GUI knows that it was a failure 
    9598          return FALSE; 
    9699      } 
     
    110113  if (setgid(pw->pw_gid) < 0) { 
    111114      qDebug() << "setgid() failed!"; 
    112       emit InvalidLogin();  //Make sure the GUI knows that it was a failure 
    113115      return FALSE; 
    114116  } 
     
    117119  if (initgroups(xuser.toLatin1(), pw->pw_gid) < 0) { 
    118120      qDebug() << "initgroups() failed!"; 
    119       emit InvalidLogin();  //Make sure the GUI knows that it was a failure 
    120121      setgid(0); 
    121122      return FALSE; 
     
    125126  if (setuid(pw->pw_uid) < 0) { 
    126127      qDebug() << "setuid() failed!"; 
    127       emit InvalidLogin();  //Make sure the GUI knows that it was a failure 
    128128      return FALSE; 
    129129  } 
Note: See TracChangeset for help on using the changeset viewer.