Changeset b28c8d9


Ignore:
Timestamp:
11/06/13 08:16:57 (10 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
9c27073
Parents:
999faef
Message:

Make sure that PCDM sets the USER and SHELL environment variables appropriately when starting up a user session.

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

Legend:

Unmodified
Added
Removed
  • src-qt4/PCDM/src/pcdm-backend.cpp

    r577dd9b rb28c8d9  
    1212#include "pcbsd-utils.h" 
    1313 
    14 QStringList displaynameList,usernameList,homedirList,instXNameList,instXBinList,instXCommentList,instXIconList; 
     14QStringList displaynameList,usernameList,homedirList,usershellList,instXNameList,instXBinList,instXCommentList,instXIconList; 
    1515QString logFile; 
    1616QString saveX,saveUsername, lastUser, lastDE; 
     
    9191  if( i == -1 ){ i = displaynameList.indexOf(username); } 
    9292  return homedirList[i]; 
     93} 
     94 
     95QString Backend::getUserShell(QString username){ 
     96  int i = usernameList.indexOf(username); 
     97  if( i == -1 ){ i = displaynameList.indexOf(username); } 
     98  return usershellList[i];       
    9399} 
    94100 
     
    366372      displaynameList << uList[i].section(":",4,4).simplified(); 
    367373      homedirList << uList[i].section(":",5,5).simplified(); 
     374      usershellList << uList[i].section(":",6,6).simplified(); 
    368375    } 
    369376  } 
  • src-qt4/PCDM/src/pcdm-backend.h

    r90dc161 rb28c8d9  
    4545    static void log(QString);  
    4646    static QString getUserHomeDir(QString); 
     47    static QString getUserShell(QString); 
    4748    static void checkLocalDirs(); 
    4849 
  • src-qt4/PCDM/src/pcdm-xprocess.cpp

    r999faef rb28c8d9  
    2525  xhome.clear(); 
    2626  xpwd.clear(); 
     27  xshell.clear(); 
    2728  pam_started = FALSE; 
    2829  pam_session_open = FALSE; 
     
    4445  xhome = Backend::getUserHomeDir(xuser); 
    4546  xcmd = Backend::getDesktopBinary(desktop); 
     47  xshell = Backend::getUserShell(xuser); 
    4648  xde = desktop; 
    4749  //Now start the login process 
     
    9496 
    9597  // Get the environment before we drop priv 
    96   QProcessEnvironment environ = QProcessEnvironment::systemEnvironment(); //current environment 
     98  this->setProcessEnvironment( QProcessEnvironment::systemEnvironment() ); //current environment 
    9799  //Now allow this user access to the Xserver 
    98100  QString xhostcmd = "xhost si:localuser:"+xuser; 
     
    132134  //cmd.append(xcmd); 
    133135  //cmd.append("; kill -l KILL"); //to clean up the session afterwards 
    134   // Get the current locale code 
    135   QLocale mylocale; 
    136   QString langCode = mylocale.name(); 
    137136   
    138137  //Backend::log("Startup command: "+cmd); 
    139138  // Setup the process environment 
    140  
    141   // Setup any specialized environment variables 
    142   // USER, HOME, and SHELL are set by the "su" login 
    143   environ.insert("LOGNAME",xuser); //Login name 
    144   environ.insert("USERNAME",xuser); // Username 
    145   environ.insert("PATH",environ.value("PATH")+":"+xhome+"/bin"); // Append the user's home dir to the path 
    146   if( langCode.toLower() == "c" ){} // do nothing extra to it 
    147   else if(!environ.value("MM_CHARSET").isEmpty() ){ langCode.append( "."+environ.value("MM_CHARSET") ); } 
    148   else{ langCode.append(".UTF-8"); } 
    149   environ.insert("LANG",langCode); //Set the proper localized language 
    150   environ.insert("MAIL","/var/mail/"+xuser); //Set the mail variable 
    151   environ.insert("GROUP",xuser); //Set the proper group id 
    152   environ.insert("SHLVL","0"); //Set the proper shell level 
    153   environ.insert("HOME",xhome); //Set the users home directory 
    154   this->setProcessEnvironment(environ); 
    155   this->setWorkingDirectory(xhome); //set the current directory to the user's home directory 
     139  setupSessionEnvironment(); 
     140   
    156141  //Log the DE startup outputs as well 
    157142  this->setStandardOutputFile(xhome+"/.pcdm-startup.log",QIODevice::Truncate); 
     
    179164} 
    180165 
     166void XProcess::setupSessionEnvironment(){ 
     167  // Setup any specialized environment variables 
     168  QProcessEnvironment environ = this->processEnvironment(); 
     169  // Get the current locale code 
     170  QLocale mylocale; 
     171  QString langCode = mylocale.name(); 
     172  if( langCode.toLower() == "c" ){} // do nothing extra to it 
     173  else if(!environ.value("MM_CHARSET").isEmpty() ){ langCode.append( "."+environ.value("MM_CHARSET") ); } 
     174  else{ langCode.append(".UTF-8"); } 
     175  // USER, HOME, and SHELL are set by the "su" login 
     176  environ.insert("LOGNAME",xuser); //Login name 
     177  environ.insert("USERNAME",xuser); // Username 
     178  environ.insert("USER",xuser); // Username 
     179  environ.insert("PATH",environ.value("PATH")+":"+xhome+"/bin"); // Append the user's home dir to the path 
     180  environ.insert("LANG",langCode); //Set the proper localized language 
     181  environ.insert("MAIL","/var/mail/"+xuser); //Set the mail variable 
     182  environ.insert("GROUP",xuser); //Set the proper group id 
     183  environ.insert("SHLVL","0"); //Set the proper shell level 
     184  environ.insert("HOME",xhome); //Set the users home directory 
     185  environ.insert("SHELL",xshell); //Set the user's default shell 
     186  this->setProcessEnvironment(environ); 
     187  this->setWorkingDirectory(xhome); //set the current directory to the user's home directory 
     188} 
    181189/* 
    182190//Start the desktop in the current process with C functions 
  • src-qt4/PCDM/src/pcdm-xprocess.h

    r999faef rb28c8d9  
    4444        int fstatus; //fork status 
    4545        pid_t fpid;  //fork pid 
    46         QString xuser, xcmd, xhome, xpwd, xde; 
     46        QString xuser, xcmd, xhome, xpwd, xde, xshell; 
    4747        bool startXSession(); 
    4848         
     49        // Session environment setup 
     50        void setupSessionEnvironment(); 
     51   
    4952        // PAM stuff and simplification functions 
    5053        pam_handle_t *pamh;  //handle for the PAM process structure 
Note: See TracChangeset for help on using the changeset viewer.