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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.